经过一天的互联网浏览后,我在这里问这个问题:
有没有办法得到pyparsing结果,fe
result = longSentence.parseString(text.lower())
以JSON格式?
2013 年 5 月 27 日 11:46 更新:
好的。所以我尝试制作一个简单的英语解析器。
句子“走 5 米,你看到了什么?”的结果 现在打印为列表:
[[[['go'], [['5', 'metres']]]], 'and', ['what do you see?']]
['what do you see?']
标记为SetResultsName('Question')
其他标记为相似。
如果它将以这种形式打印该数据,那就太好了:
{
"Sentence1":
{
"Order":
{
"Predicate": 'go',
"Subject": ['5', 'metres']
}
},
"Sentence2":
{
"Question": 'what do you see?'
}
}