Class: RuboCop::StringUtil::JaroWinkler
- Defined in:
- lib/rubocop/string_util.rb
Overview
This class computes Jaro-Winkler distance, which adds prefix-matching bonus to Jaro distance.
Constant Summary collapse
- DEFAULT_BOOST_THRESHOLD =
Add the prefix bonus only when the Jaro distance is above this value. In other words, if the Jaro distance is less than this value, JaroWinkler.distance returns the raw Jaro distance.
0.7
- DEFAULT_SCALING_FACTOR =
How much the prefix bonus is weighted. This should not exceed 0.25.
0.1
- MAX_COMMON_PREFIX_LENGTH =
Cutoff the common prefix length to this value if it’s longer than this.
4
Instance Attribute Summary collapse
-
#boost_threshold ⇒ Object
readonly
Returns the value of attribute boost_threshold.
-
#scaling_factor ⇒ Object
readonly
Returns the value of attribute scaling_factor.
Attributes inherited from Jaro
Instance Method Summary collapse
-
#initialize(a, b, boost_threshold = nil, scaling_factor = nil) ⇒ JaroWinkler
constructor
A new instance of JaroWinkler.
Methods inherited from Jaro
Constructor Details
#initialize(a, b, boost_threshold = nil, scaling_factor = nil) ⇒ JaroWinkler
Returns a new instance of JaroWinkler.
117 118 119 120 121 |
# File 'lib/rubocop/string_util.rb', line 117 def initialize(a, b, boost_threshold = nil, scaling_factor = nil) super(a, b) @boost_threshold = boost_threshold || DEFAULT_BOOST_THRESHOLD @scaling_factor = scaling_factor || DEFAULT_SCALING_FACTOR end |
Instance Attribute Details
#boost_threshold ⇒ Object (readonly)
Returns the value of attribute boost_threshold.
115 116 117 |
# File 'lib/rubocop/string_util.rb', line 115 def boost_threshold @boost_threshold end |
#scaling_factor ⇒ Object (readonly)
Returns the value of attribute scaling_factor.
115 116 117 |
# File 'lib/rubocop/string_util.rb', line 115 def scaling_factor @scaling_factor end |