gpt4 book ai didi

edu.illinois.cs.cogcomp.edison.features.helpers.WordHelpers.getLemma()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-23 22:05:05 27 4
gpt4 key购买 nike

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

WordHelpers.getLemma介绍

暂无

代码示例

代码示例来源:origin: CogComp/cogcomp-nlp

private static String getSafeLemma(TextAnnotation ta, int wordPosition) {
  String lemma = WordHelpers.getLemma(ta, wordPosition);
  if (lemma.length() == 0)
    lemma = "*";
  return lemma;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison

private static String getSafeLemma(TextAnnotation ta, int wordPosition) {
  String lemma = WordHelpers.getLemma(ta, wordPosition);
  if (lemma.length() == 0)
    lemma = "*";
  return lemma;
}

代码示例来源:origin: CogComp/cogcomp-nlp

@Override
public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException {
  if (data.size() == 0)
    loadDataFromClassPath();
  String lemma = WordHelpers.getLemma(ta, wordPosition);
  Set<Feature> features = new LinkedHashSet<>();
  if (data.containsKey(lemma)) {
    features.add(DiscreteFeature.create(data.get(lemma)));
  }
  return features;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison

@Override
public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException {
  if (data.size() == 0)
    loadDataFromClassPath();
  String lemma = WordHelpers.getLemma(ta, wordPosition);
  Set<Feature> features = new LinkedHashSet<>();
  if (data.containsKey(lemma)) {
    features.add(DiscreteFeature.create(data.get(lemma)));
  }
  return features;
}

代码示例来源:origin: CogComp/cogcomp-nlp

@Override
  public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition)
      throws EdisonException {
    Set<Feature> features = new LinkedHashSet<>();
    List<String> nomFrames;
    try {
      URL file =
          IOUtils.lsResources(WordFeatureExtractorFactory.class, "nombank.list.gz")
              .get(0);
      nomFrames = LineIO.readGZip(file.getFile());
      String lemma = WordHelpers.getLemma(ta, wordPosition);
      if (nomFrames.contains(lemma)) {
        features.add(isNom);
      }
    } catch (Exception e) {
      System.err.println("Could not read nombank.list.gz file from classpath");
      e.printStackTrace();
    }
    return features;
  }
};

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison

@Override
  public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition)
      throws EdisonException {
    Set<Feature> features = new LinkedHashSet<>();
    List<String> nomFrames;
    try {
      URL file =
          IOUtils.lsResources(WordFeatureExtractorFactory.class, "nombank.list.gz")
              .get(0);
      nomFrames = LineIO.readGZip(file.getFile());
      String lemma = WordHelpers.getLemma(ta, wordPosition);
      if (nomFrames.contains(lemma)) {
        features.add(isNom);
      }
    } catch (Exception e) {
      System.err.println("Could not read nombank.list.gz file from classpath");
      e.printStackTrace();
    }
    return features;
  }
};

代码示例来源:origin: CogComp/cogcomp-nlp

@Override
public Set<Feature> getFeatures(Constituent c) throws EdisonException {
  int tokenId = c.getEndSpan() - 1;
  TextAnnotation ta = c.getTextAnnotation();
  String predicateWord = ta.getToken(tokenId).toLowerCase().trim();
  String predicateLemma;
  if (c.hasAttribute(PredicateArgumentView.LemmaIdentifier))
    predicateLemma = c.getAttribute(PredicateArgumentView.LemmaIdentifier);
  else
    predicateLemma = WordHelpers.getLemma(ta, tokenId);
  NomLexReader nomLex = NomLexReader.getInstance();
  List<NomLexEntry> nomLexEntries = nomLex.getNomLexEntries(predicateWord, predicateLemma);
  Set<Feature> features = new LinkedHashSet<>();
  if (nomLexEntries.size() > 0) {
    for (NomLexEntry e : nomLexEntries) {
      features.add(DiscreteFeature.create("nom-cls:" + e.nomClass));
      if (NomLexEntry.VERBAL.contains(e.nomClass)) {
        features.add(DE_VERBAL);
        features.add(DiscreteFeature.create("nom-vb:" + e.verb));
      } else if (NomLexEntry.ADJECTIVAL.contains(e.nomClass)) {
        features.add(DE_ADJECTIVAL);
        features.add(DiscreteFeature.create("nom-adj:" + e.adj));
      }
    }
  }
  return features;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison

@Override
public Set<Feature> getFeatures(Constituent c) throws EdisonException {
  int tokenId = c.getEndSpan() - 1;
  TextAnnotation ta = c.getTextAnnotation();
  String predicateWord = ta.getToken(tokenId).toLowerCase().trim();
  String predicateLemma;
  if (c.hasAttribute(PredicateArgumentView.LemmaIdentifier))
    predicateLemma = c.getAttribute(PredicateArgumentView.LemmaIdentifier);
  else
    predicateLemma = WordHelpers.getLemma(ta, tokenId);
  NomLexReader nomLex = NomLexReader.getInstance();
  List<NomLexEntry> nomLexEntries = nomLex.getNomLexEntries(predicateWord, predicateLemma);
  Set<Feature> features = new LinkedHashSet<>();
  if (nomLexEntries.size() > 0) {
    for (NomLexEntry e : nomLexEntries) {
      features.add(DiscreteFeature.create("nom-cls:" + e.nomClass));
      if (NomLexEntry.VERBAL.contains(e.nomClass)) {
        features.add(DE_VERBAL);
        features.add(DiscreteFeature.create("nom-vb:" + e.verb));
      } else if (NomLexEntry.ADJECTIVAL.contains(e.nomClass)) {
        features.add(DE_ADJECTIVAL);
        features.add(DiscreteFeature.create("nom-adj:" + e.adj));
      }
    }
  }
  return features;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-verbsense

public Option<String> getLemma(TextAnnotation ta, int tokenId) {
  String pos = WordHelpers.getPOS(ta, tokenId);
  String token = ta.getToken(tokenId).toLowerCase();
  String lemma = WordHelpers.getLemma(ta, tokenId);
      if (have && WordHelpers.getLemma(ta, tokenId + 1).equals("be")) {
        predicate = false;

代码示例来源:origin: CogComp/cogcomp-nlp

public Option<String> getLemma(TextAnnotation ta, int tokenId) {
  String pos = WordHelpers.getPOS(ta, tokenId);
  String token = ta.getToken(tokenId).toLowerCase();
  String lemma = WordHelpers.getLemma(ta, tokenId);
      if (have && WordHelpers.getLemma(ta, tokenId + 1).equals("be")) {
        predicate = false;

代码示例来源:origin: CogComp/cogcomp-nlp

sb1.append("v-");
  sb2.append("v-");
  sb3.append(WordHelpers.getLemma(ta, target.getStartSpan())).append("-");
} else {
  addToFeature(target, arg, sb1, sb2, sb3);

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison

sb1.append("v-");
  sb2.append("v-");
  sb3.append(WordHelpers.getLemma(ta, target.getStartSpan())).append("-");
} else {
  addToFeature(target, arg, sb1, sb2, sb3);

代码示例来源:origin: CogComp/cogcomp-nlp

private String getLemma(Constituent c) {
  if (c.hasAttribute(PredicateArgumentView.LemmaIdentifier)) {
    return c.getAttribute(PredicateArgumentView.LemmaIdentifier);
  } else if (c.getTextAnnotation().hasView(ViewNames.LEMMA)) {
    return WordHelpers.getLemma(c.getTextAnnotation(), c.getEndSpan() - 1);
  } else
    return null;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison

private String getLemma(Constituent c) {
  if (c.hasAttribute(PredicateArgumentView.LemmaIdentifier)) {
    return c.getAttribute(PredicateArgumentView.LemmaIdentifier);
  } else if (c.getTextAnnotation().hasView(ViewNames.LEMMA)) {
    return WordHelpers.getLemma(c.getTextAnnotation(), c.getEndSpan() - 1);
  } else
    return null;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-srl

if (predicateToken + 1 < ta.getSentence(predicate.getSentenceId())
    .getEndSpan()) {
  String nextToken = WordHelpers.getLemma(ta, predicateToken + 1);

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com