What algorithm can help me discover synonyms? 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.
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.