将疑问句转换为祈使句 [英] Convert interrogative sentence to imperative sentence

查看:90
本文介绍了将疑问句转换为祈使句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发数据库的自然语言接口,我只是想知道是否有一个库或 API (Java) 可用于将问题(疑问句)转换为命令(命令式)句).

I'm trying to develop a Natural Language Interfaces to Database, and I'm just wondering if there is a library or an API (Java) that I can use to convert a question (interrogative sentence) to a command (imperative sentence).

例如:来自哪些员工出生于 1970 年之前?"以让员工在 1970 年之前出生."

Ex : from "Which employees were born before 1970?" to "Get employees born before 1970."

推荐答案

这是一个相当复杂且重要的问题.但是,如果您的域有限(员工数据库查询等)并且您只希望将有限的话语集作为输入,您可以构建一个简单的基于规则的系统.

This is a rather complex and non-trivial issue. However if your domain is limited (employee database queries, etc.) and you only expect a limited set of utterances as an input you could build a simple rule-based system.

最简单的解决方案是开发一组基于正则表达式的转换规则.例如.假设出现在 (was|were) 之后的词是动词.您可以保留所有常用动词及其到数据库字段的映射的字典.此处出生"将映射到一个可以称为 DATE_OF_BIRTH 的字段,例如.

The simpliest solution would be to develop a set of regular expression-based transformation rules. E.g. assume that the word appearing after (was|were) is the verb. You could keep a dictionary of all frequent verbs and their mappings to your database fields. Here "born" would be mapped to a field that could be called DATE_OF_BIRTH for instance.

更复杂的基于规则的解决方案是为您选择的语言查找或构建解析器,并根据解析器输出和您的规则库执行转换.例如.解析器将输出什么是句子谓词、主语等.您将拥有一组规则来重新排列句子的这些部分以生成命令式结构.

A more sophisticated rule-based solution would be to find or build a parser for the language of your choice and perform the conversion based on the parser output and your rule base. E.g. The parser would output what is the sentence predicate, subject, etc. You would have a set of rules that would rearrange those parts of sentences to produce an imperative structure.

如果您讨厌手动开发规则库的想法,您可以随时尝试机器学习方法并训练统计系统.在这里,您需要开发一个问题数据库,涵盖您可能期望的大多数问题类型)并在其上训练统计模型.

If you hate the idea of developing a rule base manually you could always try the machine learning approach and train a statistical system. Here you need to develop a question database that covers most question types you could be expecting) and train a statistical model on it.

如果我建议使用单个库/工具来试验上述任何一种方法,我会说 OpenNLP.

If I was to suggest a single library/tool for experimenting with any of the above approaches I would say OpenNLP.

这篇关于将疑问句转换为祈使句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆