Corrector
<img src=“http://img.shields.io/gem/v/corrector.svg?style=flat” alt=“Gem Version” /> <img src=“http://img.shields.io/travis/nepalez/corrector.svg?style=flat” alt=“Bild Status” /> <img src=“http://img.shields.io/codeclimate/github/nepalez/corrector.svg?style=flat” alt=“Code Metrics” /> <img src=“http://img.shields.io/gemnasium/nepalez/corrector.svg?style=flat” alt=“Dependency Status” /> <img src=“http://img.shields.io/coveralls/nepalez/corrector.svg?style=flat” alt=“Coverage Status” /> <img src=“http://img.shields.io/badge/license-MIT-blue.svg?style=flat” alt=“License” />
About
Rails plugin for cyrillic texts correction using words and phrases dictionary.
It defines two dictionaries:
Word
-
A dictionary of words
Prefix
-
A dictionary of word prefixes
Phrase
-
A dictionary of phrases
and a service Parse
that:
-
converts a source text to uppercase cyrillic one;
-
breaks it to words;
-
corrects any single word using
Prefix
andWord
dictionaries; -
puts corrected words back to sentence;
-
corrects the sentence using the
Phrase
dictionary; -
returns the result.
The model is expected to be used as a part of various classificators - to allow searching items by words in Russian.
Example
After adding some words and phrases:
Prefix.create! from: "КИЛО", to: "К", scope: "UNITS"
Word.create! from: "МЕТРОВ", to: "М", scope: "UNITS"
Word.create! from: "СЕКУНДУ", to: "С", scope: "UNITS"
Phrase.create! from: "КМ В С", to: "ТЫС М/С", scope: "UNITS"
the phrase can be corrected properly:
Parse.new "килоmетров в секyndу", scope: "UNITS" # => "ТЫС М/С"
Installation
Add this line to your application’s Gemfile:
gem "corrector"
And then execute:
$ bundle
Or install it yourself as:
$ gem install corrector
Initialization
You should:
-
copy the module’s db migrations to your project and run them;
-
copy the module’s factories (for usage in your Rspec tests).
To do all of above you can use corrector:install
rake task:
in a Rails application
$ rake corrector:install
in a Rails mountable engine
$ rake app:corrector:install
Contributing
-
Fork it ( github.com/nepalez/corrector/fork )
-
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 a new Pull Request
License
The plugin is distributed under MIT license