private List<Feature> extract(JCas view, Annotation focusAnnotation, Bounds bounds) throws CleartkExtractorException { List<Feature> features = new ArrayList<Feature>(); for (Context context : this.contexts) { features.addAll(context.extract( view, focusAnnotation, bounds, this.annotationClass, this.extractor)); } return features; }
List<Feature> extractedFeatures = new ArrayList<Feature>(); for (Context context : this.contexts) { extractedFeatures.addAll(context.extract( jCas, focusAnnotation,
public <SEARCH_T extends Annotation> List<Feature> extract(JCas jCas, Annotation focusAnnotation, Bounds bounds, Class<SEARCH_T> annotationClass, FeatureExtractor1<SEARCH_T> extractor) throws CleartkExtractorException { LinkedHashMap<String,Double> runningTotals = new LinkedHashMap<>(); for (Context context : this.contexts) { for (Feature feature : context.extract( jCas, focusAnnotation, bounds, annotationClass, extractor)) { try{ double val = Double.parseDouble(feature.getValue().toString()); if(!runningTotals.containsKey(feature.getName())){ runningTotals.put(feature.getName(), 0.0); } runningTotals.put(feature.getName(), runningTotals.get(feature.getName()) + val); }catch(Exception e){ // just ignore this feature? } } } List<Feature> features = new ArrayList<>(); for(String key : runningTotals.keySet()){ features.add(new Feature(this.name + "_" + key, runningTotals.get(key))); } return features; }
Map<String, Feature> featureMap = new HashMap<String, Feature>(); for (Context context : this.contexts) { for (Feature feature : context.extract( jCas, focusAnnotation,
public <SEARCH_T extends Annotation> List<Feature> extract(JCas jCas, Annotation focusAnnotation, Bounds bounds, Class<SEARCH_T> annotationClass, FeatureExtractor1<SEARCH_T> extractor) throws CleartkExtractorException { LinkedHashMap<String,Double> runningTotals = new LinkedHashMap<>(); for (Context context : this.contexts) { for (Feature feature : context.extract( jCas, focusAnnotation, bounds, annotationClass, extractor)) { try{ double val = Double.parseDouble(feature.getValue().toString()); if(!runningTotals.containsKey(feature.getName())){ runningTotals.put(feature.getName(), 0.0); } runningTotals.put(feature.getName(), runningTotals.get(feature.getName()) + val); }catch(Exception e){ // just ignore this feature? } } } List<Feature> features = new ArrayList<>(); for(String key : runningTotals.keySet()){ features.add(new Feature(this.name + "_" + key, runningTotals.get(key))); } return features; }
public <SEARCH_T extends Annotation> List<Feature> extract(JCas jCas, Annotation focusAnnotation, Bounds bounds, Class<SEARCH_T> annotationClass, FeatureExtractor1<SEARCH_T> extractor) throws CleartkExtractorException { HashMap<String,Double> runningTotals = new HashMap<>(); for (Context context : this.contexts) { for (Feature feature : context.extract( jCas, focusAnnotation, bounds, annotationClass, extractor)) { try{ double val = Double.parseDouble(feature.getValue().toString()); if(!runningTotals.containsKey(feature.getName())){ runningTotals.put(feature.getName(), 0.0); } runningTotals.put(feature.getName(), Double.max(runningTotals.get(feature.getName()), val)); }catch(Exception e){ // just ignore this feature? } } } List<Feature> features = new ArrayList<>(); for(String key : runningTotals.keySet()){ features.add(new Feature(this.name + "_" + key, runningTotals.get(key))); } return features; }
public <SEARCH_T extends Annotation> List<Feature> extract(JCas jCas, Annotation focusAnnotation, Bounds bounds, Class<SEARCH_T> annotationClass, FeatureExtractor1<SEARCH_T> extractor) throws CleartkExtractorException { HashMap<String,Double> runningTotals = new HashMap<>(); for (Context context : this.contexts) { for (Feature feature : context.extract( jCas, focusAnnotation, bounds, annotationClass, extractor)) { try{ double val = Double.parseDouble(feature.getValue().toString()); if(!runningTotals.containsKey(feature.getName())){ runningTotals.put(feature.getName(), 0.0); } runningTotals.put(feature.getName(), Double.max(runningTotals.get(feature.getName()), val)); }catch(Exception e){ // just ignore this feature? } } } List<Feature> features = new ArrayList<>(); for(String key : runningTotals.keySet()){ features.add(new Feature(this.name + "_" + key, runningTotals.get(key))); } 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 { String featureName = extractor instanceof NamedFeatureExtractor1 ? ((NamedFeatureExtractor1<SEARCH_T>) extractor).getFeatureName() : null; List<String> values = new ArrayList<String>(); for (Context context : this.contexts) { for (Feature feature : context.extract( jCas, focusAnnotation, bounds, annotationClass, extractor)) { values.add(String.valueOf(feature.getValue())); } } Feature feature = new Feature(featureName, Joiner.on('_').join(values)); List<Feature> features = new ArrayList<Feature>(); features.add(new ContextFeature(this.getName(), feature)); return features; } }
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> feats = new ArrayList<>(); for (Context context : this.contexts) { double[] contextVec = new double[dims]; int numComponents = 0; for (Feature feature : context.extract( jCas, focusAnnotation, bounds, annotationClass, extractor)) { if(this.vectors.containsKey(feature.getValue())){ double[] featVec = this.vectors.get(feature.getValue().toString().toLowerCase()); addToVector(contextVec, featVec); numComponents++; } } if(numComponents > 0){ for(int i = 0; i < dims; i++){ feats.add(new Feature(Feature.createName(this.name, context.getName(), String.valueOf(i)), contextVec[i] / numComponents)); } } } return feats; }
public <SEARCH_T extends Annotation> List<Feature> extract(JCas jCas, Annotation focusAnnotation, Bounds bounds, Class<SEARCH_T> annotationClass, FeatureExtractor1<SEARCH_T> extractor) throws CleartkExtractorException { HashMap<String,Double> runningTotals = new HashMap<>(); for (Context context : this.contexts) { for (Feature feature : context.extract( jCas, focusAnnotation, bounds, annotationClass, extractor)) { try{ double val = Double.parseDouble(feature.getValue().toString()); if(!runningTotals.containsKey(feature.getName())){ runningTotals.put(feature.getName(), 0.0); } runningTotals.put(feature.getName(), Double.min(runningTotals.get(feature.getName()), val)); }catch(Exception e){ // just ignore this feature? } } } List<Feature> features = new ArrayList<>(); for(String key : runningTotals.keySet()){ features.add(new Feature(this.name + "_" + key, runningTotals.get(key))); } return features; }
public <SEARCH_T extends Annotation> List<Feature> extract(JCas jCas, Annotation focusAnnotation, Bounds bounds, Class<SEARCH_T> annotationClass, FeatureExtractor1<SEARCH_T> extractor) throws CleartkExtractorException { HashMap<String,Double> runningTotals = new HashMap<>(); for (Context context : this.contexts) { for (Feature feature : context.extract( jCas, focusAnnotation, bounds, annotationClass, extractor)) { try{ double val = Double.parseDouble(feature.getValue().toString()); if(!runningTotals.containsKey(feature.getName())){ runningTotals.put(feature.getName(), 0.0); } runningTotals.put(feature.getName(), Double.min(runningTotals.get(feature.getName()), val)); }catch(Exception e){ // just ignore this feature? } } } List<Feature> features = new ArrayList<>(); for(String key : runningTotals.keySet()){ features.add(new Feature(this.name + "_" + key, runningTotals.get(key))); } return features; }
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> feats = new ArrayList<>(); for (Context context : this.contexts) { double[] contextVec = new double[dims]; int numComponents = 0; for (Feature feature : context.extract( jCas, focusAnnotation, bounds, annotationClass, extractor)) { if(this.vectors.containsKey(feature.getValue())){ double[] featVec = this.vectors.get(feature.getValue().toString().toLowerCase()); addToVector(contextVec, featVec); numComponents++; } } if(numComponents > 0){ for(int i = 0; i < dims; i++){ feats.add(new Feature(Feature.createName(this.name, context.getName(), String.valueOf(i)), contextVec[i] / numComponents)); } } } 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 (Context context : this.contexts) { for (Feature feature : context.extract( jCas, focusAnnotation, bounds, annotationClass, extractor)) { ContextFeature contextFeature = (ContextFeature) feature; Feature f2 = new Feature(contextFeature.feature.getName(), feature.getValue()); features.add(new ContextFeature(this.getName(), f2)); } } return features; } }
@Override public <SEARCH_T extends Annotation> List<Feature> extract( JCas jCas, Annotation focusAnnotation, CleartkExtractor.Bounds bounds, Class<SEARCH_T> annotationClass, FeatureExtractor1<SEARCH_T> extractor ) throws CleartkExtractorException { List<Feature> features = new ArrayList<>(); for ( CleartkExtractor.Context context : this.contexts ) { for ( Feature feature : context.extract( jCas, focusAnnotation, bounds, annotationClass, extractor ) ) { WindowedContextFeature contextFeature = (WindowedContextFeature)feature; Feature f2 = new Feature( contextFeature.feature.getName(), feature.getValue() ); features.add( new WindowedContextFeature( this.getName(), f2 ) ); } } return features; }