word_aligner
word_aligner lets you compare string as word_align.pl script does in cmu-sphinx.
It calculates distance in terms of insertions, deletions and substitutions.
Installation
Add this line to your Gemfile:
gem 'word_aligner'
Then execute:
$ bundle
Usage
error_rate = WordAligner.align('example shown line', 'they shown line')
error_rate.aligned_transcription => "EXAMPLE shown line"
error_rate.aligned_hypothesis => "THEY shown line"
error_rate.words => 3
error_rate.insertions => 0
error_rate.deletions => 0
error_rate.substitutions => 1
error_rate.correct => 2
error_rate.errors => 1
error_rate.percentage_correct => 66.0
error_rate.percentage_incorrect => 33.0
error_rate.percentage_accurate => 66.0
There is also WordErrorRateCollection
if you need to calculate
the word error rate for multiple hypotheses.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request