public class FeatureUtilities extends Object
Constructor and Description |
---|
FeatureUtilities() |
Modifier and Type | Method and Description |
---|---|
static FeatureExtractor |
conjoin(FeatureExtractor f1,
FeatureExtractor f2)
Conjoins two feature extractors.
|
static Set<Feature> |
conjoin(Set<Feature> feats1,
Set<Feature> feats2)
Conjoins two feature sets.
|
static Feature |
conjunct(String left,
String right)
Conjoins two discrete features corresponding to the strings left and right.
|
static Pair<int[],double[]> |
convert(Set<Feature> features,
edu.illinois.cs.cogcomp.lbjava.learn.Lexicon lexicon,
boolean trainingMode)
Convert a feature set into a pair of arrays of integers and doubles by looking up the feature
name in the provided lexicon.
|
static Set<Feature> |
deserializeFeatureSet(byte[] bytes)
Deserializes a byte array into a set of features
|
static edu.illinois.cs.cogcomp.lbjava.classify.Feature |
getFeature(edu.illinois.cs.cogcomp.lbjava.learn.Lexicon lexicon,
int id)
This function gets the feature from the lexicon using the id.
|
static int |
getFeatureId(edu.illinois.cs.cogcomp.lbjava.learn.Lexicon lexicon,
boolean trainingMode,
Feature feature)
Returns the id of the feature according to the lexicon.
|
static Map<String,Float> |
getFeatureMap(FeatureExtractor fex,
Constituent c)
Create a feature map using the specified feature extractor on the input constituent.
|
static Set<Feature> |
getFeatures(Counter<String> counter)
Convert a counter over strings into a set of real valued features.
|
static Set<Feature> |
getFeatures(Map<String,Float> features)
Convert a map from feature names to values into a set of real valued features.
|
static Set<Feature> |
getFeatures(Set<String> features)
Convert a set of strings into a set of discrete features.
|
static Set<String> |
getFeatureSet(FeatureExtractor fex,
Constituent c)
Create a feature set using the specified feature extractor on the input constituent.
|
static edu.illinois.cs.cogcomp.lbjava.classify.Feature |
getLBJFeature(Feature feature)
Convert an edison feature into an LBJ feature
|
static edu.illinois.cs.cogcomp.lbjava.classify.Classifier |
getLBJFeatureExtractor(FeatureExtractor fex)
Convert an edison feature extractor into an LBJ classifier
|
static edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector |
getLBJFeatures(Set<Feature> features)
Converts a Set of features into an LBJ friendly feature vector.
|
static Set<Feature> |
prefix(String prefix,
Set<Feature> features)
Add a prefix to all the features in the set.
|
static byte[] |
serializeFeatureSet(Set<Feature> features)
Serializes a set of features into a byte array.
|
public static Set<Feature> getFeatures(Set<String> features)
public static Set<Feature> getFeatures(Map<String,Float> features)
public static Set<Feature> getFeatures(Counter<String> counter)
public static Set<Feature> prefix(String prefix, Set<Feature> features)
prefix
- The prefix to be added.features
- The feature setpublic static edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector getLBJFeatures(Set<Feature> features)
public static edu.illinois.cs.cogcomp.lbjava.classify.Feature getLBJFeature(Feature feature)
public static edu.illinois.cs.cogcomp.lbjava.classify.Classifier getLBJFeatureExtractor(FeatureExtractor fex)
public static Map<String,Float> getFeatureMap(FeatureExtractor fex, Constituent c) throws EdisonException
EdisonException
public static Set<String> getFeatureSet(FeatureExtractor fex, Constituent c) throws EdisonException
EdisonException
public static Pair<int[],double[]> convert(Set<Feature> features, edu.illinois.cs.cogcomp.lbjava.learn.Lexicon lexicon, boolean trainingMode)
features
- The feature setlexicon
- The lexicontrainingMode
- Should an unseen feature string be added to the lexicon? If this is
false, unseen features will be given an ID whose value is one more than the number of
features.public static edu.illinois.cs.cogcomp.lbjava.classify.Feature getFeature(edu.illinois.cs.cogcomp.lbjava.learn.Lexicon lexicon, int id)
public static int getFeatureId(edu.illinois.cs.cogcomp.lbjava.learn.Lexicon lexicon, boolean trainingMode, Feature feature)
public static FeatureExtractor conjoin(FeatureExtractor f1, FeatureExtractor f2)
f1
- One feature extractorf2
- Another feature extractorpublic static Feature conjunct(String left, String right)
public static Set<Feature> conjoin(Set<Feature> feats1, Set<Feature> feats2)
feats1
- The first feature setfeats2
- The second feature setpublic static byte[] serializeFeatureSet(Set<Feature> features) throws IOException
IOException
public static Set<Feature> deserializeFeatureSet(byte[] bytes) throws IOException
IOException
Copyright © 2017. All rights reserved.