org.cleartk.ml.Feature类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中org.cleartk.ml.Feature类的一些代码示例,展示了Feature类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Feature类的具体详情如下:
包路径:org.cleartk.ml.Feature
类名称:Feature

Feature介绍

[英]Copyright (c) 2007-2008, Regents of the University of Colorado
All rights reserved.
[中]版权所有(C)2007-2008,科罗拉多大学摄政王
版权所有。

代码示例

代码示例来源:origin: org.apache.ctakes/ctakes-assertion

@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();
}

代码示例来源:origin: ClearTK/cleartk

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;
}

代码示例来源:origin: de.unistuttgart.ims/cleartk-util

public List<Feature> extract(JCas view, T focusAnnotation) throws CleartkExtractorException {
  Feature f = new Feature();
  int c = JCasUtil.selectCovered(goalClass, focusAnnotation).size();
  f.setValue(c);
  f.setName("count-" + goalClass.getSimpleName() + "-" + c);
  return Arrays.asList(f);
}

代码示例来源:origin: org.apache.ctakes/ctakes-assertion

protected String getFeatureName(Feature feature) {
 String featureName = feature.getName();
 Object featureValue = feature.getValue();
 return featureValue instanceof Number ? featureName : featureName + ":" + featureValue;
}

代码示例来源:origin: ClearTK/cleartk

public static Feature createFeature(String namePrefix, Feature feature) {
 return new Feature(createName(namePrefix, feature.name), feature.value);
}

代码示例来源:origin: ClearTK/cleartk

@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);
}

代码示例来源:origin: apache/ctakes

@Override
public FeatureNode[] encodeAll(Iterable<Feature> features) throws CleartkEncoderException {
 FeatureNode[] encoded = encoder.encodeAll(features);
 for(Feature feature : features){
  String name;
  if(feature.getValue() instanceof Number) {
   name = feature.getName();
  } else {
   name = Feature.createName(new String[]{feature.getName(), feature.getValue().toString()});
  }
  featureNames.add(name);
 }
 return encoded;
}

代码示例来源:origin: org.apache.ctakes/ctakes-core

public static List<Feature> getCharFeatures(char ch, String prefix){
 List<Feature> feats = new ArrayList<>();
 feats.add(new Feature(prefix+"_Id", ch == '\n' ? "<LF>" : ch));
 feats.add(new Feature(prefix+"_Upper", Character.isUpperCase(ch)));
 feats.add(new Feature(prefix+"_Lower", Character.isLowerCase(ch)));
 feats.add(new Feature(prefix+"_Digit", Character.isDigit(ch)));
 feats.add(new Feature(prefix+"_Space", Character.isWhitespace(ch)));
 feats.add(new Feature(prefix+"_Type"+Character.getType(ch), true));
 return feats;
}

代码示例来源:origin: ClearTK/cleartk

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());
}

代码示例来源:origin: ClearTK/cleartk

public boolean encodes(Feature feature) {
 return feature.getValue() instanceof Boolean;
}

代码示例来源:origin: ClearTK/cleartk

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;
}

代码示例来源:origin: ClearTK/cleartk

public SubCategorizationExtractor(String name) {
 this.featureName = Feature.createName(name, "SubCategorization");
}

代码示例来源:origin: ClearTK/cleartk

protected boolean isTransformable(Feature feature) {
 return feature instanceof TransformableFeature && this.name.equals(feature.getName());
}

代码示例来源:origin: ClearTK/cleartk

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());
 }
}

代码示例来源:origin: ClearTK/cleartk

/**
 * @param outcome
 *          the outcome of the returned instance
 * @param featureData
 *          space delimited features. Here the features only have names (no values) corresponding
 *          to the space delimited strings.
 * @return a single instance with the provided outcome and name-only string features found in the
 *         provided featureData
 */
public static <T> Instance<T> createInstance(T outcome, String featureData) {
 Instance<T> instance = new Instance<T>(outcome);
 String[] columns = featureData.split(" ");
 for (int i = 0; i < columns.length; i++) {
  Feature feature = new Feature();
  feature.setName(columns[i]);
  instance.add(feature);
 }
 return instance;
}

代码示例来源:origin: ClearTK/cleartk

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;
}

代码示例来源:origin: ClearTK/cleartk

@Override
protected Feature transform(Feature feature) {
 String featureName = feature.getName();
 MeanStddevTuple stats = this.meanStddevMap.get(featureName);
 double value = ((Number) feature.getValue()).doubleValue();
 double zmus = 0.0d;
 if (stats != null && stats.stddev > 0) {
  zmus = (value - stats.mean) / stats.stddev;
  return new Feature("ZMUS_" + featureName, zmus);
 } else {
  return null;
 }
}

代码示例来源:origin: ClearTK/cleartk

public String nameFeature(Feature feature) {
 return (feature.getValue() instanceof Number)
   ? feature.getName()
   : feature.getName() + ":" + feature.getValue();
}

代码示例来源:origin: ClearTK/cleartk

public ContextFeature(String baseName, Feature feature) {
 this.feature = feature;
 this.setName(Feature.createName(baseName, feature.getName()));
 this.setValue(this.feature.getValue());
}

代码示例来源:origin: apache/ctakes

public static List<Feature> getCharFeatures(char ch, String prefix){
 List<Feature> feats = new ArrayList<>();
 feats.add(new Feature(prefix+"_Id", ch == '\n' ? "<LF>" : ch));
 feats.add(new Feature(prefix+"_Upper", Character.isUpperCase(ch)));
 feats.add(new Feature(prefix+"_Lower", Character.isLowerCase(ch)));
 feats.add(new Feature(prefix+"_Digit", Character.isDigit(ch)));
 feats.add(new Feature(prefix+"_Space", Character.isWhitespace(ch)));
 feats.add(new Feature(prefix+"_Type"+Character.getType(ch), true));
 return feats;
}

相关文章