public class SoftDictionary extends Object
SoftDictionary softDict = new SoftDictionary(new SimpleTokenizer(true,true));
String alias[] = new String[]{"william cohen", "wwcohen", "einat minkov", "eminkov", .... };
for (int i=0; i| Constructor and Description |
|---|
SoftDictionary() |
SoftDictionary(StringDistanceLearner distanceLearner) |
SoftDictionary(StringDistanceLearner distanceLearner,
Tokenizer tokenizer) |
SoftDictionary(Tokenizer tokenizer) |
| Modifier and Type | Method and Description |
|---|---|
StringDistanceTeacher |
getTeacher()
Return a teacher that can 'train' a distance metric
from the information in the dictionary.
|
void |
load(File file)
Insert all lines in a file as items mapping to themselves.
|
void |
load(File file,
boolean ids)
Insert all lines in a file as items mapping to themselves.
|
void |
loadAliases(File file)
Load a file of identifiers, each of which has multiple
aliases.
|
Object |
lookup(String toFind)
Lookup a string in the dictionary.
|
Object |
lookup(String id,
String toFind)
Lookup a string in the dictionary.
|
Object |
lookup(String id,
StringWrapper toFind)
Lookup a prepared string in the dictionary.
|
Object |
lookup(StringWrapper toFind)
Lookup a prepared string in the dictionary.
|
double |
lookupDistance(String toFind)
Return the distance to the best match.
|
double |
lookupDistance(String id,
String toFind)
Return the distance to the best match.
|
double |
lookupDistance(String id,
StringWrapper toFind)
Return the distance to the best match.
|
double |
lookupDistance(StringWrapper toFind)
Return the distance to the best match.
|
static void |
main(String[] argv)
Simple main for testing.
|
StringWrapper |
prepare(String s)
Prepare a string for quicker lookup.
|
void |
put(String string,
Object value)
Insert a string into the dictionary.
|
void |
put(String id,
String string,
Object value)
Insert a string into the dictionary.
|
void |
put(String id,
StringWrapper toInsert,
Object value)
Insert a prepared string into the dictionary.
|
int |
size()
Return the number of entries in the dictionary.
|
public SoftDictionary()
public SoftDictionary(StringDistanceLearner distanceLearner)
public SoftDictionary(Tokenizer tokenizer)
public SoftDictionary(StringDistanceLearner distanceLearner, Tokenizer tokenizer)
public int size()
public StringWrapper prepare(String s)
public void load(File file) throws IOException, FileNotFoundException
IOExceptionFileNotFoundExceptionpublic void load(File file, boolean ids) throws IOException, FileNotFoundException
This is mostly for testing the id feature.
IOExceptionFileNotFoundExceptionpublic void loadAliases(File file) throws IOException, FileNotFoundException
IOExceptionFileNotFoundExceptionpublic void put(String id, String string, Object value)
Id is a special tag used to handle 'leave one out' lookups. If you do a lookup on a string with a non-null id, you get the closest matches that do not have the same id.
public void put(String id, StringWrapper toInsert, Object value)
Id is a special tag used to handle 'leave one out' lookups. If you do a lookup on a string with a non-null id, you get the closest matches that do not have the same id.
public Object lookup(String id, String toFind)
If id is non-null, then consider only strings with different ids (or null ids).
public Object lookup(String id, StringWrapper toFind)
If id is non-null, then consider only strings with different ids (or null ids).
public double lookupDistance(String id, String toFind)
If id is non-null, then consider only strings with different ids (or null ids).
public double lookupDistance(String id, StringWrapper toFind)
If id is non-null, then consider only strings with different ids (or null ids).
public Object lookup(StringWrapper toFind)
public double lookupDistance(String toFind)
public double lookupDistance(StringWrapper toFind)
public StringDistanceTeacher getTeacher()
public static void main(String[] argv) throws IOException, FileNotFoundException
IOExceptionFileNotFoundExceptionCopyright © 2016. All rights reserved.