|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.crosswire.common.diff.Bitap
public class Bitap
An implementation of the Bitap algorithm for finding a "fuzzy" location of a
match.
Based on the LGPL Diff_Match_Patch v1.5 javascript of Neil Fraser, Copyright (C) 2006
http://neil.fraser.name/software/diff_match_patch/
The GNU Lesser General Public License for details.
Field Summary | |
---|---|
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 Summary | |
---|---|
Bitap(String text,
String pattern,
int loc)
Locate the best instance of 'pattern' in 'text' near 'loc'. |
Method Summary | |
---|---|
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)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
private Map<Character,Integer> alphabet
Constructor Detail |
---|
public Bitap(String text, String pattern, int loc)
text
- The text to searchpattern
- The pattern to search forloc
- The location to search aroundMethod Detail |
---|
public int maxPatternLength()
Locator
maxPatternLength
in interface Locator
public int locate()
Locator
locate
in interface Locator
protected Map<Character,Integer> getAlphabet()
private double bitapScore(int e, int x)
e
- Number of errors in matchx
- Location of match
protected 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)
|
Copyright ยจ 2003-2015 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |