Sha256: 882492e3c999814e29d0dbaa8bafdb6327a51bd891f5c8a996bc8434c9522fc1
Contents?: true
Size: 1007 Bytes
Versions: 1
Compression:
Stored size: 1007 Bytes
Contents
module Nabatheon class Rule PERSON = 'PERSON' ORG = 'ORGANIZATION' def self.apply_on(*args) self.new.apply_on(*args) end def apply_on(named_entities) searches = [] previous = Entity.new(nil, nil) named_entities.map do |entity_arr| entity = Entity.new(entity_arr[:named_entity], entity_arr[:type]) if rule_of_two?(entity.type, previous.type) searches.last.value = "#{searches.last.value} #{entity.value}" else searches << Search.new(entity.type, entity.value) end previous = entity end searches end # * (2 persons || 2 orgs) in a row => #contact def rule_of_two?(type, previous_type) # FIXME: Does not return correct value if if the types are: # type = PERSON && previous[:type] = ORG # # => returns true (type == PERSON || type == ORG) && \ (previous_type == PERSON || previous_type == ORG) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nabatheon-0.0.3 | lib/nabatheon/rule.rb |