use of edu.illinois.cs.cogcomp.core.datastructures.QueryableList in project cogcomp-nlp by CogComp.
the class ChunkEmbedding method getFeatures.
@Override
public Set<Feature> getFeatures(Constituent c) throws EdisonException {
View constituents = c.getTextAnnotation().getView(viewName);
IQueryable<Constituent> shallowParseContained = constituents.where(Queries.containedInConstituent(c));
int numChunks = ((QueryableList<Constituent>) shallowParseContained).size();
Set<Feature> features = new LinkedHashSet<>();
if (numChunks > 0)
features.add(RealFeature.create("nchnks", numChunks));
if (numChunks == 1) {
features.add(DiscreteFeature.create("nchnks-th:1"));
} else if (numChunks == 2) {
features.add(DiscreteFeature.create("nchnks-th:2"));
} else if (numChunks >= 3) {
features.add(DiscreteFeature.create("nchnks-th:many"));
}
Counter<String> counter = new Counter<>();
Predicate<Constituent> condition = Queries.containedInConstituentExclusive(c);
addFeatures(features, constituents, condition, counter, "cont-in");
condition = Queries.containsConstituent(c);
addFeatures(features, constituents, condition, counter, "contains");
condition = Queries.sameSpanAsConstituent(c);
addFeatures(features, constituents, condition, counter, "=span");
condition = Queries.exclusivelyOverlaps(c);
addFeatures(features, constituents, condition, counter, "ex-ovlp");
condition = Queries.hasOverlap(c);
addFeatures(features, constituents, condition, counter, "has-ovlp");
// condition = Queries.hasNoOverlap(c);
// addFeatures(features, constituents, condition, counter,
// "has-no-overlap");
condition = Queries.sameStartSpanAs(c);
addFeatures(features, constituents, condition, counter, "=start");
condition = Queries.sameEndSpanAs(c);
addFeatures(features, constituents, condition, counter, "=end");
features.addAll(FeatureUtilities.getFeatures(counter));
return features;
}
Aggregations