Class: SynonymFinder

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#dbObject (readonly)

Returns the value of attribute db.



15
16
17
# File 'lib/synonym-finder.rb', line 15

def db
  @db
end

#inputObject (readonly)

Returns the value of attribute input.



15
16
17
# File 'lib/synonym-finder.rb', line 15

def input
  @input
end

#matchesObject (readonly)

Returns the value of attribute matches.



15
16
17
# File 'lib/synonym-finder.rb', line 15

def matches
  @matches
end

#part_matchesObject (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

.loggerObject



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_resetObject



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, message, method = :info)
  self.logger.send(method, "|%s|%s|" % [obj_id, message])
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 = compare_authorship(matches)
  clean_up(matches)
  @group_organizer.organize
end