public class FuzzyScore extends Object
One point is given for every matched character. Subsequent matches yield two bonus points. A higher score indicates a higher similarity.
This code has been adapted from Apache Commons Lang 3.3.
| Constructor and Description |
|---|
FuzzyScore(Locale locale)
This returns a
Locale-specific FuzzyScore. |
| Modifier and Type | Method and Description |
|---|---|
Integer |
fuzzyScore(CharSequence term,
CharSequence query)
Find the Fuzzy Score which indicates the similarity score between two
Strings.
|
Locale |
getLocale()
Gets the locale.
|
public FuzzyScore(Locale locale)
Locale-specific FuzzyScore.locale - The string matching logic is case insensitive.
A Locale is necessary to normalize both Strings to lower case.IllegalArgumentException - This is thrown if the Locale parameter is null.public Integer fuzzyScore(CharSequence term, CharSequence query)
score.fuzzyScore(null, null) = IllegalArgumentException
score.fuzzyScore("not null", null) = IllegalArgumentException
score.fuzzyScore(null, "not null") = IllegalArgumentException
score.fuzzyScore("", "") = 0
score.fuzzyScore("Workshop", "b") = 0
score.fuzzyScore("Room", "o") = 1
score.fuzzyScore("Workshop", "w") = 1
score.fuzzyScore("Workshop", "ws") = 2
score.fuzzyScore("Workshop", "wo") = 4
score.fuzzyScore("Apache Software Foundation", "asf") = 3
term - a full term that should be matched against, must not be nullquery - the query that will be matched against a term, must not be
nullIllegalArgumentException - if the term or query is nullCopyright © 2014–2022 The Apache Software Foundation. All rights reserved.