The Levenshtein algorithm and some ratio and proportion may handle this use case.

Based on the pre-defined sequence of statements, such as "I have a dog", "I own a car" and many more, I must determine if an another input statement such as "I have a cat" is the same or how much percentage does the input statement is most likely equal to the pre-defined statements.

For Example:

Predefined statements: "I have a dog", "I own a car", "You think you are smart"

Input statements and results:

I have a dog - 100% (because it has exact match), I have a cat - ~75% (because it was almost the same except for the animal, think - ~10% (because it was just a small part of the third statement), bottle - 0% (because it has no match at all)

The requirement is that TensorFlow be used rather than Java, which is the language I know, so any help with what to look at to get started would be helpful.

My plan was to use the predefined statements as the train_data, and to output only the accuracy during the prediction, but I don't know what model to use. Please, guide me with the architecture and I will try to implement it.


1 Answer 1


If this is a simple syntax comparison, neural networks is not the best way to achieve this.

If it's semantic comparison, then you can take a look at models used in the SNLI dataset for example.

From your question, it looks like just a syntax comparison.

Consider the 2 sentences :

She likes playing guitar

She likes listening guitar

The 2 sentences have almost the same words, but the meaning is different.

Now consider these 2 sentences :

The bird is taking a bath in the fountain

Birdie wash himself with water in public place

These 2 sentences have almost no words in common, but the meaning are very similar.

So if your use case need to return a high-score for the first example, give up neural network (it is possible, but pointless).

If your use case need to return a high-score in the second example, take a look at SNLI leaderboards, there is plenty of models that can works.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .