当前位置: 首页>>代码示例>>Java>>正文


Java Feature.getValue方法代码示例

本文整理汇总了Java中org.cleartk.ml.Feature.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Feature.getValue方法的具体用法?Java Feature.getValue怎么用?Java Feature.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.cleartk.ml.Feature的用法示例。


在下文中一共展示了Feature.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
/**
 * @return will return an empty list if the value of the feature is not a StringValue or is not as
 *         long as the minimumValueLength.
 */
@Override
public List<Feature> apply(Feature feature) {
  String featureName = Feature.createName(name, feature.getName());
  Object featureValue = feature.getValue();
  if (featureValue == null || !(featureValue instanceof String))
    return Collections.emptyList();

  String value = featureValue.toString();
  if (value == null || value.length() < minimumValueLength)
    return Collections.emptyList();

  String ngram;
  if (orientation == Orientation.LEFT_TO_RIGHT) {
    ngram = value.substring(start, end);
  } else {
    ngram = value.substring(value.length() - end, value.length() - start);
  }
  if (lowerCase)
    ngram = ngram.toLowerCase();

  return Collections.singletonList(new Feature(featureName, ngram));
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:27,代码来源:CharacterNgramFeatureFunction.java

示例2: extract

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
@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;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:23,代码来源:CleartkExtractor.java

示例3: apply

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
@Override
public List<Feature> apply(Feature feature)
{
    Object featureValue = feature.getValue();
    try {
        if (featureValue == null) {
            return Collections.singletonList(new Feature("Position", -1));
        }
        int k = PositionFeature.posistion.remove();

        String value = featureValue.toString();
        if (value == null || value.length() == 0) {
            return Collections.emptyList();
        }

        return Collections.singletonList(new Feature("Position", Integer.toString(k)));
    }
    catch (Exception e) {
        return Collections.singletonList(new Feature("Position", -1));
    }
}
 
开发者ID:tudarmstadt-lt,项目名称:GermaNER,代码行数:22,代码来源:PositionFeatureExtractor.java

示例4: apply

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
/**
 * @return will return an empty list if the value of the feature is not a StringValue or is not as
 *         long as the minimumValueLength.
 */
@Override
public List<Feature> apply(Feature feature) {
  String featureName = Feature.createName(name, feature.getName());
  Object featureValue = feature.getValue();
  if (featureValue == null || !(featureValue instanceof String)) {
      return Collections.singletonList(new Feature(featureName, "OUT"));
  }

  String value = featureValue.toString();
  if (value == null || value.length() < minimumValueLength) {
      return Collections.singletonList(new Feature(featureName, "OUT"));
  }

  String ngram;
  if (orientation == Orientation.LEFT_TO_RIGHT) {
    ngram = value.substring(start, end);
  } else {
    ngram = value.substring(value.length() - end, value.length() - start);
  }
  if (lowerCase) {
      ngram = ngram.toLowerCase();
  }

  return Collections.singletonList(new Feature(featureName, ngram));
}
 
开发者ID:tudarmstadt-lt,项目名称:GermaNER,代码行数:30,代码来源:LTCharacterNgramFeatureFunction.java

示例5: encode

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
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;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:18,代码来源:BagEncoder.java

示例6: encode

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
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;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:17,代码来源:FeatureCollectionEncoder.java

示例7: encodeAll

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
@Override
public TreeFeatureVector encodeAll(Iterable<Feature> features) throws CleartkEncoderException {
  List<Feature> fves = new ArrayList<Feature>();
  LinkedHashMap<String, TreeFeature> trs = new LinkedHashMap<String, TreeFeature>();
  for (Feature feature : features) {
    if (feature instanceof TreeFeature){
      trs.put(feature.getName(), (TreeFeature) feature);
    } else if (feature.getName() != null && feature.getName().matches("^TK.*")) {
      TreeFeature tf = new TreeFeature(feature.getName(), feature.getValue());
      trs.put(feature.getName(), tf);
    } else {
      fves.add(feature);
    }
  }
  FeatureVector f = nameNumberEncoder.encodeAll(fves);
  TreeFeatureVector tfv = new TreeFeatureVector();
  tfv.setFeatures(f);
  tfv.setTrees(trs);
  return tfv;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:21,代码来源:TreeFeatureVectorFeaturesEncoder.java

示例8: apply

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
@Override
public List<Feature> apply(Feature feature) {
    if (feature == null || feature.getValue() == null)
        throw new IllegalArgumentException("Feature must not be null and has to have an non-empty value!");
    try {
        if (this.namedEntitiesDict == null)
            this.generateDictionary();
        String featureValue = feature.getValue().toString().toLowerCase();
        return namedEntitiesDict.contains(featureValue) ? Collections.singletonList(new Feature("NamedEntityList<" + neListName + ">", this.featureName)) : Collections.emptyList();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:floschne,项目名称:NLP_ProjectNER,代码行数:15,代码来源:NEListExtractor.java

示例9: apply

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
/**
 * @return if the value of the feature is a String, then the lower cased version of that value is
 *         used for the returned feature. Otherwise, an empty list is returned.
 */
@Override
public List<Feature> apply(Feature feature) {
  String featureName = Feature.createName(DEFAULT_NAME, feature.getName());
  Object featureValue = feature.getValue();
  if (featureValue instanceof String) {
    return Collections.singletonList(new Feature(
        featureName,
        featureValue.toString().toLowerCase()));
  } else
    return Collections.emptyList();
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:16,代码来源:LowerCaseFeatureFunction.java

示例10: apply

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
/**
 * If the value of the feature is a StringValue and is determined to be one of ALL_UPPERCASE,
 * ALL_LOWERCASE, INITIAL_UPPERCASE, or MIXED_CASE, then a new feature containing one of those
 * four values is returned. If the value of the feature cannot be characterized by one of these
 * four values, then the empty list is returned (e.g. the value is an empty string, contains only
 * white space, or contains only digits, etc.)
 * 
 * <P>
 * This method was inspired by CapitalizationTypeTagger.py written by Steven Bethard.
 * 
 * @return a feature that has a value that is one of ALL_UPPERCASE, ALL_LOWERCASE,
 *         INITIAL_UPPERCASE, or MIXED_CASE. Otherwise the empty list is returned.
 */
public List<Feature> apply(Feature feature) {
  String featureName = Feature.createName(DEFAULT_NAME, feature.getName());
  Object featureValue = feature.getValue();
  if (featureValue == null)
    return Collections.emptyList();
  else if (featureValue instanceof String) {
    String value = featureValue.toString();
    if (value == null || value.length() == 0)
      return Collections.emptyList();

    String lowerCaseValue = value.toLowerCase();
    String upperCaseValue = value.toUpperCase();
    if (lowerCaseValue.equals(upperCaseValue))
      return Collections.emptyList();

    if (value.equals(value.toLowerCase())) {
      return Collections.singletonList(new Feature(
          featureName,
          CapitalType.ALL_LOWERCASE.toString()));
    } else if (value.equals(value.toUpperCase())) {
      return Collections.singletonList(new Feature(
          featureName,
          CapitalType.ALL_UPPERCASE.toString()));
    }

    if (CaseUtil.isInitialUppercase(value)) {
      return Collections.singletonList(new Feature(
          featureName,
          CapitalType.INITIAL_UPPERCASE.toString()));
    }

    return Collections.singletonList(new Feature(featureName, CapitalType.MIXED_CASE.toString()));
  } else
    return Collections.emptyList();
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:49,代码来源:CapitalTypeFeatureFunction.java

示例11: featuresToFeatureMap

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
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;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:10,代码来源:CentroidTfidfSimilarityExtractor.java

示例12: computeCentroid

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
protected Map<String, Double> computeCentroid(Iterable<Instance<OUTCOME_T>> instances, IDFMap idfs) {

    // Now compute centroid of all applicable terms (features) in all instances
    int numDocuments = idfs.getTotalDocumentCount();
    Map<String, Double> newCentroidMap = new HashMap<String, Double>();
    for (Instance<OUTCOME_T> instance : instances) {

      // Grab the matching tf*idf features from the set of all features in an instance
      for (Feature feature : instance.getFeatures()) {
        if (this.isTransformable(feature)) {
          // tf*idf features contain a list of features, these are actually what get added
          // to our document frequency map
          for (Feature untransformedFeature : ((TransformableFeature) feature).getFeatures()) {
            String termName = untransformedFeature.getName();
            int tf = (Integer) untransformedFeature.getValue();
            double tfidf = tf * idfs.getIDF(termName);
            double sumTfidf = (newCentroidMap.containsKey(termName))
                ? sumTfidf = newCentroidMap.get(termName)
                : 0.0;
            newCentroidMap.put(termName, sumTfidf + tfidf);
          }
        }
      }
    }

    for (Map.Entry<String, Double> entry : newCentroidMap.entrySet()) {
      double mean = entry.getValue() / numDocuments;
      newCentroidMap.put(entry.getKey(), mean);
    }
    return newCentroidMap;
  }
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:32,代码来源:CentroidTfidfSimilarityExtractor.java

示例13: apply

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
@Override
public List<Feature> apply(Feature feature) {
  String featureName = Feature.createName(DEFAULT_NAME, feature.getName());
  Object featureValue = feature.getValue();
  if (featureValue == null)
    return Collections.emptyList();
  else if (featureValue instanceof String) {
    String value = featureValue.toString();
    if (value == null || value.length() == 0)
      return Collections.emptyList();
    if (HyphenUtil.containsHyphen(value))
      return Collections.singletonList(new Feature(featureName, CONTAINS_HYPHEN));
  }
  return Collections.emptyList();
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:16,代码来源:ContainsHyphenFeatureFunction.java

示例14: apply

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
/**
 * If the value of the feature is a StringValue and is determined to be one of DIGITS,
 * YEAR_DIGITS, ALPHANUMERIC, SOME_DIGITS, or ROMAN_NUMERAL, then a feature containing one of
 * those five values is returned. If the value of the feature cannot be characterized by one of
 * these five values, then an empty list is returned (e.g. the value is an empty string, contains
 * only white space, or contains only letters, etc.)
 * 
 * <p>
 * This method draws heavily from NumericTypeTagger.py written by Steven Bethard. That code
 * credits <a href="http://diveintopython.org/unit_testing/stage_5.html">Dive Into Python</a> for
 * the regular expression for matching roman numerals.
 * 
 * @return a feature that has a value that is one of DIGITS, YEAR_DIGITS, ALPHANUMERIC,
 *         SOME_DIGITS, or ROMAN_NUMERAL. Otherwise an empty list is returned.
 */

@Override
public List<Feature> apply(Feature feature) {
  String featureName = Feature.createName(DEFAULT_NAME, feature.getName());
  Object featureValue = feature.getValue();
  if (featureValue == null)
    return Collections.emptyList();
  else if (featureValue instanceof String) {
    String value = featureValue.toString();
    if (value == null || value.length() == 0)
      return Collections.emptyList();

    if (NumericTypeUtil.isDigits(value)) {
      if (yearDigitsPattern.matcher(value).matches()) {
        return Collections.singletonList(new Feature(
            featureName,
            NumericType.YEAR_DIGITS.toString()));
      } else
        return Collections.singletonList(new Feature(featureName, NumericType.DIGITS.toString()));
    } else if (NumericTypeUtil.containsDigits(value)) {
      if (alphanumericPattern.matcher(value).matches() && someLetters.matcher(value).find()) {
        return Collections.singletonList(new Feature(
            featureName,
            NumericType.ALPHANUMERIC.toString()));
      } else
        return Collections.singletonList(new Feature(
            featureName,
            NumericType.SOME_DIGITS.toString()));
    } else if (romanNumeralPattern.matcher(value).matches()) {
      return Collections.singletonList(new Feature(
          featureName,
          NumericType.ROMAN_NUMERAL.toString()));
    }
  }
  return Collections.emptyList();
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:52,代码来源:NumericTypeFeatureFunction.java

示例15: encodes

import org.cleartk.ml.Feature; //导入方法依赖的package包/类
public boolean encodes(Feature feature) {
  if (!(feature.getValue() instanceof Counts))
    return false;

  Counts counts = (Counts) feature.getValue();

  if (identifier == null)
    return true;

  if (identifier.equals(counts.getIdentifier()))
    return true;

  return false;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:15,代码来源:BagEncoder.java


注:本文中的org.cleartk.ml.Feature.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。