Package org.lionsoul.jcseg.dic
Class ADictionary
- java.lang.Object
-
- org.lionsoul.jcseg.dic.ADictionary
-
- All Implemented Interfaces:
Serializable,IDictionary
- Direct Known Subclasses:
HashMapDictionary
public abstract class ADictionary extends Object implements IDictionary, Serializable
Dictionary abstract super class- Author:
- chenxin
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.lionsoul.jcseg.IDictionary
IDictionary.Type
-
-
Field Summary
Fields Modifier and Type Field Description static StringAL_TODO_FILEthe default autoload task file nameSegmenterConfigconfigintmixPrefixLengthintmixSuffixLengthmaximum length for the Chinese words after the LATIN word or the one before it used to match Chinese and English mix word, like 'B超,AA制...' or style compose style like '卡拉ok'.booleansync-
Fields inherited from interface org.lionsoul.jcseg.IDictionary
HASHMAP
-
-
Constructor Summary
Constructors Constructor Description ADictionary(SegmenterConfig config, Boolean sync)initialize the ADictionary
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SegmenterConfiggetConfig()static intgetIndex(String key)get the key's type index located in ILexicon interfacebooleanisSync()voidload(File file)load all the words from a specified lexicon filevoidload(InputStream is)load all the words from a specified lexicon input streamvoidload(String file)load all the words from a specified lexicon pathvoidloadClassPath()load all the words from all the files under the specified class path.voidloadDirectory(String lexDir)load the all the words from all the files under a specified lexicon directorystatic voidloadWords(SegmenterConfig config, ADictionary dic, File file, List<String[]> buffer)load all the words in the specified lexicon file into the dictionarystatic voidloadWords(SegmenterConfig config, ADictionary dic, InputStream is, List<String[]> buffer)load words from a InputStreamstatic voidloadWords(SegmenterConfig config, ADictionary dic, String file, List<String[]> buffer)load all the words from a specified lexicon file pathstatic voidresetPrefixLength(SegmenterConfig config, ADictionary dic, int mixLength)check and reset the value ofmixPrefixLengthstatic voidresetSuffixLength(SegmenterConfig config, ADictionary dic, int mixLength)check and reset the value of themixSuffixLengthvoidresetSynonymsNet()1, synonyms words to synonyms entry 2, loop each synonyms word and set the IWord#synEntry 3, clear the synonyms buffervoidstartAutoload()start the lexicon autoload threadvoidstopAutoload()
-
-
-
Field Detail
-
AL_TODO_FILE
public static final String AL_TODO_FILE
the default autoload task file name- See Also:
- Constant Field Values
-
config
public final SegmenterConfig config
-
sync
public final boolean sync
-
mixSuffixLength
public volatile int mixSuffixLength
maximum length for the Chinese words after the LATIN word or the one before it used to match Chinese and English mix word, like 'B超,AA制...' or style compose style like '卡拉ok'. since 2.0.1 the value will be reset during the lexicon load process
-
mixPrefixLength
public volatile int mixPrefixLength
-
-
Constructor Detail
-
ADictionary
public ADictionary(SegmenterConfig config, Boolean sync)
initialize the ADictionary- Parameters:
config-sync-
-
-
Method Detail
-
load
public void load(File file) throws NumberFormatException, IOException
load all the words from a specified lexicon file- Parameters:
file-- Throws:
NumberFormatExceptionIOException
-
load
public void load(String file) throws NumberFormatException, IOException
load all the words from a specified lexicon path- Parameters:
file-- Throws:
NumberFormatExceptionIOException
-
load
public void load(InputStream is) throws NumberFormatException, IOException
load all the words from a specified lexicon input stream- Parameters:
is-- Throws:
NumberFormatExceptionIOException
-
loadDirectory
public void loadDirectory(String lexDir) throws IOException
load the all the words from all the files under a specified lexicon directory- Parameters:
lexDir-- Throws:
IOException
-
loadClassPath
public void loadClassPath() throws IOExceptionload all the words from all the files under the specified class path. added at 2016/07/12: only in the jar file could the ZipInputStream available add IDE classpath supported here- Throws:
IOException- Since:
- 1.9.9
-
resetSynonymsNet
public void resetSynonymsNet()
1, synonyms words to synonyms entry 2, loop each synonyms word and set the IWord#synEntry 3, clear the synonyms buffer
-
startAutoload
public void startAutoload()
start the lexicon autoload thread
-
stopAutoload
public void stopAutoload()
-
isSync
public boolean isSync()
-
getIndex
public static int getIndex(String key)
get the key's type index located in ILexicon interface- Parameters:
key-- Returns:
- int
-
getConfig
public SegmenterConfig getConfig()
-
loadWords
public static void loadWords(SegmenterConfig config, ADictionary dic, File file, List<String[]> buffer) throws NumberFormatException, IOException
load all the words in the specified lexicon file into the dictionary- Parameters:
config-dic-file-buffer-- Throws:
NumberFormatExceptionIOException
-
loadWords
public static void loadWords(SegmenterConfig config, ADictionary dic, String file, List<String[]> buffer) throws NumberFormatException, IOException
load all the words from a specified lexicon file path- Parameters:
config-dic-file-buffer-- Throws:
NumberFormatExceptionIOException
-
loadWords
public static void loadWords(SegmenterConfig config, ADictionary dic, InputStream is, List<String[]> buffer) throws NumberFormatException, IOException
load words from a InputStream- Parameters:
config-dic-is-buffer-- Throws:
NumberFormatExceptionIOException
-
resetPrefixLength
public static void resetPrefixLength(SegmenterConfig config, ADictionary dic, int mixLength)
check and reset the value ofmixPrefixLength- Parameters:
config-dic-mixLength-
-
resetSuffixLength
public static void resetSuffixLength(SegmenterConfig config, ADictionary dic, int mixLength)
check and reset the value of themixSuffixLength- Parameters:
config-dic-mixLength-
-
-