Class: Linkage::ResultSet Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/linkage/result_set.rb

Overview

This class is abstract.

A ResultSet contains a ScoreSet and a MatchSet. To understand the purpose of a ResultSet, it helps to understand the recording process first.

During a record linkage, one or more Comparators generate scores. Each score is recorded by a ScoreRecorder, which uses a ScoreSet to actually save the score. After the scoring is complete, a Matcher combines the scores to create matches. Each match is recorded by a MatchRecorder, which uses a MatchSet to actually save the match information.

So to save scores and matches, we need both a ScoreSet and a MatchSet. To make this easier, a ResultSet configures both.

ResultSet is the superclass of implementations for different formats. Currently there are two formats for storing scores and matches:

See the documentation for result set you're interested in for more information.

If you want to implement a custom ResultSet, create a class that inherits ResultSet and defines both #score_set that returns a ScoreSet and #match_set that returns a MatchSet. You can then register that class via ResultSet.register.

Direct Known Subclasses

Linkage::ResultSets::CSV, Linkage::ResultSets::Database

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Class?) klass_for(name) Also known as: []

Return a registered ResultSet subclass or nil if it doesn't exist.

Parameters:

  • name (String)

    of registered result set

Returns:

  • (Class, nil)


59
60
61
# File 'lib/linkage/result_set.rb', line 59

def klass_for(name)
  @result_set ? @result_set[name] : nil
end

+ (Object) register(name, klass)

Register a new result set. Subclasses must define #score_set and #match_set. Otherwise, an ArgumentError will be raised when you try to call register.

Parameters:

  • name (String)

    Result set name used in klass_for

  • klass (Class)

    ResultSet subclass



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/linkage/result_set.rb', line 38

def register(name, klass)
  methods = klass.instance_methods(false)
  missing = []
  unless methods.include?(:score_set)
    missing.push("#score_set")
  end
  unless methods.include?(:match_set)
    missing.push("#match_set")
  end
  unless missing.empty?
    raise ArgumentError, "class must define #{missing.join(" and ")}"
  end

  @result_set ||= {}
  @result_set[name] = klass
end

Instance Method Details

- (MatchSet) match_set

This method is abstract.

Returns a MatchSet. Subclasses must define this method.

Returns:

Raises:

  • (NotImplementedError)


77
78
79
# File 'lib/linkage/result_set.rb', line 77

def match_set
  raise NotImplementedError
end

- (ScoreSet) score_set

This method is abstract.

Returns a ScoreSet. Subclasses must define this method.

Returns:

Raises:

  • (NotImplementedError)


69
70
71
# File 'lib/linkage/result_set.rb', line 69

def score_set
  raise NotImplementedError
end