Method: Epos::Dictionary#initialize

Defined in:
lib/epos/dictionary.rb

#initialize(path) ⇒ Dictionary

Returns a new instance of Dictionary.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/epos/dictionary.rb', line 9

def initialize(path)
  @idf1 = Epos::IndexedDataFile.new(File.join(path, "deah002.dhn"), File.join(path, "deah001.dhn"))
  @idf2 = Epos::IndexedDataFile.new(File.join(path, "deah008.dhn"), File.join(path, "deah007.dhn"))

  @fmt1 = Epos::HtmlFormatter.new(unmarked: false)
  @fmt2 = Epos::HtmlFormatter.new(unmarked: true)

  @entry_parser = Epos::EntryParser.new

  @fuzzy = {}

  (@idf1.keys + @idf2.keys).each do |key|
    simple = simplify(key)
    if @fuzzy.has_key?(simple)
      @fuzzy[simple] << key
    else
      @fuzzy[simple] = [key]
    end
  end

  @fuzzy.each_value do |value|
    value.sort!.uniq!
  end
end