Class BigramDictionary
- java.lang.Object
-
- org.apache.lucene.analysis.cn.smart.hhmm.AbstractDictionary
-
- org.apache.lucene.analysis.cn.smart.hhmm.BigramDictionary
-
class BigramDictionary extends AbstractDictionary
SmartChineseAnalyzer Bigram dictionary.
-
-
Field Summary
Fields Modifier and Type Field Description private long[]
bigramHashTable
private int[]
frequencyTable
private int
max
static int
PRIME_BIGRAM_LENGTH
private int
repeat
private static BigramDictionary
singleInstance
static char
WORD_SEGMENT_CHAR
-
Fields inherited from class org.apache.lucene.analysis.cn.smart.hhmm.AbstractDictionary
CHAR_NUM_IN_FILE, GB2312_CHAR_NUM, GB2312_FIRST_CHAR
-
-
Constructor Summary
Constructors Modifier Constructor Description private
BigramDictionary()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
getAvaliableIndex(long hashId, char[] carray)
private int
getBigramItemIndex(char[] carray)
int
getFrequency(char[] carray)
static BigramDictionary
getInstance()
private void
load()
private void
load(java.lang.String dictRoot)
void
loadFromFile(java.lang.String dctFilePath)
Load the datafile into this BigramDictionaryprivate void
loadFromInputStream(java.io.InputStream serialObjectInputStream)
private boolean
loadFromObj(java.nio.file.Path serialObj)
private void
saveToObj(java.nio.file.Path serialObj)
-
Methods inherited from class org.apache.lucene.analysis.cn.smart.hhmm.AbstractDictionary
getCCByGB2312Id, getGB2312Id, hash1, hash1, hash2, hash2
-
-
-
-
Field Detail
-
WORD_SEGMENT_CHAR
public static final char WORD_SEGMENT_CHAR
- See Also:
- Constant Field Values
-
singleInstance
private static BigramDictionary singleInstance
-
PRIME_BIGRAM_LENGTH
public static final int PRIME_BIGRAM_LENGTH
- See Also:
- Constant Field Values
-
bigramHashTable
private long[] bigramHashTable
-
frequencyTable
private int[] frequencyTable
-
max
private int max
-
repeat
private int repeat
-
-
Method Detail
-
getInstance
public static BigramDictionary getInstance()
-
loadFromObj
private boolean loadFromObj(java.nio.file.Path serialObj)
-
loadFromInputStream
private void loadFromInputStream(java.io.InputStream serialObjectInputStream) throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
saveToObj
private void saveToObj(java.nio.file.Path serialObj) throws java.io.IOException
- Throws:
java.io.IOException
-
load
private void load() throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
load
private void load(java.lang.String dictRoot) throws java.io.IOException
- Throws:
java.io.IOException
-
loadFromFile
public void loadFromFile(java.lang.String dctFilePath) throws java.io.IOException
Load the datafile into this BigramDictionary- Parameters:
dctFilePath
- path to the Bigramdictionary (bigramdict.dct)- Throws:
java.io.IOException
- If there is a low-level I/O error
-
getAvaliableIndex
private int getAvaliableIndex(long hashId, char[] carray)
-
getBigramItemIndex
private int getBigramItemIndex(char[] carray)
-
getFrequency
public int getFrequency(char[] carray)
-
-