Skip to content

Instantly share code, notes, and snippets.

@erikbgithub
Created August 27, 2010 07:31
Show Gist options
  • Save erikbgithub/552988 to your computer and use it in GitHub Desktop.
Save erikbgithub/552988 to your computer and use it in GitHub Desktop.
>>> parse_input(input, gramar)
{
'text': '\xe4\xbd\xa0\xe5\xa5\xbd,ni3hao3,hello\n\xe8\xb0\xa2\xe8\xb0\xa2,xie4xie0,thanks\n\xe5\xaf\xb9\xe4\xb8\x8d\xe8\xb5\xb7,dui4bu0qi3,sorry',
'type': 'InputText',
'children': [
{
'text': '\xe4\xbd\xa0\xe5\xa5\xbd,ni3hao3,hello\n',
'type': 'TextBlock',
'children': [
{'text': '\xe4\xbd\xa0\xe5\xa5\xbd', 'type': 'A', 'children': []},
{'text': 'ni3hao3', 'type': 'B', 'children': []},
{'text': 'hello', 'type': 'C', 'children': []}
]
}, {
'text': '\xe8\xb0\xa2\xe8\xb0\xa2,xie4xie0,thanks\n',
'type': 'TextBlock',
'children': [
{'text': '\xe8\xb0\xa2\xe8\xb0\xa2', 'type': 'A', 'children': []},
{'text': 'xie4xie0', 'type': 'B', 'children': []},
{'text': 'thanks', 'type': 'C', 'children': []}
]
}, {
'text': '\xe5\xaf\xb9\xe4\xb8\x8d\xe8\xb5\xb7,dui4bu0qi3,sorry\n',
'type': 'TextBlock',
'children': [
{ 'text': '\xe5\xaf\xb9\xe4\xb8\x8d\xe8\xb5\xb7', 'type': 'A', 'children': []},
{'text': 'dui4bu0qi3', 'type': 'B', 'children': []},
{'text': 'sorry', 'type': 'C', 'children': []}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment