Package opennlp.tools.doccat
Class NGramFeatureGenerator
- java.lang.Object
-
- opennlp.tools.doccat.NGramFeatureGenerator
-
- All Implemented Interfaces:
FeatureGenerator
public class NGramFeatureGenerator extends Object implements FeatureGenerator
Generates ngram features for a document. n-gramFeatureGenerator
-
-
Constructor Summary
Constructors Constructor Description NGramFeatureGenerator()
Default constructor for Bi gramsNGramFeatureGenerator(int minGram, int maxGram)
Constructor for ngrams.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<String>
extractFeatures(String[] text, Map<String,Object> extraInfo)
Extract ngram features from given text fragments
-
-
-
Constructor Detail
-
NGramFeatureGenerator
public NGramFeatureGenerator(int minGram, int maxGram) throws InvalidFormatException
Constructor for ngrams.- Parameters:
minGram
- minGram value - which means minimum words in ngram featuresmaxGram
- maxGram value - which means maximum words in ngram features- Throws:
InvalidFormatException
-
NGramFeatureGenerator
public NGramFeatureGenerator() throws InvalidFormatException
Default constructor for Bi grams- Throws:
InvalidFormatException
-
-
Method Detail
-
extractFeatures
public Collection<String> extractFeatures(String[] text, Map<String,Object> extraInfo)
Extract ngram features from given text fragments- Specified by:
extractFeatures
in interfaceFeatureGenerator
- Parameters:
text
- the text fragments to extract features fromextraInfo
- optional extra information- Returns:
- a collection of n gram features
-
-