Class CommandLineInterface
java.lang.Object
com.optimaize.langdetect.cybozu.CommandLineInterface
LangDetect Command Line Interface.
This is a command line interface of Language Detection Library "LangDetect".
Renamed: this class was previously known as "Command".
TODO after my recent changes switching to the new Detector this code is untested. -Fabian
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final doublesmoothing default parameter (ELE)for Command line easy parser -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidvoidBatch Test of Language Detection (--batchtest option)voidLanguage detection test for each file (--detectlang option)voidGenerate Language Profile from a text file.private doublegetParamDouble(String key, double defaultValue) Returns the double, or the default is absent.private @Nullable LonggetParamLongOrNull(String key) private booleanstatic voidCommand Line Interfaceprivate LanguageDetectorUsing all language profiles from the given directory.private voidCommand line easy parserprivate @NotNull StringrequireParamString(@NotNull String key) private FilesearchFile(File directory, String pattern) File search (easy glob)
-
Field Details
-
DEFAULT_ALPHA
private static final double DEFAULT_ALPHAsmoothing default parameter (ELE)- See Also:
-
opt_with_value
-
values
-
opt_without_value
-
arglist
-
-
Constructor Details
-
CommandLineInterface
public CommandLineInterface()
-
-
Method Details
-
main
Command Line Interface- Parameters:
args- command line arguments- Throws:
IOException
-
parse
Command line easy parser- Parameters:
args- command line arguments
-
addOpt
-
requireParamString
-
getParamDouble
Returns the double, or the default is absent. Throws if the double is specified but invalid. -
getParamLongOrNull
-
hasParam
-
searchFile
-
generateProfile
public void generateProfile()Generate Language Profile from a text file.usage: --genprofile [text file] [language name]
-
detectLang
Language detection test for each file (--detectlang option)usage: --detectlang -d [profile directory] -a [alpha] -s [seed] [test file(s)]
- Throws:
IOException
-
batchTest
Batch Test of Language Detection (--batchtest option)usage: --batchtest -d [profile directory] -a [alpha] -s [seed] [test data(s)]
The format of test data(s):[correct language name]\t[text body for test]\n
- Throws:
IOException
-
makeDetector
Using all language profiles from the given directory.- Throws:
IOException
-