I have data where there is text for each user A visiting a business B. I want to find similarity between each user using their text.

Question 1: Which NLP method should I start with?

I have tried cosine similarity, I know its a great method but it's very slow in computing similarities.

I have thought about extracting important information from text (for example: Term Extraction, I don't want to use LDA) and computing similarities between that information.

Question 2: Any suggestions?

this is how text data looks like

  • $\begingroup$ Hi, can you show some example of how these texts look like? $\endgroup$ Jul 31, 2018 at 8:18
  • $\begingroup$ @BrunoGL I have edited my post. You can see how text data looks now. $\endgroup$
    – jdwins11
    Aug 1, 2018 at 16:23
  • $\begingroup$ Try sentence to vectors and get similarity measure. Look word2vec and Doc2vec $\endgroup$ Aug 2, 2018 at 5:18
  • $\begingroup$ cosine similarity is basically a two vector dot product, why do you think it is slow? $\endgroup$
    – QtRoS
    Jun 5, 2019 at 13:16

1 Answer 1


There are many ways to see how texts are similar, but this will depend on your use case.


Nowadays, word embeddings are getting popular. Like it was suggested in the comments, you could use Doc2Vec to transform your sentence into a vector and calculate the cosine distance from each sentence.

The idea with these learned embeddings is that you kind of encode the meaning of the sentence by looking how words are used in context. So, to sentences would be similar if words are used in the same manner in a context.

However, this could potentially be difficult to interpret.

For example:

Good tattoo shop. Clean space.
Good pizza restaurant. Large space.
Terrible tattoo shop. Dirty space.

Which of these are semantically close? It will depend a lot on your training and your own judgment to tell if the results are useful to you.


Maybe you are interested in saying that sentences are similar if their sentiment is positive or negative (or on some other scale).

For example:

Suppose you can have sentiment on a scale $[-1,1]$, where $-1$ is negative, $0$ is neutral and $1$ is positive.

Good tattoo shop. Clean space.
    Sentiment = 0.7

Good pizza restaurant. Large space.
    Sentiment = 0.75

Terrible tattoo shop. Dirty space.
    Sentiment = -0.9

There are many resources online on how to do this. Here is an answer with some links.


The bag-of-words is a very simple approach, but depending on what you are doing, it could do the trick. Suppose you want to say that sentences are similar if they are about a business in the same industry.

You can make a simple dictionary for every industry:

word_per_industry = {
    'restaurants' = ['restaurant', 'food', 'chef', 'dish', 'salad', 'lunch'],
    'tatto_shop' = ['clean', 'dirty', 'art', 'sterlized']

Then, per sentences, you can count which business has more words in the sentence, and if sentences are from the same industry they are similar. Of course, you could also make lists based on another characteristic, not necessarily on industries.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.