public SubCategorizationExtractor(String name) { this.featureName = Feature.createName(name, "SubCategorization"); }
public Context_ImplBase(int begin, int end) { if (begin > end) { String message = "expected begin < end, found begin=%d end=%d"; throw new IllegalArgumentException(String.format(message, begin, end)); } this.begin = begin; this.end = end; this.name = Feature.createName( this.getClass().getSimpleName(), String.valueOf(this.begin), String.valueOf(this.end)); }
public AbstractWindowedContext( int begin, int end ) { if ( begin > end ) { String message = "expected begin < end, found begin=%d end=%d"; throw new IllegalArgumentException( String.format( message, begin, end ) ); } else { this.begin = begin; this.end = end; this.name = Feature.createName( this.getClass().getSimpleName(), String.valueOf( this.begin ), String.valueOf( this.end ) ); } }
public ContinuousBag(File vecFile, Context... contexts) throws FileNotFoundException { this.contexts = contexts; this.vectors = readVectorFile(vecFile); // String[] names = new String[contexts.length + 1]; // names[0] = "ContinuousBag"; // for (int i = 1; i < names.length; ++i) { // names[i] = contexts[i - 1].getName(); // } this.name = Feature.createName("ContinuousBag"); }
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 ContinuousBag(File vecFile, Context... contexts) throws FileNotFoundException { this.contexts = contexts; this.vectors = readVectorFile(vecFile); // String[] names = new String[contexts.length + 1]; // names[0] = "ContinuousBag"; // for (int i = 1; i < names.length; ++i) { // names[i] = contexts[i - 1].getName(); // } this.name = Feature.createName("ContinuousBag"); }
public static Feature createFeature(String namePrefix, Feature feature) { return new Feature(createName(namePrefix, feature.name), feature.value); }
@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(); }
@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 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<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<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 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 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()) { if (frequencies.getCount(key) > 0) { String name = Feature.createName(prefix, key.toString()); NameNumber fve = new NameNumber(name, 1); fves.add(fve); } } normalizer.normalize(fves); return fves; }
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 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() ); }