I am already familiar with some text (document) classification algorithms after processing into a Bag-of-words & tf-idf representation. Classification algorithms such as Multionmial Naive Bayes, Logistic regression, Support vector machine, etc. I also looked into word2vec and not sure if it's suitable for what I am trying. I need something more than just a tf-idf computation, I want to classify based on the semantic relations in the text and I will provide an example.

Let's assume as a simple case I want to predict if a movie is receiving a good review or a bad one, for example the movie "A.I.: Artificial Intelligence". But the sentence is usually composed of one or move movies:

Sentence example: "I really disliked the movie "Ex Machina", but "A.I.: Artificial Intelligence" was quite good!"

Thus inside the sentence I only want to find the relation with the movie "A.I.: Artificial Intelligence" and I don't care at all about other movies. But traditional algorithms could interpret this as a bad review because they capture the words not related to "A.I.: Artificial Intelligence".

So my question is what is the best way to handle such cases.

2 Answers 2


There are two paths you can take to solve this problem, both outlined in Jurafsky & Martin (2016), Ch. 15.

1) If computing your own semantic similarity matrix, you can shrink the size of the window where the model looks for co-occurrences. In your example, if the window around the title was 3 words, it would pick up "quite good" but not "disliked." In general, the smaller the window size, the more syntactically related the co-occurrences.

2) You can use an algorithm that takes semantic/syntactic dependency into account. From the above textbook:

In other words, we could define the dimensions of our context vector not by the presence of a word in a window, but by the presence of a word in a particular dependency (or other grammatical relation)...

A number of previous studies have used this, as outlined in the linked chapter. They either only count semantic/syntactic co-occurrences, or under/overweight co-occurrences based on semantic/syntactic relationships.

  • That's the direction I was looking for. Thanks Adam_G.
    – rafiko1
    Commented Jul 20, 2017 at 16:59

Your broader question is about semantic relations, but the example you gave was about a narrower, but still widely researched field, that of opinion mining. Since you're asking about an entire field, it would be hard for me to get into the details. I'll treat the question as a reference request, and recommend the book Opinion mining and sentiment analysis. Published in 2008, the book is somewhat dated now, but it's still a good enough starting point to explore the various techniques used.

  • Thank you, book is indeed a good intro to opinion mining.
    – rafiko1
    Commented Jul 19, 2017 at 11:56
  • One additional point, if you are specifically working on opinion mining or sentiment analysis, you may also want to take a look at "aspect/entity-level sentiment analysis." I kind of addressed it in my response here: stackoverflow.com/questions/11141194/…
    – Pedram
    Commented Aug 23, 2018 at 19:26

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.