Class: RussianWordForms::Rules
- Inherits:
-
Object
- Object
- RussianWordForms::Rules
- Defined in:
- lib/russian_word_forms/rules.rb
Constant Summary collapse
- @@rules =
Hash.new {|h,k| h[k]=Hash.new {|h2,k2| h2[k2]=[]}}
Instance Method Summary collapse
-
#initialize ⇒ Rules
constructor
A new instance of Rules.
- #load_file(file) ⇒ Object
- #load_rules ⇒ Object
- #rules ⇒ Object
Constructor Details
#initialize ⇒ Rules
Returns a new instance of Rules.
5 6 7 |
# File 'lib/russian_word_forms/rules.rb', line 5 def initialize load_rules end |
Instance Method Details
#load_file(file) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/russian_word_forms/rules.rb', line 8 def load_file(file) flag="" File.readlines(file).each do |line| command=line.chomp.split('#')[0] # get rid of comments if command&&command!="" command=command.split(" ") if command.count==2 # case command[0] when "flag" flag=command[1][1..-2] end elsif command.count>2 # command rule=command.join.split(">") @@rules[flag][rule[0]]<<rule[1] end end end end |
#load_rules ⇒ Object
28 29 30 31 32 33 |
# File 'lib/russian_word_forms/rules.rb', line 28 def load_rules files=Dir[File.dirname(__FILE__)+"/dictionaries/*.aff"] files.each do |file| load_file file end end |
#rules ⇒ Object
35 36 37 |
# File 'lib/russian_word_forms/rules.rb', line 35 def rules @@rules end |