public class CommandLineInterface
extends java.lang.Object
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
| Modifier and Type | Field and Description |
|---|---|
private java.util.List<java.lang.String> |
arglist |
private static double |
DEFAULT_ALPHA
smoothing default parameter (ELE)
|
private java.util.Map<java.lang.String,java.lang.String> |
opt_with_value
for Command line easy parser
|
private java.util.Set<java.lang.String> |
opt_without_value |
private java.util.Map<java.lang.String,java.lang.String> |
values |
| Constructor and Description |
|---|
CommandLineInterface() |
| Modifier and Type | Method and Description |
|---|---|
private void |
addOpt(java.lang.String opt,
java.lang.String key,
java.lang.String value) |
void |
batchTest()
Batch Test of Language Detection (--batchtest option)
|
void |
detectLang()
Language detection test for each file (--detectlang option)
|
void |
generateProfile()
Generate Language Profile from a text file.
|
private double |
getParamDouble(java.lang.String key,
double defaultValue)
Returns the double, or the default is absent.
|
private @Nullable java.lang.Long |
getParamLongOrNull(java.lang.String key) |
private boolean |
hasParam(java.lang.String opt) |
static void |
main(java.lang.String[] args)
Command Line Interface
|
private LanguageDetector |
makeDetector()
Using all language profiles from the given directory.
|
private void |
parse(java.lang.String[] args)
Command line easy parser
|
private @NotNull java.lang.String |
requireParamString(@NotNull java.lang.String key) |
private java.io.File |
searchFile(java.io.File directory,
java.lang.String pattern)
File search (easy glob)
|
private static final double DEFAULT_ALPHA
private final java.util.Map<java.lang.String,java.lang.String> opt_with_value
private final java.util.Map<java.lang.String,java.lang.String> values
private final java.util.Set<java.lang.String> opt_without_value
private final java.util.List<java.lang.String> arglist
public static void main(java.lang.String[] args)
throws java.io.IOException
args - command line argumentsjava.io.IOExceptionprivate void parse(java.lang.String[] args)
args - command line argumentsprivate void addOpt(java.lang.String opt,
java.lang.String key,
java.lang.String value)
@NotNull
private @NotNull java.lang.String requireParamString(@NotNull
@NotNull java.lang.String key)
private double getParamDouble(java.lang.String key,
double defaultValue)
@Nullable private @Nullable java.lang.Long getParamLongOrNull(java.lang.String key)
private boolean hasParam(java.lang.String opt)
private java.io.File searchFile(java.io.File directory,
java.lang.String pattern)
directory - directory pathpattern - searching file pattern with regular representationpublic void generateProfile()
usage: --genprofile [text file] [language name]
public void detectLang()
throws java.io.IOException
usage: --detectlang -d [profile directory] -a [alpha] -s [seed] [test file(s)]
java.io.IOExceptionpublic void batchTest()
throws java.io.IOException
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
java.io.IOExceptionprivate LanguageDetector makeDetector() throws java.io.IOException
java.io.IOException