I don’t think you will get very far from simple regex constructs. The problem is that since you are obviously working in the field of natural language, there are many, many possibilities that you must consider. How should there be a solution?
I know that you said that this is possible using the Java API, but is it possible to use Prolog? SWI-Prolog has a Java interface (JPL), and the problem you are describing will be much better solved in Prolog. Infact is the kind of problem that Prolog does best and is used for academic purposes. SWI-Prolog even includes a natural language processing package ( http://www.swi-prolog.org/pldoc/package/nlp.html ). This is the best way that I know to deal with a problem like yours.
Of course, I don’t know how important this function is for your product / project, and using Prolog is probably not an option, so another option is to write a parser that will extract a verb / noun, etc. and create the corresponding “proposal model” (or group of objects). Then you can convert this proposal model into another proposal model, based on some rules, developed in an extensible way, so when new pop-ups (and with such a wide domain they will be), you can simply add a new rule to your transformation.
This is really a non-trivial solution, but I can’t imagine what a trivial solution might look like.
Bernard marx
source share