com.cybozu.labs.langdetect
Class DetectorFactory

java.lang.Object
  extended by com.cybozu.labs.langdetect.DetectorFactory

public class DetectorFactory
extends Object

Language Detector Factory Class This class manages an initialization and constructions of Detector. Before using language detection library, load profiles with loadProfile(String) method and set initialization parameters. When the language detection, construct Detector instance via create(). See also Detector's sample code.

Author:
Nakatani Shuyo
See Also:
Detector

Field Summary
 ArrayList<String> langlist
           
 Long seed
           
 HashMap<String,double[]> wordLangProbMap
           
 
Method Summary
static void clear()
          Clear loaded language profiles (reinitialization to be available)
static Detector create()
          Construct Detector instance
static Detector create(double alpha)
          Construct Detector instance with smoothing parameter
static List<String> getLangList()
           
static void loadProfile(File profileDirectory)
          Load profiles from specified directory.
static void loadProfile(List<String> json_profiles)
          Load profiles from specified directory.
static void loadProfile(String profileDirectory)
          Load profiles from specified directory.
static void setSeed(long seed)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wordLangProbMap

public HashMap<String,double[]> wordLangProbMap

langlist

public ArrayList<String> langlist

seed

public Long seed
Method Detail

loadProfile

public static void loadProfile(String profileDirectory)
                        throws LangDetectException
Load profiles from specified directory. This method must be called once before language detection.

Parameters:
profileDirectory - profile directory path
Throws:
LangDetectException - Can't open profiles(error code = ErrorCode.FileLoadError) or profile's format is wrong (error code = ErrorCode.FormatError)

loadProfile

public static void loadProfile(File profileDirectory)
                        throws LangDetectException
Load profiles from specified directory. This method must be called once before language detection.

Parameters:
profileDirectory - profile directory path
Throws:
LangDetectException - Can't open profiles(error code = ErrorCode.FileLoadError) or profile's format is wrong (error code = ErrorCode.FormatError)

loadProfile

public static void loadProfile(List<String> json_profiles)
                        throws LangDetectException
Load profiles from specified directory. This method must be called once before language detection.

Throws:
LangDetectException - Can't open profiles(error code = ErrorCode.FileLoadError) or profile's format is wrong (error code = ErrorCode.FormatError)

clear

public static void clear()
Clear loaded language profiles (reinitialization to be available)


create

public static Detector create()
                       throws LangDetectException
Construct Detector instance

Returns:
Detector instance
Throws:
LangDetectException

create

public static Detector create(double alpha)
                       throws LangDetectException
Construct Detector instance with smoothing parameter

Parameters:
alpha - smoothing parameter (default value = 0.5)
Returns:
Detector instance
Throws:
LangDetectException

setSeed

public static void setSeed(long seed)

getLangList

public static final List<String> getLangList()


Copyright © 2012. All Rights Reserved.