# File lib/text/hyphen.rb, line 160
  def hyphenate(word)
    word = word.downcase
    $stderr.puts "Hyphenating #{word}" if DEBUG
    return @cache[word] if @cache.has_key?(word)
    res = @language.exceptions[word]
    return @cache[word] = make_result_list(res) if res

    result = [0] * (word.split(//).size + 1)
    rightstop = word.split(//).size - @right

    updater = Proc.new do |hash, str, pos|
      if hash.has_key?(str)
        $stderr.print "#{pos}: #{str}: #{hash[str]}" if DEBUG
        hash[str].split(//).each_with_index do |cc, ii|
          cc = cc.to_i
          result[ii + pos] = cc if cc > result[ii + pos]
        end
        $stderr.print ": #{result}\n" if DEBUG
      end
    end

      # Walk the word
    (0..rightstop).each do |pos|
      restlength = word.length - pos
      (1..restlength).each do |length|
        substr = word[pos, length]
        updater[@language.hyphen, substr, pos]
        updater[@language.start, substr, pos] if pos.zero?
        updater[@language.stop, substr, pos] if (length == restlength)
      end
    end

    updater[@language.both, word, 0] if @language.both[word]

    (0..@left).each { |i| result[i] = 0 }
    ((-1 - @right)..(-1)).each { |i| result[i] = 0 }
    @cache[word] = make_result_list(result)
  end