How to create exclamations for a specific sentence

I would like to create exclamations for a specific sentence using the java API?

eg. It's amazing. Isn't it amazing! e.g. Cold. Not cold!

Are there any suppliers or tools that will help you generate exclamations if you give a suggestion (i.e. the left side in the example above). Note. Suggestions will be provided by the user, and we should be able to get the right offer.

I'm not sure if it needs to be tagged under other categories

EDIT1

A few more examples, I would like this to be as general as possible

eg. They are late == Do not be late!
for example, he looks tired. He does not look tired!
for example This baby is dirty. Isn't that a dirty kid! for example It's hot. Isn't it hot!

+6
java regex nlp text-manipulation
source share
6 answers

This question is not about exclamations. You can just add '!' for all your examples of input and receipt of valid exclamation points.

You perform grammar transformations, such as these .

LingPipe looks like it has some interesting things that you could use (this is java), especially if you are developing a learning system and you need to recognize “ parts of speech ” (for example, a subject and a verb phrase, according to your examples).

+2
source share

Depending on how smart and complex you want it to be, this can be a very complex or very simple problem. Here's a simple regex that is pretty dumb:

String[] sentences = { "It surprising", "It cold", "It $*($&%!", "That is a hot coffee indeed..." }; for (String sentence : sentences) { System.out.println( sentence.replaceAll("It (.+)", "Isn't it $1!") ); } 

Prints ( as seen on ideone.com ):

  Isn't it surprising!
 Isn't it cold!
 Isn't it $ * ($ &% !!
 That is a hot coffee indeed ...
+8
source share

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.

+3
source share

Take a look at the Natural Language ToolKit , and then ask your question about which subset of English you want your code to work on, and a clearer definition of the types of exclamation translation you want.

+1
source share

Here is my regular expression example without deep language analysis. It can be easily fooled, but it handles most of your examples.

 s.replace("(.+?)('re| are) (.+)", "Aren't $1 $3!") .replace("(.+?)('s| is) (.+)", "Isn't $1 $3!") .replace("(I|You|We|They) (.+)", "Don't $1 $2!") .replace("(He|She|It) (\\w+)s (.*)", "Doesn't $1 $2 $3!") // correct case .replace(" You", " you") .replace(" He", " he") .replace(" She", " she") .replace(" It", " it") .replace(" We", " we") .replace(" They", " they"); 
+1
source share

I don’t know how sophisticated you want it to be, but if you just want to change expressions like “That's all” to “Isn't it!”, Then this is very simple:

 String text = "It cold"; String result = "Isn't it " + text.substring(5) + "!"; 

(Even simpler than a regular polygenic lubricant solution).

-2
source share

All Articles