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

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

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

Feature.asSet介绍

暂无

代码示例

代码示例来源: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

@Override
  public Set<Feature> extract(JCas view1, JCas view2) throws TextClassificationException
  {
    return new Feature("DiffNrOfTokens", JCasUtil.select(view1, Token.class).size()
        - JCasUtil.select(view2, Token.class).size(), FeatureType.NUMERIC).asSet();
  }
}

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

@Override
  public Set<Feature> extract(JCas view1, JCas view2) throws TextClassificationException
  {
    return new Feature("DiffNrOfSentences",
        JCasUtil.select(view1, Sentence.class).size()
            - JCasUtil.select(view2, Sentence.class).size(),
        FeatureType.NUMERIC).asSet();
  }
}

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

@Override
  public Set<Feature> extract(JCas jcas, TextClassificationTarget aTarget)
    throws TextClassificationException
  {
    String token = aTarget.getCoveredText();

    boolean bool = Character.isUpperCase(token.charAt(0));
    return new Feature(FEATURE_NAME, bool ? 1.0 : 0.0, bool == false, FeatureType.BOOLEAN)
        .asSet();
  }
}

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

@Override
  public Set<Feature> extract(JCas jcas, TextClassificationTarget aTarget)
    throws TextClassificationException
  {
    String token = aTarget.getCoveredText();

    boolean bool = Character.isUpperCase(token.charAt(0));
    return new Feature(FEATURE_NAME, bool ? 1.0 : 0.0, bool == false, FeatureType.BOOLEAN)
        .asSet();
  }
}

代码示例来源: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 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
  {
    return new Feature("DiffNrOfCharacters",
        view1.getDocumentText().length() - view2.getDocumentText().length(),
        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: dkpro/dkpro-tc

@Override
public Set<Feature> extract(JCas jCas, TextClassificationTarget aTarget)
  throws TextClassificationException
{
  Matcher hashTagMatcher = HASHTAG_PATTERN
      .matcher(jCas.getDocumentText().substring(aTarget.getBegin(), aTarget.getEnd()));
  int numberOfHashTags = 0;
  while (hashTagMatcher.find()) {
    numberOfHashTags++;
  }
  return new Feature(NumberOfHashTags.class.getSimpleName(), numberOfHashTags,
      FeatureType.NUMERIC).asSet();
}

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

@Override
public Set<Feature> extract(JCas jCas, TextClassificationTarget aTarget)
  throws TextClassificationException
{
  Matcher hashTagMatcher = HASHTAG_PATTERN
      .matcher(jCas.getDocumentText().substring(aTarget.getBegin(), aTarget.getEnd()));
  int numberOfHashTags = 0;
  while (hashTagMatcher.find()) {
    numberOfHashTags++;
  }
  return new Feature(NumberOfHashTags.class.getSimpleName(), numberOfHashTags,
      FeatureType.NUMERIC).asSet();
}

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

@Override
public Set<Feature> extract(JCas view1, JCas view2) throws TextClassificationException
{
  return new Feature("SharedNEs", !Collections.disjoint(getNEs(view1), getNEs(view2)),
      FeatureType.NUMERIC).asSet();
}

代码示例来源: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: dkpro/dkpro-tc

@Override
public Set<Feature> extract(JCas jcas, TextClassificationTarget aTarget)
  throws TextClassificationException
{
  long maxLen = getMax();
  Collection<Token> tokens = JCasUtil.selectCovered(jcas, Token.class, aTarget);
  double ratio = getRatio(tokens.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("DiffTypeTokenRatio",
      getTypeTokenRatio(view1) / getTypeTokenRatio(view2), FeatureType.NUMERIC).asSet();
}

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

@Override
public Set<Feature> extract(JCas jcas, TextClassificationTarget aTarget)
  throws TextClassificationException
{
  long maxLen = getMax();
  double ratio = getRatio(aTarget.getCoveredText().length(), maxLen);
  return new Feature(FEATURE_NAME, ratio, 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();
}

相关文章