Sentence generator using Thesaurus

Pankaj Mishra picture Pankaj Mishra · Sep 21, 2010 · Viewed 8.9k times · Source

I am creating an application in .NET.

I got a running application name http://www.spinnerchief.com/. It did what I needed it to do but but I did not get any help from Google. I need functional results for my application, where users can give one sentence and then the user can get the same sentence, but have it worded differently.

Here is an example of want I want.

Suppose I put a sentence that is "Pankaj is a good man." The output should be similar to the following one:

Pankaj is a great person.
Pankaj is a superb man.
Pankaj is a acceptable guy.
Pankaj is a wonderful dude.
Pankaj is a superb male.
Pankaj is a good human.
Pankaj is a splendid gentleman

Answer

LBushkin picture LBushkin · Sep 21, 2010

To do this correctly for any arbitrary sentence you would need to perform natural language analysis of the source sentence. You may want to look into the SharpNLP library - it's a free library of natural language processing tools for C#/.NET.

If you're looking for a simpler approach, you have to be willing to sacrifice correctness to some degree. For instance, you could create a dictionary of trigger words, which - when they appear in a sentence - are replaced with synonyms from a thesaurus. The problem with this approach is making sure that you replace a word with an equivalent part of speech. In English, it's possible for certain words to be different parts of speech (verb, adjective, adverb, etc) based on their contextual usage in a sentence.

An additional consideration you'll need to address (if you're not using an NLP library) is stemming. In most languages, certain parts of speech are conjugated/modified (verbs in English) based on the subject they apply to (or the object, speaker, or tense of the sentence).

If all you want to do is replace adjectives (as in your example) the approach of using trigger words may work - but it won't be readily extensible. Before you do anything, I would suggest that you clearly defined the requirements and rules for your problem domain ... and use that to decide which route to take.