public class DetectorFactory
extends java.lang.Object
implements java.io.Serializable
Detector.
Before using language detection library,
load profiles with loadProfile(String) method
and set initialization parameters.
When the language detection,
construct Detector instance via create().
See also Detector's sample code.
Detector,
Serialized Form| Constructor and Description |
|---|
DetectorFactory() |
DetectorFactory(java.util.Map<java.lang.String,double[]> wordLangProbMap,
java.util.ArrayList<java.lang.String> langlist,
long seed) |
| Modifier and Type | Method and Description |
|---|---|
void |
addProfile(LangProfile profile,
int index,
int langsize) |
void |
clear()
Clear loaded language profiles (reinitialization to be available)
|
Detector |
create()
Construct Detector instance
|
Detector |
create(double alpha)
Construct Detector instance with smoothing parameter
|
java.util.List<java.lang.String> |
getLangList()
The languages that this detector factory knows about.
|
long |
getSeed() |
java.util.Map<java.lang.String,double[]> |
getWordLangProbMap()
The language to word-probability mapping.
|
void |
loadProfile(java.io.File profileDirectory)
Load profiles from specified directory.
|
void |
loadProfile(java.util.List<java.lang.String> json_profiles)
Load profiles from specified directory.
|
void |
loadProfile(java.lang.String profileDirectory)
Load profiles from specified directory.
|
void |
setSeed(long seed) |
public DetectorFactory()
public DetectorFactory(java.util.Map<java.lang.String,double[]> wordLangProbMap,
java.util.ArrayList<java.lang.String> langlist,
long seed)
public long getSeed()
public void setSeed(long seed)
public java.util.List<java.lang.String> getLangList()
public java.util.Map<java.lang.String,double[]> getWordLangProbMap()
public void loadProfile(java.lang.String profileDirectory)
throws LangDetectException
profileDirectory - profile directory pathLangDetectException - Can't open profiles(error code = ErrorCode.FileLoadError)
or profile's format is wrong (error code = ErrorCode.FormatError)public void loadProfile(java.io.File profileDirectory)
throws LangDetectException
profileDirectory - profile directory pathLangDetectException - Can't open profiles(error code = ErrorCode.FileLoadError)
or profile's format is wrong (error code = ErrorCode.FormatError)public void loadProfile(java.util.List<java.lang.String> json_profiles)
throws LangDetectException
json_profiles - all json-encoded profilesLangDetectException - Can't open profiles(error code = ErrorCode.FileLoadError)
or profile's format is wrong (error code = ErrorCode.FormatError)public void addProfile(LangProfile profile, int index, int langsize) throws LangDetectException
profile - profileindex - indexlangsize - language sizeLangDetectException - if there's a problempublic void clear()
public Detector create() throws LangDetectException
LangDetectException - if there's a problempublic Detector create(double alpha) throws LangDetectException
alpha - smoothing parameter (default value = 0.5)LangDetectException - if there's a problem