Class CommandLineInterface

java.lang.Object
com.optimaize.langdetect.cybozu.CommandLineInterface

public class CommandLineInterface extends Object
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 Details

    • DEFAULT_ALPHA

      private static final double DEFAULT_ALPHA
      smoothing default parameter (ELE)
      See Also:
    • opt_with_value

      private final Map<String,String> opt_with_value
      for Command line easy parser
    • values

      private final Map<String,String> values
    • opt_without_value

      private final Set<String> opt_without_value
    • arglist

      private final List<String> arglist
  • Constructor Details

    • CommandLineInterface

      public CommandLineInterface()
  • Method Details

    • main

      public static void main(String[] args) throws IOException
      Command Line Interface
      Parameters:
      args - command line arguments
      Throws:
      IOException
    • parse

      private void parse(String[] args)
      Command line easy parser
      Parameters:
      args - command line arguments
    • addOpt

      private void addOpt(String opt, String key, String value)
    • requireParamString

      @NotNull private @NotNull String requireParamString(@NotNull @NotNull String key)
    • getParamDouble

      private double getParamDouble(String key, double defaultValue)
      Returns the double, or the default is absent. Throws if the double is specified but invalid.
    • getParamLongOrNull

      @Nullable private @Nullable Long getParamLongOrNull(String key)
    • hasParam

      private boolean hasParam(String opt)
    • searchFile

      private File searchFile(File directory, String pattern)
      File search (easy glob)
      Parameters:
      directory - directory path
      pattern - 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 IOException
      Language detection test for each file (--detectlang option)
       usage: --detectlang -d [profile directory] -a [alpha] -s [seed] [test file(s)]
       
      Throws:
      IOException
    • batchTest

      public void batchTest() throws IOException
      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

      private LanguageDetector makeDetector() throws IOException
      Using all language profiles from the given directory.
      Throws:
      IOException