Package com.optimaize.langdetect.cybozu
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 double
smoothing default parameter (ELE)for Command line easy parser -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
void
Batch Test of Language Detection (--batchtest option)void
Language detection test for each file (--detectlang option)void
Generate Language Profile from a text file.private double
getParamDouble
(String key, double defaultValue) Returns the double, or the default is absent.private @Nullable Long
getParamLongOrNull
(String key) private boolean
static void
Command Line Interfaceprivate LanguageDetector
Using all language profiles from the given directory.private void
Command line easy parserprivate @NotNull String
requireParamString
(@NotNull String key) private File
searchFile
(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
for Command line easy parser -
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
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
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
-