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
generatorIAdaptiveFeatureGeneratorfeature generator
WindowFeatureGenerator(IAdaptiveFeatureGenerator, int, int)
Initializes the current instance with the given parameters.
public WindowFeatureGenerator(IAdaptiveFeatureGenerator generator, int prevWindowSize, int nextWindowSize)
Parameters
generatorIAdaptiveFeatureGeneratorFeature generator to apply to the window.
prevWindowSizeintSize of the window to the left of the current token.
nextWindowSizeintSize 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
generatorsIAdaptiveFeatureGenerator[]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
prevWindowSizeintnextWindowSizeintgeneratorsIAdaptiveFeatureGenerator[]
Fields
NEXT_PREFIX
public const string NEXT_PREFIX = "n"
Field Value
PREV_PREFIX
public const string PREV_PREFIX = "p"
Field Value
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
featuresIList<string>The list of features to be added to.
tokensstring[]The tokens of the sentence or other text unit being processed.
indexintThe index of the token which is currently being processed.
predsstring[]
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)