Class: Multext
- Inherits:
-
Object
- Object
- Multext
- Defined in:
- lib/multext.rb
Defined Under Namespace
Classes: MSD
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#language ⇒ Object
Returns the value of attribute language.
-
#msd ⇒ Object
Returns the value of attribute msd.
Class Method Summary collapse
Instance Method Summary collapse
- #forms(lemma) ⇒ Object
-
#initialize(language = :en) ⇒ Multext
constructor
A new instance of Multext.
- #lemma(word_form) ⇒ Object
Constructor Details
#initialize(language = :en) ⇒ Multext
Returns a new instance of Multext.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/multext.rb', line 7 def initialize(language=:en) @data = [] @language = language @msd = Multext::MSD.new basedir = "#{ENV['HOME']}/multext" filename = "wfl-#{language}.txt" File.foreach(File.join(basedir, filename)) do |line| word_form, lemma, info = line.split(' ') info = msd.parse(info, language) data << { word_form: word_form, lemma: lemma, info: info } end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
2 3 4 |
# File 'lib/multext.rb', line 2 def data @data end |
#language ⇒ Object
Returns the value of attribute language.
2 3 4 |
# File 'lib/multext.rb', line 2 def language @language end |
#msd ⇒ Object
Returns the value of attribute msd.
2 3 4 |
# File 'lib/multext.rb', line 2 def msd @msd end |
Class Method Details
.install ⇒ Object
4 5 |
# File 'lib/multext.rb', line 4 def self.install end |
Instance Method Details
#forms(lemma) ⇒ Object
35 36 37 38 39 |
# File 'lib/multext.rb', line 35 def forms(lemma) @data.find_all do |ele| ele[:lemma] == lemma end end |
#lemma(word_form) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/multext.rb', line 27 def lemma(word_form) @data.each do |ele| return ele[:lemma] if ele[:word_form] == word_form end return nil end |