0
$\begingroup$

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

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

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

Semantics

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.

Sentiment

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.

BoW

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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