Class LanguageDetectorModel
java.lang.Object
opennlp.tools.util.model.BaseModel
opennlp.tools.langdetect.LanguageDetectorModel
- All Implemented Interfaces:
Serializable, ArtifactProvider
The
LanguageDetectorModel is the model used by a learnable LanguageDetector.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate static final longFields inherited from class BaseModel
artifactMap, FACTORY_NAME, MANIFEST_ENTRY, toolFactory, TRAINING_CUTOFF_PROPERTY, TRAINING_EVENTHASH_PROPERTY, TRAINING_ITERATIONS_PROPERTY -
Constructor Summary
ConstructorsConstructorDescriptionLanguageDetectorModel(File modelFile) Initializes aLanguageDetectorModelinstance via a validFile.Initializes aLanguageDetectorModelinstance via a validInputStream.LanguageDetectorModel(URL modelURL) Initializes aLanguageDetectorModelinstance via a validURL.LanguageDetectorModel(MaxentModel langdetectModel, Map<String, String> manifestInfoEntries, LanguageDetectorFactory factory) Initializes aLanguageDetectorModelinstance via given parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected Class<? extends BaseToolFactory> Subclasses should override this method if their module has a defaultBaseToolFactorysubclass.protected voidValidates the parsed artifacts.Methods inherited from class BaseModel
checkArtifactMap, createArtifactSerializers, createArtifactSerializers, deserialize, getArtifact, getArtifactSerializer, getLanguage, getManifestProperty, getVersion, isLoadedFromSerialized, serialize, serialize, serialize, setManifestProperty, skipEntryForSerialization
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
COMPONENT_NAME
- See Also:
-
LANGDETECT_MODEL_ENTRY_NAME
- See Also:
-
-
Constructor Details
-
LanguageDetectorModel
public LanguageDetectorModel(MaxentModel langdetectModel, Map<String, String> manifestInfoEntries, LanguageDetectorFactory factory) Initializes aLanguageDetectorModelinstance via given parameters.- Parameters:
langdetectModel- A validMaxentModel.manifestInfoEntries- Additional information kept in the manifest.factory- TheLanguageDetectorFactoryfor creating related objects.
-
LanguageDetectorModel
Initializes aLanguageDetectorModelinstance via a validInputStream.- Parameters:
in- TheInputStreamused for loading the model.- Throws:
IOException- Thrown if IO errors occurred during initialization.
-
LanguageDetectorModel
Initializes aLanguageDetectorModelinstance via a validFile.- Parameters:
modelFile- TheFileused for loading the model.- Throws:
IOException- Thrown if IO errors occurred during initialization.
-
LanguageDetectorModel
Initializes aLanguageDetectorModelinstance via a validURL.- Parameters:
modelURL- TheURLused for loading the model.- Throws:
IOException- Thrown if IO errors occurred during initialization.
-
-
Method Details
-
validateArtifactMap
Description copied from class:BaseModelValidates the parsed artifacts. If something is not valid, subclasses should throw anInvalidFormatException.Note: Subclasses should generally invoke
super.validateArtifactMapat the beginning of this method.- Overrides:
validateArtifactMapin classBaseModel- Throws:
InvalidFormatException- Thrown if artifacts were found to be inconsistent.
-
getFactory
- Returns:
- Retrieves the active
LanguageDetectorFactory.
-
getDefaultFactory
Description copied from class:BaseModelSubclasses should override this method if their module has a defaultBaseToolFactorysubclass.- Overrides:
getDefaultFactoryin classBaseModel- Returns:
- The default
BaseToolFactoryfor the component, ornullif none.
-
getMaxentModel
- Returns:
- Retrieves a
MaxentModel.
-