【发布时间】:2013-05-22 04:29:32
【问题描述】:
在网上浏览了一天后,我在这里问这个问题:
有什么方法可以得到 pyparsing 结果,f.e.
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?'
}
}
【问题讨论】:
标签: python json python-2.7 pyparsing