public class LuceneLanguageModel extends Object implements LanguageModel
| Modifier and Type | Class and Description |
|---|---|
protected static class |
LuceneLanguageModel.LuceneSearcher |
GOOGLE_SENTENCE_END, GOOGLE_SENTENCE_START| Constructor and Description |
|---|
LuceneLanguageModel(File topIndexDir) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
long |
getCount(List<String> tokens)
Get the occurrence count for the given token sequence.
|
long |
getCount(String token1)
Get the occurrence count for
token. |
long |
getCount(String token1,
String token2)
Get the occurrence count for the phrase
token1 token2. |
long |
getCount(String token1,
String token2,
String token3)
Get the occurrence count for the phrase
token1 token2 token3. |
protected LuceneLanguageModel.LuceneSearcher |
getLuceneSearcher(int ngramSize) |
long |
getTotalTokenCount() |
String |
toString() |
static void |
validateDirectory(File topIndexDir)
Throw RuntimeException is the given directory does not seem to be a valid ngram top directory
with sub directories
1grams etc. |
public LuceneLanguageModel(File topIndexDir) throws IOException
topIndexDir - a directory which contains at least another sub directory called 3grams,
which is a Lucene index with ngram occurrences as created by
org.languagetool.dev.FrequencyIndexCreator.IOExceptionpublic static void validateDirectory(File topIndexDir)
1grams etc.public long getCount(List<String> tokens)
LanguageModelgetCount in interface LanguageModelpublic long getCount(String token1)
LanguageModeltoken.getCount in interface LanguageModelpublic long getCount(String token1, String token2)
LanguageModeltoken1 token2.getCount in interface LanguageModelpublic long getCount(String token1, String token2, String token3)
LanguageModeltoken1 token2 token3.getCount in interface LanguageModelpublic long getTotalTokenCount()
getTotalTokenCount in interface LanguageModelprotected LuceneLanguageModel.LuceneSearcher getLuceneSearcher(int ngramSize)
public void close()
close in interface AutoCloseableclose in interface LanguageModel