Class: SynonymFinder
- Inherits:
-
Object
- Object
- SynonymFinder
- Defined in:
- lib/synonym-finder.rb,
lib/synonym-finder/group_organizer.rb,
lib/synonym-finder/duplicate_finder.rb
Defined Under Namespace
Classes: DuplicateFinder, GroupOrganizer
Constant Summary collapse
- NO_AUTH_INFO =
10
- PARTIAL_AUTH_INFO =
20
- AUTH_MATCH =
100
- AUTH_NO_MATCH =
0
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#matches ⇒ Object
readonly
Returns the value of attribute matches.
-
#part_matches ⇒ Object
readonly
Returns the value of attribute part_matches.
Class Method Summary collapse
- .logger ⇒ Object
- .logger=(logger) ⇒ Object
- .logger_reset ⇒ Object
- .logger_write(obj_id, message, method = :info) ⇒ Object
Instance Method Summary collapse
- #find_matches(threshold = 5) ⇒ Object
-
#initialize(input, in_memory = true) ⇒ SynonymFinder
constructor
A new instance of SynonymFinder.
Constructor Details
#initialize(input, in_memory = true) ⇒ SynonymFinder
Returns a new instance of SynonymFinder.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/synonym-finder.rb', line 34 def initialize(input, in_memory = true) @input = input @atomizer = Taxamatch::Atomizer.new @tm = Taxamatch::Base.new @stemmer = Lingua::Stemmer.new(:language => "latin") @db = init_db(in_memory) #tmp_populate build_tree unless @db.execute("select count(*) from names")[0][0].to_i > 0 @matches = {} @part_matches = {} @duplicate_finder = DuplicateFinder.new(self) @group_organizer = GroupOrganizer.new(self) end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
15 16 17 |
# File 'lib/synonym-finder.rb', line 15 def db @db end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
15 16 17 |
# File 'lib/synonym-finder.rb', line 15 def input @input end |
#matches ⇒ Object (readonly)
Returns the value of attribute matches.
15 16 17 |
# File 'lib/synonym-finder.rb', line 15 def matches @matches end |
#part_matches ⇒ Object (readonly)
Returns the value of attribute part_matches.
15 16 17 |
# File 'lib/synonym-finder.rb', line 15 def part_matches @part_matches end |
Class Method Details
.logger ⇒ Object
17 18 19 |
# File 'lib/synonym-finder.rb', line 17 def self.logger @@logger ||= Logger.new(nil) end |
.logger=(logger) ⇒ Object
21 22 23 |
# File 'lib/synonym-finder.rb', line 21 def self.logger=(logger) @@logger = logger end |
.logger_reset ⇒ Object
25 26 27 |
# File 'lib/synonym-finder.rb', line 25 def self.logger_reset self.logger = Logger.new(nil) end |
.logger_write(obj_id, message, method = :info) ⇒ Object
29 30 31 |
# File 'lib/synonym-finder.rb', line 29 def self.logger_write(obj_id, , method = :info) self.logger.send(method, "|%s|%s|" % [obj_id, ]) end |
Instance Method Details
#find_matches(threshold = 5) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/synonym-finder.rb', line 48 def find_matches(threshold = 5) @duplicate_finder.canonical_duplicates matches = @duplicate_finder.species_epithet_duplicates(threshold) matches = (matches) clean_up(matches) @group_organizer.organize end |