Libexttextcat RubyGem
This is a natural language detection library for Ruby.
This gem is a CRuby binding for the libexttextcat library.
Installation
Install the gem and add to the application's Gemfile by executing:
bundle add libexttextcat
If bundler is not being used to manage dependencies, install the gem by executing:
gem install libexttextcat
Usage
CONF_DIR = '/usr/local/share/libexttextcat'
CONF_FILE = File.join(CONF_DIR, "fpdb.conf.dist")
SOURCE = "吾輩は猫である。名前はまだ無い。"
Dir.chdir(CONF_DIR) do
classifier = Libexttextcat::Classifier.new(CONF_FILE)
classifier.classify(SOURCE) #=> "[ja--utf8]"
candidates = classifier.classify_full(SOURCE)
candidate = candidates[0]
candidate.score #=> 26443
candidate.name #=> "ja--utf8"
end
Please also refer to the API documentation.
Development
After checking out the repo, run bin/setup to install
dependencies. Then, run rake test to run the tests. You can also run
bin/console for an interactive prompt that will allow you to
experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in
version.rb, and then run bundle exec rake release, which will
create a git tag for the version, push git commits and the created
tag, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on Codeberg.
License
Copyright (C) 2026 gemmaro
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.