Important
This gem is in an early stage of development. The API may change in the future.
A Ruby gem for splitting German compound words into their constituent parts, based on CharSplit.
require "decompound"
word = "Bodenbelag"
parts = Decompound.split(word)
# => ["boden", "belag"]The bundled model is trained on 127,106 German Wiktionary noun lemmas and their inflected forms, and achieves ~95% head-detection accuracy on GermaNet-derived compounds, matching CharSplit.
bundle add decompoundOr without bundler:
gem install decompound- Provide different models (small, medium, large) (?)
- Recursive decompounding
Fussbodenbelag→Fuss+Bodenbelag→Fuss+Boden+Belag
After checking out the repo, run bin/setup to install dependencies, rake test to run the tests, and bin/console for an interactive prompt.
For each release:
- Update
lib/decompound/version.rb - Run
bundle installto updateGemfile.lock - Update
CHANGELOG.md - Run tests and RBS validation
- Commit with message
Prepare x.x.x releaseand push - Run
bundle exec rake release
The training pipeline reads the German noun CSV entirely in Ruby and defaults to one observation per unique word form across all case inflections:
ruby bin/train.rb \
--input data/vendor/german-nouns/nouns.csv \
--forms all \
--output data/ngram_probs.json--forms lemmas uses only lemmas, while --forms nominative uses lemmas plus nominative inflections. Inflected forms provide the linking-element evidence (e.g. the -s in Einkaufsliste), so the bundled model uses all. The generated JSON contains CharSplit-compatible prefix, infix, and suffix probabilities.
The gem ships the probabilities as a binary table (data/model.bin), searched in place:
ruby bin/pack.rb data/ngram_probs.json data/model.binThe noun corpus used to train the bundled probabilities is derived from German Wiktionary. It is extracted by Wiktextract and distributed by Kaikki.org. Wiktionary textual content is licensed under CC BY-SA 4.0 and, where applicable, the GNU Free Documentation License. See data/vendor/german-nouns/SOURCE.md for the pinned source, extraction process, and reproducibility details.
The splitting and training algorithms are Ruby ports of CharSplit, created by Don Tuggener and described in Incremental Coreference Resolution for German (University of Zurich, 2016). CharSplit is MIT licensed; its copyright and license are reproduced in LICENSE-CharSplit.txt.
See NOTICE.md for consolidated third-party notices.
Bug reports and pull requests are welcome on GitHub at https://github.com/visini/decompound.
The gem is available as open source under the terms of the MIT License.