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; }
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)); }
public List<NameNumber> encode(Feature feature) { String name = feature.getName(); Number number = (Number) feature.getValue(); return Collections.singletonList(new NameNumber(name, number)); }
public ContextFeature(String baseName, int position, int oobPosition, String featureName) { this.feature = new Feature(featureName, String.format(Locale.ROOT, "OOB%d", oobPosition)); this.setName(Feature.createName(baseName, String.valueOf(position), featureName)); this.setValue(this.feature.getValue()); }
public WindowedContextFeature( String baseName, int position, int oobPosition, String featureName ) { this.feature = new Feature( featureName, String.format( Locale.ROOT, "OOB%d", oobPosition ) ); this.setName( Feature.createName( baseName, String.valueOf( position ), featureName ) ); this.setValue( this.feature.getValue() ); }
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<NameNumber> encode(Feature feature) { List<NameNumber> fves = new ArrayList<NameNumber>(); Counts frequencies = (Counts) feature.getValue(); String prefix = frequencies.getFeatureName(); for (Object key : frequencies.getValues()) { String name = Feature.createName(prefix, key.toString()); NameNumber fve = new NameNumber(name, frequencies.getCount(key)); fves.add(fve); } normalizer.normalize(fves); return fves; }
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() ); }
@Override protected Feature transform(Feature feature) { int tf = (Integer) feature.getValue(); double tfidf = tf * this.idfMap.getIDF(feature.getName()); return new Feature("TF-IDF_" + feature.getName(), tfidf); }
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() ); }