Module org.elasticsearch.xcore
Class NGram
java.lang.Object
org.elasticsearch.xpack.core.ml.inference.preprocessing.NGram
- All Implemented Interfaces:
org.apache.lucene.util.Accountable,NamedWriteable,Writeable,ToXContent,ToXContentObject,LenientlyParsedPreProcessor,PreProcessor,StrictlyParsedPreProcessor,NamedXContentObject
public class NGram
extends Object
implements LenientlyParsedPreProcessor, StrictlyParsedPreProcessor
PreProcessor for n-gram encoding a string
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xpack.core.ml.inference.preprocessing.PreProcessor
PreProcessor.PreProcessorParseContextNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final longstatic final ParseFieldFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLEFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic NGramfromXContentLenient(XContentParser parser, PreProcessor.PreProcessorParseContext context) static NGramfromXContentStrict(XContentParser parser, PreProcessor.PreProcessorParseContext context) getField()intgetName()int[]getOutputFieldType(String outputField) intgetStart()inthashCode()The expected input fieldsbooleanisCustom()voidProcess the given fields and their values and return the modified map.longtoString()toXContent(XContentBuilder builder, ToXContent.Params params) voidwriteTo(StreamOutput out) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResourcesMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
SHALLOW_SIZE
public static final long SHALLOW_SIZE -
NAME
-
FIELD
-
FEATURE_PREFIX
-
NGRAMS
-
START
-
LENGTH
-
CUSTOM
-
-
Constructor Details
-
NGram
-
NGram
- Throws:
IOException
-
-
Method Details
-
fromXContentStrict
public static NGram fromXContentStrict(XContentParser parser, PreProcessor.PreProcessorParseContext context) -
fromXContentLenient
public static NGram fromXContentLenient(XContentParser parser, PreProcessor.PreProcessorParseContext context) -
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
toString
-
inputFields
Description copied from interface:PreProcessorThe expected input fields- Specified by:
inputFieldsin interfacePreProcessor
-
outputFields
- Specified by:
outputFieldsin interfacePreProcessor- Returns:
- The resulting output fields. It is imperative that the order is consistent between calls.
-
process
Description copied from interface:PreProcessorProcess the given fields and their values and return the modified map. NOTE: The passed map object is mutated directly- Specified by:
processin interfacePreProcessor- Parameters:
fields- The fields and their values to process
-
reverseLookup
- Specified by:
reverseLookupin interfacePreProcessor- Returns:
- Reverse lookup map to match resulting features to their original feature name
-
getOutputFieldType
- Specified by:
getOutputFieldTypein interfacePreProcessor
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-
getWriteableName
- Specified by:
getWriteableNamein interfaceNamedWriteable
-
getName
- Specified by:
getNamein interfaceNamedXContentObject- Returns:
- The name of the XContentObject that is to be serialized
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
getField
-
getFeaturePrefix
-
getnGrams
public int[] getnGrams() -
getStart
public int getStart() -
getLength
public int getLength() -
isCustom
public boolean isCustom()- Specified by:
isCustomin interfacePreProcessor- Returns:
- Is the pre-processor a custom one provided by the user, or automatically created? This changes how feature importance is calculated, as fields generated by custom processors get individual feature importance calculations.
-
equals
-
hashCode
public int hashCode()
-