@Override public List<Feature> extract(JCas jCas, IdentifiedAnnotation arg1, IdentifiedAnnotation arg2) throws AnalysisEngineProcessException { List<Feature> features = new ArrayList<Feature>(); features.addAll(this.mention1FeaturesExtractor.extract(jCas, arg1)); features.addAll(this.mention2FeaturesExtractor.extract(jCas, arg2)); return features; }
@Override public List<Feature> extract(JCas jCas, IdentifiedAnnotation arg1, IdentifiedAnnotation arg2) throws AnalysisEngineProcessException { List<Feature> features = new ArrayList<Feature>(); features.addAll(this.mention1FeaturesExtractor.extract(jCas, arg1)); features.addAll(this.mention2FeaturesExtractor.extract(jCas, arg2)); return features; }
/** * Extract features from the <tt>Annotation</tt> using the sub-extractors. The parameters are * passed on as they are. * * @return the combined list of features generated by the sub-extractors. If <tt>name</tt> was set * in the constructor, the top-level context of all features will have that as their name. */ public List<Feature> extract(JCas view, T focusAnnotation) throws CleartkExtractorException { List<Feature> result = new ArrayList<Feature>(); for (FeatureExtractor1<T> extractor : this.extractors) { result.addAll(extractor.extract(view, focusAnnotation)); } return result; }
@Override public List<Feature> extract(JCas view, FOCUS_T focusAnnotation) throws CleartkExtractorException { String spanText = focusAnnotation.getCoveredText(); List<Feature> features = new ArrayList<Feature>(); if (!stopwords.contains(spanText.toLowerCase())) { features.addAll(this.subExtractor.extract(view, focusAnnotation)); } return features; }
public List<Feature> extract(JCas jCas, T focusAnnotation) throws CleartkExtractorException { List<Feature> returnValues = new ArrayList<Feature>(); List<Feature> features = this.extractor.extract(jCas, focusAnnotation); if (baseFeatures == BaseFeatures.INCLUDE) returnValues.addAll(features); for (Function<Feature, List<Feature>> featureFunction : this.featureFunctions) { returnValues.addAll(apply(featureFunction, features)); } return returnValues; }
@Override public List<Feature> extract(JCas view, T focusAnnotation) throws CleartkExtractorException { if (this.accept(annotationClass.cast(focusAnnotation))) { return this.extractor.extract(view, focusAnnotation); } else { return Collections.emptyList(); } }
public List<Feature> extract(JCas view, M focusAnnotation) throws CleartkExtractorException { return subExtractor.extract(view, selectSubAnnotation(focusAnnotation)); }
@Override public List<Feature> extract(JCas view, FOCUS_T focusAnnotation) throws CleartkExtractorException { List<Feature> extracted = this.subExtractor.extract(view, focusAnnotation); List<Feature> result = new ArrayList<Feature>(); if (this.isTrained) { // Filter out selected features result.addAll(Collections2.filter(extracted, this)); } else { // We haven't trained this extractor yet, so just mark the existing features // for future modification, by creating one uber-container feature result.add(new TransformableFeature(this.name, extracted)); } return result; }
@Override public List<Feature> extract(JCas view, Markable focusAnnotation) throws CleartkExtractorException { List<Feature> feats = new ArrayList<>(); // token features: feats.addAll(tokenIdentityContext.extract(view, focusAnnotation)); // token vector features: // if(this.tokenVectorContext != null){ // feats.addAll(this.tokenVectorContext.extract(view, focusAnnotation)); // } // pos features: feats.addAll(mentionFeaturesExtractor.extract(view, focusAnnotation)); // Always do num covered and dep features feats.add(new Feature("NumCoveredTokens", JCasUtil.selectCovered(BaseToken.class, focusAnnotation).size())); feats.addAll(DependencyTreeFeaturesExtractor.extractForNode(view, focusAnnotation, "dep")); return feats; }
@Override public <SEARCH_T extends Annotation> List<Feature> extract( JCas jCas, Annotation focusAnnotation, Bounds bounds, Class<SEARCH_T> annotationClass, FeatureExtractor1<SEARCH_T> extractor) throws CleartkExtractorException { List<Feature> features = new ArrayList<Feature>(); for (Feature feature : extractor.extract(jCas, annotationClass.cast(focusAnnotation))) { features.add(new ContextFeature(this.getName(), feature)); } return features; }
public List<Feature> extractFeatures(JCas jCas, Token token, Sentence sentence) throws CleartkExtractorException { List<Feature> features = new ArrayList<Feature>(); for (FeatureExtractor1<Token> extractor : simpleExtractors) { features.addAll(extractor.extract(jCas, token)); } for (CleartkExtractor<Token, Token> extractor : windowExtractors) { features.addAll(extractor.extractWithin(jCas, token, sentence)); } for (CleartkExtractor<Token, Token> extractor : windowNGramExtractors) { features.addAll(extractor.extractWithin(jCas, token, sentence)); } return features; }
@Override public List<Feature> extract(JCas view, Markable focusAnnotation) throws CleartkExtractorException { List<Feature> feats = new ArrayList<>(); // token features: feats.addAll(tokenIdentityContext.extract(view, focusAnnotation)); // token vector features: // if(this.tokenVectorContext != null){ // feats.addAll(this.tokenVectorContext.extract(view, focusAnnotation)); // } // pos features: feats.addAll(mentionFeaturesExtractor.extract(view, focusAnnotation)); // Always do num covered and dep features feats.add(new Feature("NumCoveredTokens", JCasUtil.selectCovered(BaseToken.class, focusAnnotation).size())); feats.addAll(DependencyTreeFeaturesExtractor.extractForNode(view, focusAnnotation, "dep")); return feats; }
@Override public List<Feature> extract(JCas view, FOCUS_T focusAnnotation) throws CleartkExtractorException { List<Feature> extracted = this.subExtractor.extract(view, focusAnnotation); List<Feature> result = new ArrayList<Feature>(); if (this.isTrained) { // We have trained / loaded a MinMax model, so now fix up the values for (Feature feature : extracted) { result.add(this.transform(feature)); } } else { // We haven't trained this extractor yet, so just mark the existing features // for future modification, by creating one mega container feature result.add(new TransformableFeature(this.name, extracted)); } return result; }
@Override public List<Feature> extract(JCas view, FOCUS_T focusAnnotation) throws CleartkExtractorException { List<Feature> extracted = this.subExtractor.extract(view, focusAnnotation); List<Feature> result = new ArrayList<Feature>(); if (this.isTrained) { // We have trained / loaded a tf*idf model, so now fix up the values for (Feature feature : extracted) { result.add(this.transform(feature)); } } else { // We haven't trained this extractor yet, so just mark the existing features // for future modification, by creating one mega container feature result.add(new TransformableFeature(this.name, extracted)); } return result; }
List<Feature> extractNode(JCas jCas, TreebankNode node, boolean specialCasePP) throws CleartkExtractorException { List<Feature> features = subExtractor.extract(jCas, node); for (Feature feature : features) { feature.setName(createName(specialCasePP, feature)); } return features; }
@Override public <SEARCH_T extends Annotation> List<Feature> extract( JCas jCas, Annotation focusAnnotation, Bounds bounds, Class<SEARCH_T> annotationClass, FeatureExtractor1<SEARCH_T> extractor) throws CleartkExtractorException { List<Feature> features = new ArrayList<Feature>(); int pos = 0; for (SEARCH_T ann : JCasUtil.selectCovered(jCas, annotationClass, focusAnnotation)) { for (Feature feature : extractor.extract(jCas, ann)) { features.add(new ContextFeature(this.getName(), pos, feature)); } pos += 1; } return features; }
@Override public List<Feature> extract(JCas view, FOCUS_T focusAnnotation) throws CleartkExtractorException { List<Feature> extracted = this.subExtractor.extract(view, focusAnnotation); List<Feature> result = new ArrayList<Feature>(); if (this.isTrained) { // We have trained / loaded a centroid tf*idf model, so now compute // a cosine similarity for the extracted values Map<String, Double> extractedFeatureMap = this.featuresToFeatureMap(extracted); result.add(new Feature(name, this.simFunction.distance(extractedFeatureMap, centroidMap))); } else { // We haven't trained this extractor yet, so just mark the existing features // for future modification, by creating one mega container feature result.add(new TransformableFeature(this.name, extracted)); } return result; }
public List<Feature> extract(JCas view, T focusAnnotation) throws CleartkExtractorException { List<Feature> features = subExtractor.extract(view, focusAnnotation); for (Feature feature : features) { feature.setName(Feature.createName(name, feature.getName())); } return features; }
public List<Feature> extract(JCas jCas, TreebankNode node) throws CleartkExtractorException { TreebankNode parent = node.getParent(); if (parent == null) return Collections.emptyList(); List<Feature> features = subExtractor.extract(jCas, parent); for (Feature feature : features) { feature.setName(Feature.createName("Parent", feature.getName())); } return features; }
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { for (Time time : JCasUtil.select(jCas, Time.class)) { List<Feature> features = new ArrayList<Feature>(); for (FeatureExtractor1<Time> extractor : this.featuresExtractors) { features.addAll(extractor.extract(jCas, time)); } if (this.isTraining()) { this.dataWriter.write(new Instance<String>(time.getTimeType(), features)); } else { time.setTimeType(this.classifier.classify(features)); } } }