Pascoale
Minor utilities for text processing in Brazilian Portuguese.
I'm going to add new functions as I need them.
Currently it has:
- Pluralization and singularization (>= v0.3.0);
- Proparoxytone, paroxytone and oxytone detection (>= v0.3.0);
- Simple formatting considering accents in portuguese (upcase, downcase, capitalize);
- Title formatting, considering prepositions;
- Variations of a word at one and two edit distances (Reference: http://norvig.com/spell-correct.html);
- Heuristic syllabic separation. My tests against a corpus of ~170K words shows 99.36% correctness (improved to ~99.56% on v0.3.0).
The name of the gem is a homage to "Prof. Pasquale Cipro Neto" (http://pt.wikipedia.org/wiki/Pasquale_Cipro_Neto), a great teacher! And yes, the name of the gem is wrong spelled as a joke ^_^
Installation
Add this line to your application's Gemfile:
gem 'pascoale'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pascoale
Usage
Pluralization and singularization
*(Lowercase only)
require 'pascoale'
capt = Pascoale::Inflector.new('capitão')
puts capt.pluralize
capts = Pascoale::Inflector.new('capitães')
puts capts.singularize
captn = Pascoale::Inflector.new('capitãozinho')
puts captn.singularize
qq = Pascoale::Inflector.new('qualquer')
puts qq.singularize
Proparoxytones, Paroxytones and Oxytones
*(Lowercase only)
require 'pascoale'
diox = Pascoale::Reflector.new('dióxido')
puts diox.proparoxytone?
puts diox.paroxytone?
puts diox.oxytone?
ideia = Pascoale::Reflector.new('ideia')
puts ideia.proparoxytone?
puts ideia.paroxytone?
puts ideia.oxytone?
parati = Pascoale::Reflector.new('parati')
puts parati.proparoxytone?
puts parati.paroxytone?
puts parati.oxytone?
Text formatter
require 'pascoale'
text = Pascoale::Formatter.new('Isso é um teste de formatação')
puts text.upcase
puts text.downcase
puts text.capitalize
puts text.as_title
puts text.upcase.upcase?
puts text.upcase.downcase?
puts text.capitalize?
Variations of a word (typos and misspelling)
require 'pascoale'
edits = Pascoale::Edits.new('você')
puts edits.editions.inspect
puts edits.editions2.inspect
Syllabic separation
*(Lowercase only)
require 'pascoale'
separator = Pascoale::SyllableSeparator.new('exceção')
puts separator.separated.inspect
separator = Pascoale::SyllableSeparator.new('aéreo')
puts separator.separated.inspect
separator = Pascoale::SyllableSeparator.new('apneia')
puts separator.separated.inspect
separator = Pascoale::SyllableSeparator.new('construir')
puts separator.separated.inspect
Contributing
- Fork it ( http://github.com//pascoale/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 new Pull Request