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.- See Also:
FeatureGenerator
-
-
Constructor Summary
Constructors Constructor Description NGramFeatureGenerator()
Instantiates anNGramFeatureGenerator
instance with a Bi grams config.NGramFeatureGenerator(int minGram, int maxGram)
Instantiates anNGramFeatureGenerator
instance with configurable ngram parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<String>
extractFeatures(String[] text, Map<String,Object> extraInfo)
Extracts features from giventext
fragments.
-
-
-
Constructor Detail
-
NGramFeatureGenerator
public NGramFeatureGenerator(int minGram, int maxGram) throws InvalidFormatException
Instantiates anNGramFeatureGenerator
instance with configurable ngram parameters.- Parameters:
minGram
- The minimum words in ngram features.maxGram
- The maximum words in ngram features.- Throws:
InvalidFormatException
- Thrown if parameter values are invalid or inconsistent.
-
NGramFeatureGenerator
public NGramFeatureGenerator() throws InvalidFormatException
Instantiates anNGramFeatureGenerator
instance with a Bi grams config.- Throws:
InvalidFormatException
- Thrown if parameter values are invalid or inconsistent.
-
-
Method Detail
-
extractFeatures
public Collection<String> extractFeatures(String[] text, Map<String,Object> extraInfo)
Description copied from interface:FeatureGenerator
Extracts features from giventext
fragments.- Specified by:
extractFeatures
in interfaceFeatureGenerator
- Parameters:
text
- The text fragments to extract features fromextraInfo
- Optional extra information to be used by theFeatureGenerator
.- Returns:
- A collection of features.
-
-