Class: Finder::Instance
- Inherits:
-
Object
- Object
- Finder::Instance
- Defined in:
- lib/rbbt/ner/finder.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#normalizer ⇒ Object
Returns the value of attribute normalizer.
Instance Method Summary collapse
- #find(name) ⇒ Object
-
#initialize(path, open_options = {}) ⇒ Instance
constructor
A new instance of Instance.
Constructor Details
#initialize(path, open_options = {}) ⇒ Instance
Returns a new instance of Instance.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rbbt/ner/finder.rb', line 18 def initialize(path, = {}) case path when TSV @namespace = path.namespace @format = path.key_field @normalizer = Normalizer.new(path) when Hash @namespace = [:namespace] @format = nil @normalizer = RegExpNER.new(path) else = Misc.add_defaults , :type => :flat tsv = TSV.open(path, ) @namespace = tsv.namespace @format = tsv.key_field @normalizer = Normalizer.new(tsv) end end |
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format.
17 18 19 |
# File 'lib/rbbt/ner/finder.rb', line 17 def format @format end |
#namespace ⇒ Object
Returns the value of attribute namespace.
17 18 19 |
# File 'lib/rbbt/ner/finder.rb', line 17 def namespace @namespace end |
#normalizer ⇒ Object
Returns the value of attribute normalizer.
17 18 19 |
# File 'lib/rbbt/ner/finder.rb', line 17 def normalizer @normalizer end |
Instance Method Details
#find(name) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rbbt/ner/finder.rb', line 37 def find(name) candidates = @normalizer.match(name) if defined? Finder::Match candidates.collect{|c| Finder::Match.setup(c.dup, @format, @namespace, @normalizer.token_score(c, name)) } else candidates end end |