public class FuzzyStringComparator extends Object
T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Constructor and Description |
---|
FuzzyStringComparator() |
Modifier and Type | Method and Description |
---|---|
static int |
distance(String s,
String t)
Compute the Levenshtein distance of two strings.
|
static List<TextSearchResult> |
findAll(Pattern p,
String text,
boolean greedy)
Find all locations in the text that match the provided regular
expression.
|
static List<TextSearchResult> |
findAll(String regexp,
String text,
boolean greedy)
Find all locations in the text that match the provided regular
expression.
|
static List<TextSearchResult> |
findAll(String pattern,
String text,
int distance)
Search the text for all substrings matching the given pattern with a Levenshtein
distance up to the specified limit.
|
static int |
indexOf(String pattern,
String text,
int distance,
StringBuffer outBuf)
Search text for a substring with a Levenshtein distance up to the specified
limit.
|
static float |
relativeDistance(String s,
String t)
Compute relative Levenshtein distance of two strings.
|
public static int distance(String s, String t)
s
- one string.t
- another string to be compared to the first one.public static float relativeDistance(String s, String t)
s
- one string.t
- another string to be compared to the first one.public static int indexOf(String pattern, String text, int distance, StringBuffer outBuf)
pattern
- a substring to search for. Must not be null.text
- text to search. Must not be null.distance
- maximum allowed text distance (difference).outBuf
- optional output buffer to copy the matching string to.public static List<TextSearchResult> findAll(String pattern, String text, int distance)
Collections.sort(java.util.List)
on the resulting list..pattern
- a substring to search for. Must not be null.text
- text to search. Must not be null.distance
- maximum allowed text distance (difference).public static List<TextSearchResult> findAll(String regexp, String text, boolean greedy)
regexp
- a regular expression.text
- the text to search.greedy
- true will enable overlapping (one match may intersect with
another one).public static List<TextSearchResult> findAll(Pattern p, String text, boolean greedy)
p
- a regular expression.text
- the text to search.greedy
- true will enable overlapping (one match may intersect with
another one).