CmpText is a simple text comparison tool. It was originally created for the purpose of comparing two copyright licenses to determine their textual similarity. At present, its only use is to compare two texts and return a percentage match score.


At this time, the easiest way to install the CmpText gem is to download the *.gem file from the Bitbucket project then install using the gem install command:

gem install cmp_text-N.N.N.gem

The N.N.N in this case is the version number of the gemfile you downloaded.

Users of 1.8.x versions of Ruby may want to add one of the following lines to their shell rc files. It ensures easier management of gems, and circumvents the need for special handling of the tests for this project.

For sh-style shells:

export RUBYOPT='-r rubygems'

For csh-style shells:

setenv RUBYOPT '-r rubygems'

If you do not set this, you can run the tests with a command line the following:

ruby -r rubygems cmptext_tests.rb


Include the CmpText module in a class:

require 'cmp_text'

class Foo
  include CmpText
  # more code here

Use the cmp_text.rb file directly as a command line utility:

$ cmp_text.rb file1.txt file2.txt


Plans for this project include adding it to the public archive of Ruby gems and creating an online license comparison page at the Copyfree Initiative site.


Copyright 2011 Sterling Camden

Project files may be distributed under the terms of the Open Works License. See the license.txt file for details.