public class Bitap extends Object implements Locator
The GNU Lesser General Public License for details.
Modifier and Type | Field and Description |
---|---|
private Map<Character,Integer> |
alphabet
Alphabet is the compiled representation of the pattern.
|
private static float |
balance |
private static float |
BALANCE
Tweak the relative importance (0.0 = accuracy, 1.0 = proximity)
|
private int |
loc
The location in text to focus the search.
|
private static int |
MAXBITS
The maximum number of bits in an int.
|
private static int |
maxLength |
private static int |
MAXLENGTH |
private static int |
minLength |
private static int |
MINLENGTH
The min and max cutoffs used when computing text lengths.
|
private String |
pattern
The pattern to find in the text.
|
private int |
scoreTextLength
The length of the string constrained between MINLENGHT and MAXLENGTH
|
private String |
text
The text to search.
|
private static float |
threshold |
private static float |
THRESHOLD
At what point is no match declared (0.0 = perfection, 1.0 = very loose)
|
Constructor and Description |
---|
Bitap(String text,
String pattern,
int loc)
Locate the best instance of 'pattern' in 'text' near 'loc'.
|
Modifier and Type | Method and Description |
---|---|
protected void |
alphabet() |
private double |
bitapScore(int e,
int x)
Compute and return the score for a match with e errors and x location.
|
protected Map<Character,Integer> |
getAlphabet() |
int |
locate()
Locate the best match of a pattern in text near a supplied location.
|
int |
maxPatternLength()
The maximum length a pattern can be.
|
static void |
setBalance(float newBalance) |
static void |
setMaxLength(int newMaxLength) |
static void |
setMinLength(int newMinLength) |
static void |
setThreshold(float newThreshold) |
private static final int MAXBITS
private static final float BALANCE
private static float balance
private static final float THRESHOLD
private static float threshold
private static final int MINLENGTH
private static int minLength
private static final int MAXLENGTH
private static int maxLength
private String text
private String pattern
private int loc
private int scoreTextLength
public int maxPatternLength()
Locator
maxPatternLength
in interface Locator
public int locate()
Locator
private double bitapScore(int e, int x)
e
- Number of errors in matchx
- Location of matchprotected void alphabet()
public static void setBalance(float newBalance)
public static void setThreshold(float newThreshold)
public static void setMinLength(int newMinLength)
public static void setMaxLength(int newMaxLength)