Module: Decompound

Defined in:
lib/decompound.rb,
lib/decompound/version.rb,
sig/decompound.rbs

Constant Summary collapse

NGRAM_PATH =
File.expand_path("../data/ngram_probs.json", __dir__)
FUGEN_S_ENDINGS =
%w[ts gs ks hls ns].freeze
VERSION =

Returns:

  • (String)
"0.2.0"

Class Method Summary collapse

Class Method Details

.split(word) ⇒ Array[String]

Parameters:

  • word (String)

Returns:

  • (Array[String])


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/decompound.rb', line 10

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