我正在尝试将英语语句转换为SQL查询 例如去年创造了多少产品?
这应该转换为
select count(*) from products
where manufacturing date between 1/1/2015 and 31/12/2015
我无法理解如何映射动词"创建"制造日期"制造日期"我表中的属性。我正在使用斯坦福核心nlp套件来解析我的陈述。我也在使用带有JWI框架的wordnet分类法。
我试图通过定义简单规则将动词映射到属性。但这不是一种非常通用的方法,因为我无法事先知道所有的动词。有没有更好的方法来实现这个目标?
我很感激这方面的任何帮助。
答案 0 :(得分:0)
我知道这需要更换工具,但我会建议您通过Mycroft AI查看Adapt。
这是一个非常直接的意图解析器,它将用户输入转换为json语义表示。
例如:
Input: "Put on my Joan Jett Pandora station."
JSON:
{
"confidence": 0.61,
"target": null,
"Artist": "joan jett",
"intent_type": "MusicIntent",
"MusicVerb": "put on",
"MusicKeyword": "pandora"
}
看起来规则很容易指定和扩展,因此您只需要构建规则,然后使用您想要的任何工具来处理JSON并发送SQL查询。