Converting an interrogative sentence into an imperative sentence

I'm trying to develop natural language interfaces for a database, and I'm just wondering if there is a library or API (Java) that I can use to convert a question (interrogative sentence) into a command (imperative sentence).

Ex: from "What kind of employees were born before 1970?" "Get employees born before 1970."

+6
source share
1 answer

This is a rather complicated and non-trivial problem. However, if your domain is limited (querying a database of employees, etc.), and you expect only a limited set of statements as input, you can create a simple rule-based system.

The simplest solution is to develop a set of expression-based translation rules. For instance. suppose that the word that appeared after (was | was) is a verb. You can save the dictionary of all common verbs and their mappings in the fields of your database. Here "born" will be displayed in a field that can be called DATE_OF_BIRTH, for example.

A more complex rule-based solution will be to search or create a parser for your chosen language and perform a conversion based on the output of the parser and the rule base. For instance. The parser will infer what a predicate of a sentence, subject, etc. You will have a set of rules that will modify these parts of the sentences to create an imperative structure.

If you hate the idea of ​​developing a rule base manually, you can always try the machine learning approach and prepare a statistical system. Here you need to develop a database of questions that covers most types of questions that you might expect) and prepare a statistical model.

If I proposed one library / tool for experimenting with any of the above approaches, I would say OpenNLP.

0
source

All Articles