Sign inSign up

o76923/mi-similarity

By o76923

Updated almost 9 years ago

Docker image to calculate semantic similarity on lists of short texts using Michalcea's algorithm.

Image
0

1.1K

o76923/mi-similarity repository overview

Mihalcea Similarity Calculator

This container is used to calculate semantic similarity based on Mihalcea's algorithm for short text similarity as described in Mihalcea, Corley, & Strapparava (2006). Some slight modifications have been made to this instantiation of the algorithm as described in Larsen & Bong (2016).

Running the Tool

In order to run the tool, type the following into your terminal

docker run -it -v /local/data/path/:/app/data -e CONFIG_FILE=config.yml o76923/mi-similarity

Where /local/data/path/ is the path on your local system that contains the source information and config.yml is the configuration file in that directory containing which tasks should be performed as well as their settings.

Directory Structure

The path on your local machine should contain the following

  1. A configuration file
  2. An information content file
  3. The texts to be compared

Configuration File

The configuration file specifies the parameters that will tweak how the tool behaves. A sample configuration file is provided in /app/conf/config.yml. The sections of it are as follows

Tasks

There is presently only one task that can be performed with this tool: "calculate_similarity".

calculate_similarity

The calculate_similarity task is used to generate semantic similarity scores between short texts. A sample calculate_similarity task is included below, followed by an explanation of the options available.

  - type: calculate_similarity
    from:
      files:
        - input/def.txt
      pairs: all
      headers: true
      numbered: true
    options:
      batch_size: 100
    output:
      format: H5
      file_name: def.h5
      ds_name: mi
files
A list of files that contain the short texts to be compared.
pairs
Which pairs of short texts should be compared to one another? At the moment, "all" is the only option supported which compares each text to every other text.
headers
Do your files contain a header row that should be skipped?
numbered
Do the texts have IDs assigned to them already?
format
What format should the similarity scores be written to? At the moment, only "H5" is available which saves the output in the HDF5 file format.
file_name
The name of the similarity file. It will be placed in the `/app/data/output` directory.
ds_name
If the format is "H5", you can specify the name of the data source. This name will be used in both the sims and vector groups.
Options

Options specifies global options that will apply to all tasks run. At this time, only one option is available.

cores
The maximum number of processor cores that can be used at any given time. Note that this is based on how many threads that this tool will create on its own. It is possible, due to the use of certain math libraries, that more than this number of cores will be used.

Information Content File

The Mi algorithm requires that there be a .ic file which stores information on the inverse document frequency of words based on a corpus. These freqeuncies are used in the Wu & Palmer; Lin; and Jiang & Conrath wordnet similarity components.

This file is expected to be located in /app/data/bnc.ic which should be in the base directory of /local/data/path/.

The source data can be downloaded from the page for the WordNet::Similarity perl package.

Based on this sorce data, you will need to convert it from a .dat file with raw counts to a .ic file that contains the inverse document frequency. Instructions for this process are coming soon.

Texts to be Compared

The texts to be compared are the short texts that you wish to have compared to one another. Similarity scores will be generated between texts with one ID and texts with another ID.

Tag summary

Content type

Image

Digest

Size

410.9 MB

Last updated

almost 9 years ago

docker pull o76923/mi-similarity