org.dkpro.tc.api.features.Feature.<init>()方法的使用及代码示例

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

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

Feature.<init>介绍

[英]Creates a feature that is aware if the value is a default value. This information is used when filling the feature store. A sparse feature store would not add a feature if it is a default value i.e. means a feature is not set
[中]创建一个可以识别该值是否为默认值的特征。填充功能存储时使用此信息。如果稀疏要素存储是默认值,即表示未设置要素,则不会添加要素

代码示例

代码示例来源:origin: de.unidue.ltl.flextag/flextag-features

public Set<Feature> extract(JCas aView, TextClassificationTarget aTarget)
    throws TextClassificationException
  {

    Feature feature = new Feature(FEATURE_NAME, aTarget.getCoveredText().contains(
        "-") ? 1 : 0);
    Set<Feature> features = new HashSet<Feature>();
    features.add(feature);
    return features;
  }
}

代码示例来源:origin: de.unidue.ltl.flextag/flextag-features

public Set<Feature> extract(JCas aView, TextClassificationTarget aTarget)
  throws TextClassificationException
{
  Feature feature = new Feature(FEATURE_NAME, aTarget.getCoveredText().contains(
      ".") ? 1 : 0);
  Set<Feature> features = new HashSet<Feature>();
  features.add(feature);
  return features;
}

代码示例来源:origin: de.unidue.ltl.flextag/flextag-features

public Set<Feature> extract(JCas aView, TextClassificationTarget aTarget)
  throws TextClassificationException
{
  Feature feature = new Feature(FEATURE_NAME, aTarget.getCoveredText().contains(
      "_") ? 1 : 0);
  Set<Feature> features = new HashSet<Feature>();
  features.add(feature);
  return features;
}

代码示例来源:origin: dkpro/dkpro-tc

@Override
public Set<Feature> extract(JCas view1, JCas view2) throws TextClassificationException
{
  return new Feature("BaselineFeature", 0, FeatureType.NUMERIC).asSet();
}

代码示例来源:origin: dkpro/dkpro-tc

public static Feature retrieve(JCas jcas) throws TextClassificationException
{
  String fullId = getFullId(jcas);
  return new Feature(ID_FEATURE_NAME, fullId, FeatureType.STRING);
};

代码示例来源:origin: de.unidue.ltl.flextag/flextag-features

public Set<Feature> extract(JCas aView, TextClassificationTarget aTarget)
  throws TextClassificationException
{
  String text = aTarget.getCoveredText();
  boolean isRetweet = isRetweet(text);
  Feature feature = new Feature(FEATURE_NAME, isRetweet ? 1 : 0);
  Set<Feature> features = new HashSet<Feature>();
  features.add(feature);
  return features;
}

代码示例来源:origin: de.unidue.ltl.flextag/flextag-features

public Set<Feature> extract(JCas aView, TextClassificationTarget aTarget)
  throws TextClassificationException
{
  String text = aTarget.getCoveredText();
  boolean isUserMention = isUserMention(text);
  Feature feature = new Feature(FEATURE_NAME, isUserMention ? 1 : 0);
  Set<Feature> features = new HashSet<Feature>();
  features.add(feature);
  return features;
}

代码示例来源:origin: de.unidue.ltl.flextag/flextag-features

public Set<Feature> extract(JCas aView, TextClassificationTarget aTarget)
  throws TextClassificationException
{
  String text = aTarget.getCoveredText();
  boolean containsComma = containsComma(text);
  Feature feature = new Feature(FEATURE_NAME, containsComma ? 1 : 0);
  Set<Feature> features = new HashSet<Feature>();
  features.add(feature);
  return features;
}

代码示例来源:origin: de.unidue.ltl.flextag/flextag-features

public Set<Feature> extract(JCas aView, TextClassificationTarget aTarget)
  throws TextClassificationException
{
  String token = aTarget.getCoveredText();
  Feature feature = new Feature(FEATURE_NAME, isAllCapitalized(token) ? 1 : 0);
  Set<Feature> features = new HashSet<Feature>();
  features.add(feature);
  return features;
}

代码示例来源:origin: de.unidue.ltl.flextag/flextag-features

public Set<Feature> extract(JCas aView, TextClassificationTarget aTarget)
  throws TextClassificationException
{
  String token = aTarget.getCoveredText();
  boolean flc = firstLetterCapitalized(token);
  Feature feature = new Feature(FEATURE_NAME, flc ? 1 : 0);
  Set<Feature> features = new HashSet<Feature>();
  features.add(feature);
  return features;
}

代码示例来源:origin: org.dkpro.tc/dkpro-tc-features

@Override
  public Set<Feature> extract(JCas jCas, TextClassificationTarget aTarget)
    throws TextClassificationException
  {
    int nrOfEmoticons = JCasUtil.selectCovered(jCas, POS_EMO.class, aTarget).size();
    int nrOfTokens = JCasUtil.selectCovered(jCas, Token.class, aTarget).size();
    double ratio = (double) nrOfEmoticons / nrOfTokens;
    return new Feature(EmoticonRatio.class.getSimpleName(), ratio, FeatureType.NUMERIC).asSet();
  }
}

代码示例来源:origin: dkpro/dkpro-tc

@Override
public Set<Feature> extract(JCas view1, JCas view2) throws TextClassificationException
{
  if (normalizeWithFirst) {
    return new Feature("SharedNounChunkView1", getSharedNounChunksCount(view1, view2),
        FeatureType.NUMERIC).asSet();
  }
  else {
    return new Feature("SharedNounChunkView2", getSharedNounChunksCount(view2, view1),
        FeatureType.NUMERIC).asSet();
  }
}

代码示例来源:origin: org.dkpro.tc/dkpro-tc-core

public static Feature retrieve(JCas jcas, TextClassificationTarget unit)
  throws TextClassificationException
{
  String fullId = getFullId(jcas);
  fullId = fullId + "_" + unit.getId();
  String suffix = unit.getSuffix();
  if (suffix != null && suffix.length() > 0) {
    fullId = fullId + "_" + suffix;
  }
  return new Feature(ID_FEATURE_NAME, fullId, FeatureType.STRING);
};

代码示例来源:origin: org.dkpro.tc/dkpro-tc-core

public static Feature retrieve(JCas jcas, TextClassificationTarget unit, Integer sequenceId)
  throws TextClassificationException
{
  String fullId = getFullId(jcas);
  fullId = fullId + "_" + sequenceId;
  fullId = fullId + "_" + unit.getId();
  String suffix = unit.getSuffix();
  if (suffix != null && suffix.length() > 0) {
    fullId = fullId + "_" + suffix;
  }
  return new Feature(ID_FEATURE_NAME, fullId, FeatureType.STRING);
};

代码示例来源:origin: dkpro/dkpro-tc

public static Feature retrieve(JCas jcas, TextClassificationTarget unit, Integer sequenceId)
  throws TextClassificationException
{
  String fullId = getFullId(jcas);
  fullId = fullId + "_" + sequenceId;
  fullId = fullId + "_" + unit.getId();
  String suffix = unit.getSuffix();
  if (suffix != null && suffix.length() > 0) {
    fullId = fullId + "_" + suffix;
  }
  return new Feature(ID_FEATURE_NAME, fullId, FeatureType.STRING);
};

代码示例来源:origin: dkpro/dkpro-tc

@Override
public Set<Feature> extract(JCas jcas, TextClassificationTarget aTarget)
  throws TextClassificationException
{
  long maxLen = getMax();
  List<Sentence> sentences = JCasUtil.selectCovered(jcas, Sentence.class, aTarget);
  double ratio = getRatio(sentences.size(), maxLen);
  return new Feature(FEATURE_NAME, ratio, FeatureType.NUMERIC).asSet();
}

代码示例来源:origin: dkpro/dkpro-tc

@Override
public Set<Feature> extract(JCas view1, JCas view2) throws TextClassificationException
{
  return new Feature("DiffNounPhraseTokenLength",
      getAverageNounPhraseTokenLength(view1) - getAverageNounPhraseTokenLength(view2),
      FeatureType.NUMERIC).asSet();
}

代码示例来源:origin: dkpro/dkpro-tc

@Override
public Set<Feature> extract(JCas view1, JCas view2) throws TextClassificationException
{
  return new Feature("DiffNounPhraseCharacterLength",
      getAverageNounPhraseCharacterLength(view1)
          - getAverageNounPhraseCharacterLength(view2),
      FeatureType.NUMERIC).asSet();
}

代码示例来源:origin: org.dkpro.tc/dkpro-tc-features

public Set<Feature> extract(JCas aView, TextClassificationTarget unit)
  throws TextClassificationException
{
  super.extract(aView, unit);
  Integer currentTargetIdx = super.unitBegin2Idx.get(unit.getBegin());
  Integer targetIdx = currentTargetIdx + shiftIdx;
  String featureVal = getTargetText(targetIdx);
  return new Feature(FEATURE_NAME + toHumanReadable(shiftIdx), featureVal,
      FeatureType.NUMERIC).asSet();
}

代码示例来源:origin: dkpro/dkpro-tc

public Set<Feature> extract(JCas aView, TextClassificationTarget target)
  throws TextClassificationException
{
  super.extract(aView, target);
  Integer currentTargetIdx = super.targetBegin2Idx.get(target.getBegin());
  Integer targetIdx = currentTargetIdx + shiftIdx;
  String featureVal = getTargetText(targetIdx);
  return new Feature(FEATURE_NAME + toHumanReadable(shiftIdx), featureVal,
      FeatureType.STRING).asSet();
}

相关文章