public abstract class ADictionary extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
AL_TODO_FILE
the default auto load task file name
|
protected JcsegTaskConfig |
config |
int |
mixPrefixLength |
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'.
|
protected boolean |
sync |
| Constructor and Description |
|---|
ADictionary(JcsegTaskConfig config,
Boolean sync)
initialize the ADictionary
|
| Modifier and Type | Method and Description |
|---|---|
abstract IWord |
add(int t,
IWord word)
directly add a IWord item to the dictionary
|
abstract IWord |
add(int t,
String key,
int type)
add a new word to the dictionary
|
abstract IWord |
add(int t,
String key,
int fre,
int type)
add a new word to the dictionary
|
abstract IWord |
add(int t,
String key,
int fre,
int type,
String entity)
add a new word to the dictionary with its statistics frequency
|
abstract IWord |
add(int t,
String key,
int type,
String entity)
add a new word to the dictionary
|
abstract IWord |
get(int t,
String key)
return the IWord associate with the given key.
|
JcsegTaskConfig |
getConfig() |
static int |
getIndex(String key)
get the key's type index located in ILexicon interface
|
boolean |
isSync() |
void |
load(File file)
load all the words from a specified lexicon file
|
void |
load(InputStream is)
load all the words from a specified lexicon input stream
|
void |
load(String file)
load all the words from a specified lexicon path
|
void |
loadClassPath()
load all the words from all the files under the specified class path.
|
void |
loadDirectory(String lexDir)
load the all the words form all the files under a specified lexicon directory
|
static void |
loadWords(JcsegTaskConfig config,
ADictionary dic,
File file)
load all the words in the specified lexicon file into the dictionary
|
static void |
loadWords(JcsegTaskConfig config,
ADictionary dic,
InputStream is)
load words from a InputStream
|
static void |
loadWords(JcsegTaskConfig config,
ADictionary dic,
String file)
load all the words from a specified lexicon file path
|
abstract boolean |
match(int t,
String key)
loop up the dictionary, check the given key is in the dictionary or not
|
abstract void |
remove(int t,
String key)
remove the mapping associate with the given key
|
static boolean |
resetPrefixLength(JcsegTaskConfig config,
ADictionary dic,
int mixLength)
check and reset the value of
mixPrefixLength |
static boolean |
resetSuffixLength(JcsegTaskConfig config,
ADictionary dic,
int mixLength)
check and reset the value of the
mixSuffixLength |
void |
setConfig(JcsegTaskConfig config) |
abstract int |
size(int t)
return the size of the dictionary
|
void |
startAutoload()
start the lexicon autoload thread
|
void |
stopAutoload() |
public static final String AL_TODO_FILE
protected JcsegTaskConfig config
protected boolean sync
public volatile int mixSuffixLength
public volatile int mixPrefixLength
public ADictionary(JcsegTaskConfig config, Boolean sync)
config - sync - public void load(File file) throws NumberFormatException, FileNotFoundException, IOException
file - IOExceptionFileNotFoundExceptionNumberFormatExceptionpublic void load(String file) throws NumberFormatException, FileNotFoundException, IOException
file - IOExceptionFileNotFoundExceptionNumberFormatExceptionpublic void load(InputStream is) throws NumberFormatException, IOException
is - IOExceptionNumberFormatExceptionpublic void loadDirectory(String lexDir) throws IOException
lexDir - IOExceptionpublic void loadClassPath()
throws IOException
lexDir - IOExceptionpublic void startAutoload()
public void stopAutoload()
public boolean isSync()
public abstract boolean match(int t,
String key)
t - key - public abstract IWord add(int t, IWord word)
t - word - IWord - public abstract IWord add(int t, String key, int fre, int type, String entity)
t - key - fre - type - entity - public abstract IWord add(int t, String key, int fre, int type)
t - key - fre - type - IWord - public abstract IWord add(int t, String key, int type)
t - key - type - IWord - public abstract IWord add(int t, String key, int type, String entity)
t - key - type - entity - IWord - public abstract IWord get(int t, String key)
t - key - public abstract void remove(int t,
String key)
t - key - public abstract int size(int t)
t - public static int getIndex(String key)
key - public JcsegTaskConfig getConfig()
public void setConfig(JcsegTaskConfig config)
public static void loadWords(JcsegTaskConfig config, ADictionary dic, File file) throws NumberFormatException, FileNotFoundException, IOException
config - dic - file - IOExceptionFileNotFoundExceptionNumberFormatExceptionpublic static void loadWords(JcsegTaskConfig config, ADictionary dic, String file) throws NumberFormatException, FileNotFoundException, IOException
config - dic - file - IOExceptionFileNotFoundExceptionNumberFormatExceptionpublic static void loadWords(JcsegTaskConfig config, ADictionary dic, InputStream is) throws NumberFormatException, IOException
config - dic - is - IOExceptionNumberFormatExceptionpublic static boolean resetPrefixLength(JcsegTaskConfig config, ADictionary dic, int mixLength)
mixPrefixLengthconfig - dic - mixLength - public static boolean resetSuffixLength(JcsegTaskConfig config, ADictionary dic, int mixLength)
mixSuffixLengthconfig - dic - mixLength - Copyright © 2017. All Rights Reserved.