Package com.optimaize.langdetect.cybozu
Class CommandLineInterface
- java.lang.Object
-
- com.optimaize.langdetect.cybozu.CommandLineInterface
-
public class CommandLineInterface extends java.lang.ObjectLangDetect 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
Fields Modifier and Type Field Description private java.util.List<java.lang.String>arglistprivate static doubleDEFAULT_ALPHAsmoothing default parameter (ELE)private java.util.Map<java.lang.String,java.lang.String>opt_with_valuefor Command line easy parserprivate java.util.Set<java.lang.String>opt_without_valueprivate java.util.Map<java.lang.String,java.lang.String>values
-
Constructor Summary
Constructors Constructor Description CommandLineInterface()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddOpt(java.lang.String opt, java.lang.String key, java.lang.String value)voidbatchTest()Batch Test of Language Detection (--batchtest option)voiddetectLang()Language detection test for each file (--detectlang option)voidgenerateProfile()Generate Language Profile from a text file.private doublegetParamDouble(java.lang.String key, double defaultValue)Returns the double, or the default is absent.private @Nullable java.lang.LonggetParamLongOrNull(java.lang.String key)private booleanhasParam(java.lang.String opt)static voidmain(java.lang.String[] args)Command Line Interfaceprivate LanguageDetectormakeDetector()Using all language profiles from the given directory.private voidparse(java.lang.String[] args)Command line easy parserprivate @NotNull java.lang.StringrequireParamString(@NotNull java.lang.String key)private java.io.FilesearchFile(java.io.File directory, java.lang.String pattern)File search (easy glob)
-
-
-
Field Detail
-
DEFAULT_ALPHA
private static final double DEFAULT_ALPHA
smoothing default parameter (ELE)- See Also:
- Constant Field Values
-
opt_with_value
private final java.util.Map<java.lang.String,java.lang.String> opt_with_value
for Command line easy parser
-
values
private final java.util.Map<java.lang.String,java.lang.String> values
-
opt_without_value
private final java.util.Set<java.lang.String> opt_without_value
-
arglist
private final java.util.List<java.lang.String> arglist
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.io.IOExceptionCommand Line Interface- Parameters:
args- command line arguments- Throws:
java.io.IOException
-
parse
private void parse(java.lang.String[] args)
Command line easy parser- Parameters:
args- command line arguments
-
addOpt
private void addOpt(java.lang.String opt, java.lang.String key, java.lang.String value)
-
requireParamString
@NotNull private @NotNull java.lang.String requireParamString(@NotNull @NotNull java.lang.String key)
-
getParamDouble
private double getParamDouble(java.lang.String key, double defaultValue)Returns the double, or the default is absent. Throws if the double is specified but invalid.
-
getParamLongOrNull
@Nullable private @Nullable java.lang.Long getParamLongOrNull(java.lang.String key)
-
hasParam
private boolean hasParam(java.lang.String opt)
-
searchFile
private java.io.File searchFile(java.io.File directory, java.lang.String pattern)File search (easy glob)- Parameters:
directory- directory pathpattern- searching file pattern with regular representation- Returns:
- matched file
-
generateProfile
public void generateProfile()
Generate Language Profile from a text file.usage: --genprofile [text file] [language name]
-
detectLang
public void detectLang() throws java.io.IOExceptionLanguage detection test for each file (--detectlang option)usage: --detectlang -d [profile directory] -a [alpha] -s [seed] [test file(s)]
- Throws:
java.io.IOException
-
batchTest
public void batchTest() throws java.io.IOExceptionBatch 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:
java.io.IOException
-
makeDetector
private LanguageDetector makeDetector() throws java.io.IOException
Using all language profiles from the given directory.- Throws:
java.io.IOException
-
-