Package opennlp.dl
Class InferenceOptions
java.lang.Object
opennlp.dl.InferenceOptions
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintintReturns whether tokenization should lower case the input text and strip accents, as required by uncased models.intbooleanisGpu()booleanbooleanbooleanReturns whether input dashes are normalized to the ASCII hyphen before inference.booleanReturns whether input whitespace is normalized to ASCII spaces before inference.voidsetDocumentSplitSize(int documentSplitSize) voidsetGpu(boolean gpu) voidsetGpuDeviceId(int gpuDeviceId) voidsetIncludeAttentionMask(boolean includeAttentionMask) voidsetIncludeTokenTypeIds(boolean includeTokenTypeIds) voidsetLowerCase(boolean lowerCase) Sets whether tokenization should lower case the input text and strip accents.voidsetNormalizeDashes(boolean normalizeDashes) Replaces Unicode dashes in the input with the ASCII hyphen-minus before inference.voidsetNormalizeWhitespace(boolean normalizeWhitespace) Replaces every Unicode whitespace character in the input with an ASCII space before inference.voidsetSplitOverlapSize(int splitOverlapSize)
-
Constructor Details
-
InferenceOptions
public InferenceOptions()
-
-
Method Details
-
isIncludeAttentionMask
public boolean isIncludeAttentionMask() -
setIncludeAttentionMask
public void setIncludeAttentionMask(boolean includeAttentionMask) -
isIncludeTokenTypeIds
public boolean isIncludeTokenTypeIds() -
setIncludeTokenTypeIds
public void setIncludeTokenTypeIds(boolean includeTokenTypeIds) -
isGpu
public boolean isGpu() -
setGpu
public void setGpu(boolean gpu) -
getGpuDeviceId
public int getGpuDeviceId() -
setGpuDeviceId
public void setGpuDeviceId(int gpuDeviceId) -
getDocumentSplitSize
public int getDocumentSplitSize() -
setDocumentSplitSize
public void setDocumentSplitSize(int documentSplitSize) -
getSplitOverlapSize
public int getSplitOverlapSize() -
setSplitOverlapSize
public void setSplitOverlapSize(int splitOverlapSize) -
isNormalizeWhitespace
public boolean isNormalizeWhitespace()Returns whether input whitespace is normalized to ASCII spaces before inference.- Returns:
- whether input whitespace is normalized to ASCII spaces before inference
-
setNormalizeWhitespace
public void setNormalizeWhitespace(boolean normalizeWhitespace) Replaces every Unicode whitespace character in the input with an ASCII space before inference. This is offset preserving (each whitespace code point maps to one space), so any spans a model produces still align with the input. Off by default.This is a one-for-one replacement, not the collapse-and-trim whitespace fold of the runtime
TextNormalizer.whitespace()rung: runs of whitespace are not merged and leading or trailing whitespace is not removed, so offsets are preserved.- Parameters:
normalizeWhitespace- Whether to normalize whitespace.
-
isNormalizeDashes
public boolean isNormalizeDashes()Returns whether input dashes are normalized to the ASCII hyphen before inference.- Returns:
- whether input dashes are normalized to the ASCII hyphen before inference
-
setNormalizeDashes
public void setNormalizeDashes(boolean normalizeDashes) Replaces Unicode dashes in the input with the ASCII hyphen-minus before inference. This is offset preserving for the dash characters in the Basic Multilingual Plane (the common case). The mathematical minus signs are not affected. Off by default.A supplementary-plane dash shrinks from two chars to one, which shifts later offsets, so with this enabled
find(...)reports offsets into the normalized text in that case. UseNameFinderDL.findInOriginal(...)for offsets mapped back to the original input.- Parameters:
normalizeDashes- Whether to normalize dashes.
-
getLowerCase
Returns whether tokenization should lower case the input text and strip accents, as required by uncased models.- Returns:
Boolean.TRUEfor uncased models,Boolean.FALSEfor cased models, ornullif not set, in which case each component applies the default that matches its commonly used models.
-
setLowerCase
public void setLowerCase(boolean lowerCase) Sets whether tokenization should lower case the input text and strip accents. Settruefor uncased models andfalsefor cased models. If not set, each component applies the default that matches its commonly used models.- Parameters:
lowerCase- Whether to lower case the input text during tokenization.
-