|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Observable
de.folt.fuzzy.FuzzyNodeKey
public class FuzzyNodeKey
Basically a FuzzyNodeKey is an array of shorts of length maxFuzzyKeyLength. This array represents a point in an n-dimensional space (dimension = maxFuzzyKeyLength de.folt.fuzzy.FuzzyNodeKey#setMaxFuzzyKeyLength(int)).
The key is used by the FuzzyNode search algorithm search (and addFuzzyNode) to search FuzzyNode.search(FuzzyNode, int) resp. insert FuzzyNode FuzzyNode.insertFuzzyNode(FuzzyNode) (for more details: FuzzyNode).
A specific method is available for generating a key from a String FuzzyNodeKey(String) . FuzzyNodeKey(String string) and its versions FuzzyNodeKey(String, int) and FuzzyNodeKey(String, int, int) generate a FuzzyNodeKey based on n grams.
| Constructor Summary | |
|---|---|
FuzzyNodeKey(short[] key)
Generate a FuzzyNodeKey based on a short array. |
|
FuzzyNodeKey(java.lang.String string)
FuzzyNodeKey generates a FuzzyNodeKey for a string. |
|
FuzzyNodeKey(java.lang.String string,
int nGram)
FuzzyNodeKey generates a FuzzyNodeKey for a string. |
|
FuzzyNodeKey(java.lang.String string,
int nGrams,
int maxfuzzy)
FuzzyNodeKey generates a FuzzyNodeKey for a string. |
|
| Method Summary | |
|---|---|
int |
computeKeyDistance(FuzzyNodeKey fuzzyNodeKey)
computeKeyDistance computes the distance between the two fuzzy node keys. |
int |
computeKeySum()
computeKeySum computes the sum of the key elements (counters for a specific ngram) for (int i = 0; i < this.key.length; i++) { isum += (int) key[i]; } |
int |
computeKeySumTillLevel(int level)
computeKeySumTillLevel computes the keysum till the level of the key node |
java.lang.String |
format()
format produces a string which represents the key elements in a string separated by "," Example: 4, [3,0,1,5] |
static long |
getDefaultFuzzyBaseCharNumber()
|
static int |
getDefaultFuzzyKeyLength()
|
long |
getFuzzyBaseCharNumber()
|
int |
getFuzzyKeyLength()
|
short[] |
getKey()
|
int |
getKeysum()
return the sum of the keys. |
int |
getNGrams()
|
static void |
setDefaultFuzzyBaseCharNumber(long defaultFuzzyBaseCharNumber)
|
static void |
setDefaultFuzzyKeyLength(int defaultFuzzyKeyLength)
|
void |
setFuzzyBaseCharNumber(long fuzzybase_charnum)
|
void |
setFuzzyKeyLength(int maxFuzzyKeyLength)
This sets the length of the FuzzyKey. |
void |
setKey(short[] key)
|
void |
setKeysum(int keysum)
|
void |
setNGrams(int grams)
|
| Methods inherited from class java.util.Observable |
|---|
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FuzzyNodeKey(short[] key)
computeKeySum()
key - the key for the fuzzy node key to generate the array representing a key (n-dimensional space)public FuzzyNodeKey(java.lang.String string)
key - the string from which the key should be generated (using 3 for nGram and maxFuzzyKeyLength) this is a short array
public FuzzyNodeKey(java.lang.String string,
int nGram)
string - the string from which the key should be generated - based on nGramsnGram - nGrams the length of an nGram
public FuzzyNodeKey(java.lang.String string,
int nGrams,
int maxfuzzy)
for (i = 0; i < k - nGrams + 1; i++)
{ // loop over all chars until the last n
lNum = 0;
for (j = 0; j < nGrams; j++)
{
// sum up the n gram values
// if we have n chars to sum up
// Example: FUZZYBASE_CHARNUM = 10, 3Grams
// Value of the trigram "abc" = a*10*10 + b*10 + c = 61*100 + 62*10 + 63 = 6783
lNum = lNum * (long) FUZZYBASE_CHARNUM + (long) string.charAt(i + j);
}
// Position for Example: maxfuzzy = 48: 6783%48 = 15
lNum = lNum % ((long) (maxfuzzy - 1)); // position of the nGram in the key - increment +1
// Example: we increment now element 15 of key +1
key[(int) lNum]++;
}
The method computes the key sum using @see computeKeySum()
string - the string from which the key should be generated - based on nGramsnGrams - the length of an nGrammaxfuzzy - the length of the fuzzy key to generate| Method Detail |
|---|
public static long getDefaultFuzzyBaseCharNumber()
public static int getDefaultFuzzyKeyLength()
public static void setDefaultFuzzyBaseCharNumber(long defaultFuzzyBaseCharNumber)
defaultFuzzyBaseCharNumber - the defaultFuzzyBaseCharNumber to setpublic static void setDefaultFuzzyKeyLength(int defaultFuzzyKeyLength)
defaultFuzzyKeyLength - the defaultFuzzyKeyLength to setpublic int computeKeyDistance(FuzzyNodeKey fuzzyNodeKey)
distance = distance + Math.abs((int)fuzzyNodeKey.key[i] - (int)this.key[i]);<br> distance = distance / 2;
fuzzyNodeKey -
public int computeKeySum()
for (int i = 0; i < this.key.length; i++)
{
isum += (int) key[i];
}
public int computeKeySumTillLevel(int level)
level - the level for the node
public java.lang.String format()
4, [3,0,1,5]
public long getFuzzyBaseCharNumber()
public int getFuzzyKeyLength()
public short[] getKey()
public int getKeysum()
public int getNGrams()
public void setFuzzyBaseCharNumber(long fuzzybase_charnum)
fuzzybase_charnum - the fUZZYBASE_CHARNUM to setpublic void setFuzzyKeyLength(int maxFuzzyKeyLength)
maxFuzzyKeyLength - the maxFuzzyKeyLength to setpublic void setKey(short[] key)
key - the key to setpublic void setKeysum(int keysum)
keysum - the kEYSUM to setpublic void setNGrams(int grams)
grams - the nGrams to set
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||