Module: Decompound
- Defined in:
- lib/decompound.rb,
lib/decompound/model.rb,
lib/decompound/packer.rb,
lib/decompound/railtie.rb,
lib/decompound/version.rb,
sig/decompound.rbs
Defined Under Namespace
Classes: Model, Packer, Railtie
Constant Summary collapse
- MODEL_PATH =
File.("../data/model.bin", __dir__)
- FUGEN_S_ENDINGS =
%w[ts gs ks hls ns].freeze
- VERSION =
"0.3.1"
Class Method Summary collapse
-
.eager_load! ⇒ Object
Loads the model up front instead of on the first split.
- .split(word) ⇒ Array[String]
Class Method Details
.eager_load! ⇒ Object
Loads the model up front instead of on the first split. Called by Rails on boot when config.eager_load is enabled (see Decompound::Railtie).
12 13 14 15 |
# File 'lib/decompound.rb', line 12 def self.eager_load! model nil end |
.split(word) ⇒ Array[String]
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/decompound.rb', line 17 def self.split(word) word = word.downcase if word.include?("-") left, separator, right = word.rpartition("-") return [left, right] unless separator.empty? end best = split_candidates(word).max_by { |score, left, right| [score, left, right] } best ? best.drop(1) : [word, word] end |