protected boolean isTransformable(Feature feature) { return feature instanceof TransformableFeature && this.name.equals(feature.getName()); }
@Override public Double apply(List<Feature> wordFeatures) { double sentenceWeight = 1.0; for (Feature feature : wordFeatures) { if (this.seenWords.contains(feature.getName())) { sentenceWeight *= this.seenWordProbability; } else { sentenceWeight *= this.tfMap.getProbability(feature.getName()); } } return sentenceWeight; } }
protected String getFeatureName(Feature feature) { String featureName = feature.getName(); Object featureValue = feature.getValue(); return featureValue instanceof Number ? featureName : featureName + ":" + featureValue; }
protected String getFeatureName(Feature feature) { String featureName = feature.getName(); Object featureValue = feature.getValue(); return featureValue instanceof Number ? featureName : featureName + ":" + featureValue; }
private String createName(boolean specialCasePP, Feature subFeature) { StringBuffer buffer = new StringBuffer(); if (specialCasePP) buffer.append("PP"); buffer.append("HeadWord"); return Feature.createName(buffer.toString(), subFeature.getName()); } }
public Map<String, Double> featuresToFeatureMap(List<Feature> features) { Map<String, Double> featureMap = new HashMap<String, Double>(); for (Feature feature : features) { String termName = feature.getName(); int tf = (Integer) feature.getValue(); featureMap.put(termName, tf * this.idfMap.getIDF(termName)); } return featureMap; }
@Override public List<Feature> apply(@Nullable Feature input) { String featureName = Feature.createName(DEFAULT_NAME, input.getName()); Object featureValue = input.getValue(); if(featureValue instanceof String){ return Collections.singletonList(new Feature(featureName, word2class.containsKey(featureValue) ? word2class.get(featureValue) : "NoCluster")); } return Collections.emptyList(); }
public List<NameNumber> encode(Feature feature) { String name = feature.getName(); Number number = ((Boolean) feature.getValue()).booleanValue() ? 1.0 : 0.0; return Collections.singletonList(new NameNumber(name, number)); }
@Override public List<Feature> apply(@Nullable Feature input) { String featureName = Feature.createName(DEFAULT_NAME, input.getName()); Object featureValue = input.getValue(); if(featureValue instanceof String){ return Collections.singletonList(new Feature(featureName, word2class.containsKey(featureValue) ? word2class.get(featureValue) : "NoCluster")); } return Collections.emptyList(); }
public List<NameNumber> encode(Feature feature) { String name = feature.getName(); Number number = (Number) feature.getValue(); return Collections.singletonList(new NameNumber(name, number)); }
public List<NameNumber> encode(Feature feature) throws CleartkEncoderException { FeatureCollection fc = (FeatureCollection) feature.getValue(); List<NameNumber> fves = new ArrayList<NameNumber>(); if (identifier != null && !identifier.equals(fc.getIdentifier())) return Collections.emptyList(); for (Feature f : fc.getFeatures()) { Feature f1 = new Feature(Feature.createName(feature.getName(), f.getName()), f.getValue()); fves.addAll(subEncoder.encode(f1)); } normalizer.normalize(fves); return fves; }
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; }
public ContextFeature(String baseName, int position, Feature feature) { this.feature = feature; this.setName(Feature.createName(baseName, String.valueOf(position), feature.getName())); this.setValue(feature.getValue()); }
public WindowedContextFeature( String baseName, int position, Feature feature ) { this.feature = feature; this.setName( Feature.createName( baseName, String.valueOf( position ), feature.getName() ) ); this.setValue( feature.getValue() ); }
public ContextFeature(String baseName, Feature feature) { this.feature = feature; this.setName(Feature.createName(baseName, feature.getName())); this.setValue(this.feature.getValue()); }
public WindowedContextFeature( String baseName, Feature feature ) { this.feature = feature; this.setName( Feature.createName( baseName, feature.getName() ) ); this.setValue( this.feature.getValue() ); }