Class WindowFeatureGenerator

Namespace
NOpenNLP.Tools.Util.Featuregen
Assembly
NOpenNLP.Tools.dll

Generates previous and next features for a given IAdaptiveFeatureGenerator. The window size can be specified.

Features: Current token is always included unchanged Previous tokens are prefixed with p distance Next tokens are prefix with n distance

public class WindowFeatureGenerator : IAdaptiveFeatureGenerator
Inheritance
WindowFeatureGenerator
Implements
Inherited Members

Constructors

WindowFeatureGenerator(IAdaptiveFeatureGenerator)

Initializes the current instance. The previous and next window size is 5.

public WindowFeatureGenerator(IAdaptiveFeatureGenerator generator)

Parameters

generator IAdaptiveFeatureGenerator

feature generator

WindowFeatureGenerator(IAdaptiveFeatureGenerator, int, int)

Initializes the current instance with the given parameters.

public WindowFeatureGenerator(IAdaptiveFeatureGenerator generator, int prevWindowSize, int nextWindowSize)

Parameters

generator IAdaptiveFeatureGenerator

Feature generator to apply to the window.

prevWindowSize int

Size of the window to the left of the current token.

nextWindowSize int

Size of the window to the right of the current token.

WindowFeatureGenerator(params IAdaptiveFeatureGenerator[])

Initializes the current instance with the given parameters.

public WindowFeatureGenerator(params IAdaptiveFeatureGenerator[] generators)

Parameters

generators IAdaptiveFeatureGenerator[]

array of feature generators

WindowFeatureGenerator(int, int, params IAdaptiveFeatureGenerator[])

Initializes the current instance with the given parameters.

public WindowFeatureGenerator(int prevWindowSize, int nextWindowSize, params IAdaptiveFeatureGenerator[] generators)

Parameters

prevWindowSize int
nextWindowSize int
generators IAdaptiveFeatureGenerator[]

Fields

NEXT_PREFIX

public const string NEXT_PREFIX = "n"

Field Value

string

PREV_PREFIX

public const string PREV_PREFIX = "p"

Field Value

string

Methods

ClearAdaptiveData()

Informs the feature generator that the context of the adaptive data (typically a document) is no longer valid.

public virtual void ClearAdaptiveData()

CreateFeatures(IList<string>, string[], int, string[])

Adds the appropriate features for the token at the specified index with the specified array of previous outcomes to the specified list of features.

public virtual void CreateFeatures(IList<string> features, string[] tokens, int index, string[] preds)

Parameters

features IList<string>

The list of features to be added to.

tokens string[]

The tokens of the sentence or other text unit being processed.

index int

The index of the token which is currently being processed.

preds string[]

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

UpdateAdaptiveData(string[], string[])

Informs the feature generator that the specified tokens have been classified with the corresponding set of specified outcomes.

public virtual void UpdateAdaptiveData(string[] tokens, string[] outcomes)

Parameters

tokens string[]

The tokens of the sentence or other text unit which has been processed.

outcomes string[]

The outcomes associated with the specified tokens.