5
$\begingroup$

In the context of text mining, I'd like to discover potential synonyms in my dataset. The current dataset is stackexchange's stackoverflow data on archive.org. The result doesn't have to be perfect, I can post-process it by hand. But I need help to have a clue of which term seems to be "similar" to another term.

Here examples of synonyms I am looking for:

  • postgresql, postgres, pgsql, psql
  • mobile, phone, android, iphone

Also in best case, it should be possible to also guess multi word synonyms like:

  • rdbms, relational database management system
  • obama, barack obama

The algorithm doesn't need to compute whether those are many-way synonyms (like rdbms and relational database management system) and one-way synonyms (like iphone is mobile but not all mobile are iphone).

I read that word2vec can be helpful but I am not sure how to use it.

$\endgroup$
5
$\begingroup$

word2vec is probably the way to go. It maps words to a point in n-dimensional space. You can use Euclidean (or whatever distance) to find the nearest points to a given word. If training went well, the closest points should be a synonym.

$\endgroup$
  • $\begingroup$ So how would you handle this in practice? Train a word2vec model with a dictionary of synonyms and then implement that model in your (larger) project where you need the synonyms? $\endgroup$ – I_Play_With_Data Mar 23 '18 at 19:46
  • 3
    $\begingroup$ Unfortunately word2vec representations are purely based on the context that a word appears, which means that often antonyms have very similar vector representations as well. For example, good and bad will often appear in the same context but they are clearly not synonyms. $\endgroup$ – timleathart Mar 23 '18 at 22:43
  • $\begingroup$ word2vec is a tool. Word Embedding is a language modeling technique. $\endgroup$ – Abdulrahman Bres Mar 24 '18 at 22:33
3
+25
$\begingroup$

As Kyle said on his answer word2vec can be run with the data dump data and you would get a mapping that shows the closest words, that are possible synonym candidates. Same approach is on this Quora post.

Here is explained how word2vec makes a vector of probabilities of different words and with cosine similiary (highest cosine distances) you can find the nearest ones = the synonym candidates. A code example is on this Github. There is a KDT tree used and its cosine distance. (KDT = k dimensional tree)

Basically a synonym is a word with enough little distance, and you can set some threshold to find all enough near ones or only the nearest. All that in code of course.

In the mentioned Quora WordNet was mentioned as a source of synonyms too, but then I came up also with idea of using SE Tag Synonym dump (see here), where we have a superwised source of common synonyms. Those can be used as alternative source of synonyms, or as a database to verify the ones found by the distance method.

$\endgroup$
  • 1
    $\begingroup$ Answer to Bounty question "Are there ways to handle "car" versus "automobile"?" is that word2vec analyzes with which word context these both are used and from the surrounding data it will make the desicion they belong together. It does not matter how different the words look like as letters. $\endgroup$ – mico Mar 24 '18 at 17:39

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.