Class: FuzzyMatch::Rule::Grouping
- Inherits:
-
FuzzyMatch::Rule
- Object
- FuzzyMatch::Rule
- FuzzyMatch::Rule::Grouping
- Defined in:
- lib/fuzzy_match/rule/grouping.rb
Overview
“Record linkage typically involves two main steps: grouping and scoring…” en.wikipedia.org/wiki/Record_linkage
Groupings effectively divide up the haystack into groups that match a pattern
A grouping (formerly known as a blocking) comes into effect when a str matches. Then the needle must also match the grouping’s regexp.
Instance Attribute Summary
Attributes inherited from FuzzyMatch::Rule
Instance Method Summary collapse
-
#join?(str1, str2) ⇒ Boolean
If a grouping “joins” two strings, that means they both fit into it.
- #match?(str) ⇒ Boolean
Methods inherited from FuzzyMatch::Rule
Constructor Details
This class inherits a constructor from FuzzyMatch::Rule
Instance Method Details
#join?(str1, str2) ⇒ Boolean
If a grouping “joins” two strings, that means they both fit into it.
Returns false if they certainly don’t fit this grouping. Returns nil if the grouping doesn’t apply, i.e. str2 doesn’t fit the grouping.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fuzzy_match/rule/grouping.rb', line 19 def join?(str1, str2) if str2_match_data = regexp.match(str2) if str1_match_data = regexp.match(str1) str2_match_data.captures.join.downcase == str1_match_data.captures.join.downcase else false end else nil end end |
#match?(str) ⇒ Boolean
11 12 13 |
# File 'lib/fuzzy_match/rule/grouping.rb', line 11 def match?(str) !!(regexp.match(str)) end |