Class: RussianWordForms::Dictionary
- Inherits:
-
Object
- Object
- RussianWordForms::Dictionary
- Defined in:
- lib/russian_word_forms/dictionary.rb
Instance Attribute Summary collapse
-
#dictionary ⇒ Object
Returns the value of attribute dictionary.
Instance Method Summary collapse
- #get_flags(word) ⇒ Object
-
#initialize ⇒ Dictionary
constructor
A new instance of Dictionary.
- #load_dictionaries ⇒ Object
- #load_dictionary(file) ⇒ Object
Constructor Details
#initialize ⇒ Dictionary
Returns a new instance of Dictionary.
8 9 10 11 |
# File 'lib/russian_word_forms/dictionary.rb', line 8 def initialize @dictionary = Hash.new load_dictionaries end |
Instance Attribute Details
#dictionary ⇒ Object
Returns the value of attribute dictionary.
6 7 8 |
# File 'lib/russian_word_forms/dictionary.rb', line 6 def dictionary @dictionary end |
Instance Method Details
#get_flags(word) ⇒ Object
29 30 31 |
# File 'lib/russian_word_forms/dictionary.rb', line 29 def get_flags(word) @dictionary[word] end |
#load_dictionaries ⇒ Object
22 23 24 25 26 27 |
# File 'lib/russian_word_forms/dictionary.rb', line 22 def load_dictionaries files = Dir[File.dirname(__FILE__)+"/dictionaries/*.dic"] files.each do |file| load_dictionary file end end |
#load_dictionary(file) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/russian_word_forms/dictionary.rb', line 13 def load_dictionary(file) File.readlines(file).each do |line| stem,flags = line.chomp.split('/') stem = Unicode::upcase stem stem.gsub!("Ё","Е") @dictionary[stem]=flags end end |