class Taxamatch::Authmatch
Public Class Methods
authmatch(authors1, authors2, years1, years2)
click to toggle source
# File lib/taxamatch_rb/authmatch.rb, line 7 def self.authmatch(authors1, authors2, years1, years2) unique_authors1, unique_authors2 = remove_duplicate_authors(authors1, authors2) year_difference = compare_years(years1, years2) get_score(authors1, unique_authors1, authors2, unique_authors2, year_difference) end
compare_years(years1, years2)
click to toggle source
# File lib/taxamatch_rb/authmatch.rb, line 94 def self.compare_years(years1, years2) return 0 if years1 == [] && years2 == [] if years1.size == 1 && years2.size == 1 return (years1[0].to_i - years2[0].to_i).abs end nil end
get_score(authors1, unique_authors1, authors2, unique_authors2, year_diff)
click to toggle source
# File lib/taxamatch_rb/authmatch.rb, line 15 def self.get_score(authors1, unique_authors1, authors2, unique_authors2, year_diff) count_before = authors1.size + authors2.size count_after = unique_authors1.size + unique_authors2.size score = 0 if count_after == 0 if year_diff != nil if year_diff == 0 score = 100 elsif year_diff == 1 score = 54 end else score = 94 end elsif unique_authors1.size == 0 || unique_authors2.size == 0 if year_diff != nil if year_diff == 0 score = 91 elsif year_diff == 1 score = 51 end else score = 90 end else score = ((1 - count_after.to_f/count_before.to_f) * 100).round score = 0 unless year_diff == nil || (year_diff && year_diff == 0) end score > 50 ? score : 0 end