Class: Morphy::Morphy

Inherits:
Object
  • Object
show all
Defined in:
lib/morphy.rb

Instance Method Summary collapse

Constructor Details

#initializeMorphy

Returns a new instance of Morphy.



8
9
10
# File 'lib/morphy.rb', line 8

def initialize
  @dawg = Dawg.load("#{::Morphy.path}/dawg.bin")
end

Instance Method Details

#query(word) ⇒ Object



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

def query(word)
  results = @dawg.query(word)
  results = results.map do |result|
    result = result.to_s
    word, para_id, index = result.split(' ')
    Word.new(word, para_id, index)
  end
  results
end

#to_sObject



22
23
24
# File 'lib/morphy.rb', line 22

def to_s
  "Morphy"
end