Class: Jamnagar::Refiners::DuplicateDetection

Inherits:
Refiner
  • Object
show all
Defined in:
lib/jamnagar/refiners/duplicate_detection.rb

Instance Method Summary collapse

Constructor Details

#initialize(detector = nil, store: nil) ⇒ DuplicateDetection

Returns a new instance of DuplicateDetection.



4
5
6
# File 'lib/jamnagar/refiners/duplicate_detection.rb', line 4

def initialize(detector=nil, store: nil)
  @detector = detector || Utilities::DuplicateDetector.new(store)
end

Instance Method Details

#refine(item) ⇒ Object



12
13
14
# File 'lib/jamnagar/refiners/duplicate_detection.rb', line 12

def refine(item)
  super item
end

#refinement_result(item) ⇒ Object



16
17
18
19
20
# File 'lib/jamnagar/refiners/duplicate_detection.rb', line 16

def refinement_result(item)
  result = @detector.detect(item["final_url"])
  return {"duplicate" => false} unless result
  {"duplicate" => true, "duplicate_of" => result["_id"]}
end

#to_sObject



8
9
10
# File 'lib/jamnagar/refiners/duplicate_detection.rb', line 8

def to_s
  "Duplicate Detection"
end