A tool for calculation semantic similarity between words from a text corpus based on lexico-syntactic patterns.
C# Perl Other
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



A tool for calculation semantic similarity between words from a text corpus based on lexico-syntactic patterns.

  • Currently, the tool consist of two separate programs -- patternsim and patternsim-rank (see below).
  • This tool implements the extraction method described in these papers:
    • Panchenko A., Morozova O., Naets H. “A Semantic Similarity Measure Based on Lexico-Syntactic Patterns.” In Proceedings of the 11th Conference on Natural Language Processing (KONVENS 2012), — Vienna (Austria), 2012
    • http://www.oegai.at/konvens2012/proceedings/23_panchenko12p/
    • Kristina Sabirova, Artem Lukanin. Automatic Extraction of Hypernyms and Hyponyms from Russian Texts // Supplementary Proceedings of the 3rd International Conference on Analysis of Images, Social Networks and Texts (AIST 2014) / Ed. by D. I. Ignatov, M. Y. Khachay, A. Panchenko, N. Konstantinova, R. Yavorsky, D. Ustalov. Vol. 1197: Supplementary Proceedings of AIST 2014. CEUR-WS.org, 2014. С. 35-40.
    • http://ceur-ws.org/Vol-1197/paper6.pdf
  • A demo of the extraction results provided with this method can be accessed here: http://serelex.cental.be/
  • Related repositories:


LGPLv3: http://www.gnu.de/documents/lgpl-3.0.en.html


A tool for extraction of raw extraction counts with lexico-syntactic patterns.


Installation on Ubuntu 12.04

  1. Install Unitex 3.0beta (http://www-igm.univ-mlv.fr/~unitex/zips/Unitex3.0beta.zip)
  2. Install cpanm: "sudo cpan App::cpanminus"
  3. Install all dependencies: "sudo cpanm --installdeps ."

Quick Start

Use ./rerank.sh to rerank relations with the default formula, and as an example of usage of patternsim-rank.


patternsim [options] [corpus_file(s) ...]


patternsim [options] [corpus_file(s) ...]

  Mandatory options:
    --unitex                 Unitex main directory
    --output (-o)            output directory

    --vocabulary (-v)        input vocabulary file
    --workers (-w)           number of workers
    --language (-l)          language

    --list-languages         list all available languages

    --verbose                verbose mode
    --help                   brief help message
    --man                    full documentation

--unitex *unitex_main_directory*
        Specify the Unitex main directory if you want to use your own
        Unitex installation (overwite the patternsim configuration file)

--output -o *output_directory*
        Specify the output directory.

--vocabulary --vocab -v *vocabulary_file*
        Specify the UTF-8 input vocabulary file (one word per line)

--workers -w *number_of_workers*
        Specify the number of parallel workers Workers will extract in
        parallel semantic relations. A good number of workers will be
        the number of CPU cores minus 1.

--language -w *language_id*
        Specify the current language

        Show all available languages (language_id and full name)

        Explains what is being done

--help -h
        Prints a brief help message and exits.

--man   Prints the manual page and exits.

        Activates the verbose mode. Explains all the processes. Outputs
        will be shown on stderr.


./patternsim --unitex /home/user/Unitex3.0beta -v vocabulary.txt -o output corpus.txt

The output of this command -- a set of files in the directory "./output":

  • conc-freq.csv -- a frequency list derived from a set of extraction concordances
  • corpus-freq.csv -- a frequency list derived from an input corpus "corpus.txt"
  • pairs.csv -- similarity matrix containing raw extraction counts between all single words
  • pairs-np.csv -- similarity matrix containing raw extraction counts between all noun phrases
  • pairs-voc.csv -- similarity matrix containing raw extraction counts between terms from the input vocabulary "vocabulary.txt"

The files conc-freq.csv and corpus-freq.csv are CSV files in the following format:


The files pairs.csv, pairs-np.csv and pairs-voc.csv are CSV files in the following format:


Here target-word and related-word are words, ' e-all is the number of extractions between target-word and relatum-word with all the 17 patterns, ei is number of extractions between target-word and relatum-word with the i-th pattern (see the referenced above paper for details). Thus e-all = sum_i (ei).

e-syno, e-cohypo, e-hyper, e-hyper-hypo, e-hypo is the number of specific relations extracted between terms (synonyms, co-hyponyms, hypernyms, hyponym, hypernyms+hyponyms).


Here are some corpora which you may use with this tool:

Russian morphological dictionary

The Russian dictionary in this repository is an extract of the Russian computational morphological dictionary developed at CIS, Munich. This extract contains about 15% of the original dictionary (the most frequent lemmata). The whole dictionary actually contains 140,000 simple entries (= 2.7 million distinct forms), 166,000 simple proper nouns (= 900,000 distinct forms) and 1800 compound words.

If you want to use the full version of the lexicon, please contact:

Sebastian Nagel
Oettingenstr. 67
80538 München

For additional information see:

Nagel, Sebastian 2002: Formenbildung im Russischen. Formale Beschreibung und Automatisierung für das CISLEX-Wörterbuchsystem (http://www.cis.uni-muenchen.de/~wastl/pub/ruslex.pdf)

For a short description (in German), see http://www.cis.uni-muenchen.de/~wastl/pub/ruslexUnitex.pdf


Reranking semantic similarity scores between words extracted with the patternsim. Directory -- "rank".


patternsim-rank [options]

System Requirements


Binaries are readily available the bin folder. On Unix based systems you may use "./patternsim-rank" or "./patternsim-rank.exe". On Windows, use "patternsim-rank.exe".


  1. Download test data http://cental.fltr.ucl.ac.be/team/~panchenko/sim-eval/patternsim-rank-data.tgz.
  2. Save the archive to the "rank" directory.
  3. Extract the data (tar xzf patternsim-rank-data.tgz). The directory "data" should appear.
  4. Run tests.sh script. It will produce the output in the data/output folder.


  1. Open patternsim-rank.sln with MonoDevelop or Visual Studio.
  2. Build the solution.


p, pairs

Required. An UTF-8 encoded CSV file in provided by the PattenSim program. In the format:


This file must contain symmetric relations between words (generated by the PatternSim by default). If there exist a relation 'target;relatum;type;sim' then there should exist one and only one relation 'relatum;target;type;sim' in the same file.

o, output

Required. An UTF-8 encoded CSV file 'target;relatum;sim', where 'sim' is similarity score between 'target' and 'relatum'. This file is sorted by 'target' and then 'sim'.

c, corpusfreq

Required. An UTF-8 encoded CSV file 'word;freq' with frequencies of words.

t, type

Required. Type of reranking:

  1. Efreq, no reranking, transform scores to the interval [0;1].
  2. Efreq-Rfreq, reranking by frequency of relations to other words. Uses option 'alpha'.
  3. Efreq-Rnum, reranking by number of relations to other words. Uses option 'beta'.
  4. Efreq-Cfreq, reranking by word frequency. Uses option 'corpusfreq'.
  5. Efreq-Rnum-Cfreq, reranking by number of relations to other words and by word frequency. Uses options 'beta' and 'corpusfreq'.
  6. Efreq-Rnum-Cfreq-Pnum, reranking by number of relations to other words, by word frequency and by number of different patterns extracted the relations. Uses options 'corpusfreq', 'patterns', 'beta' and 'sqrt'.

a, alpha

Expected number of relations per word, default -- 15.

b, beta

Minimum number of extractions which establish a relation between words, default -- 2.

s, sqrt

Sqrt of the number of different patterns, default -- true.