public class NorvigSpellingAlgorithm extends Object
Constructor and Description |
---|
NorvigSpellingAlgorithm() |
Modifier and Type | Method and Description |
---|---|
protected void |
consider(String candidate)
Consider the given candidate.
|
String |
correct(String aWord)
Try to find a correction for the given word.
|
protected List<String> |
edits(String word)
Get a list for all possible variants of the given word containing an insertion, deletion,
replacement or transposition.
|
protected String |
getBestCandidate(String word)
Try to find a correction for the given word.
|
protected boolean |
isNumber(String aWord) |
void |
reset() |
protected void |
resetScore() |
void |
train(Reader aReader)
Read words from the given reader and count their occurrences.
|
void |
train(URL aUrl,
String aEncoding)
Read words from the given URL and count their occurrences.
|
protected void resetScore()
public void reset()
public void train(Reader aReader) throws IOException
aReader
- the reader.IOException
- if the words cannot be read.public void train(URL aUrl, String aEncoding) throws IOException
aUrl
- the URL to load the words from.aEncoding
- the encoding.IOException
- if the words cannot be read.protected List<String> edits(String word)
word
- the word.public String correct(String aWord)
aWord
- the word to correct (has to be lower-case)protected boolean isNumber(String aWord)
protected String getBestCandidate(String word)
word
- the word to correct (has to be lower-case)protected void consider(String candidate)
candidate
- the candidate to consider.Copyright © 2007–2018 Ubiquitous Knowledge Processing (UKP) Lab, Technische Universität Darmstadt. All rights reserved.