Class: Tokenizer::Custom

Inherits:
Object
  • Object
show all
Defined in:
lib/rbbt/ner/rnorm/tokens.rb

Instance Method Summary collapse

Constructor Details

#initializeCustom

Returns a new instance of Custom.



80
81
82
# File 'lib/rbbt/ner/rnorm/tokens.rb', line 80

def initialize
  @ignore_case = Tokenizer::ignore_case
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



89
90
91
92
# File 'lib/rbbt/ner/rnorm/tokens.rb', line 89

def method_missing(name, *args, &block)
  @token = name.to_sym
  @block = block
end

Instance Method Details

#eval(list1, list2) ⇒ Object



94
95
96
97
98
99
# File 'lib/rbbt/ner/rnorm/tokens.rb', line 94

def eval(list1, list2)
  toks1 = list1.select{|t| t[1] == @token}.collect{|t| @ignore_case ? t[0].to_s.downcase : t[0].to_s}
  toks2 = list2.select{|t| t[1] == @token}.collect{|t| @ignore_case ? t[0].to_s.downcase : t[0].to_s}

  @block.call(toks1, toks2)
end

#ignore_case(ignore = true) ⇒ Object



84
85
86
87
# File 'lib/rbbt/ner/rnorm/tokens.rb', line 84

def ignore_case(ignore = true)
  @ignore_case = ignore
  self
end