gpt4 book ai didi

edu.illinois.cs.cogcomp.edison.features.helpers.WordHelpers类的使用及代码示例

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

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

WordHelpers介绍

暂无

代码示例

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

private static String getSafePOS(TextAnnotation ta, int wordPosition) {
  String pos = WordHelpers.getPOS(ta, wordPosition);
  if (pos.length() == 0)
    pos = "*";
  return pos;
}

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

public static boolean isPrep(TextAnnotation ta, int tokenId) {
  String pos = WordHelpers.getPOS(ta, tokenId);
  String word = WordHelpers.getWord(ta, tokenId);
  String lowerCase = word.toLowerCase().trim();
  boolean validPreposition = prepositions.contains(lowerCase);
  boolean isPrepositionPOS = POSUtils.isPOSPreposition(pos);
  // we need to consider the case of "to + verb"
  boolean isToVP = false;
  if (tokenId < ta.size() - 1) {
    if (lowerCase.equals("to") && POSUtils.isPOSVerb(WordHelpers.getPOS(ta, tokenId + 1)))
      isToVP = true;
  }
  return validPreposition && (isPrepositionPOS && !isToVP);
}

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

public static List<String> getHypernyms(TextAnnotation ta, int tokenId, WordNetManager wnManager)
    throws JWNLException {
  String word = getWord(ta, tokenId).toLowerCase();
  String wordPOS = getPOS(ta, tokenId);
  if (POSUtils.isPOSOpenSet(wordPOS)) {
    POS wnPos = getWNPOS(wordPOS);
    return wnManager.getHypernyms(word, wnPos, true);
  } else {
    return new ArrayList<>();
  }
}

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

public static boolean isCapitalized(TextAnnotation ta, int tokenId) {
  String word = getWord(ta, tokenId);
  String firstCharacter = word.substring(0, 1);
  String upperCase = firstCharacter.toUpperCase();
  return upperCase.matches("[A-Z]") && upperCase.equals(firstCharacter);
}

代码示例来源: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;
      if ((have || doVerb) && POSUtils.isPOSVerb(WordHelpers.getPOS(ta, tokenId + 1)))
        predicate = false;
            && POSUtils.isPOSVerb(WordHelpers.getPOS(ta, tokenId + 2)))
          predicate = false;

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

public static String getPOS(TextAnnotation ta, int tokenId) {
  return getTokenLabel(ta, tokenId, ViewNames.POS);
}

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

public static List<String> getSynset(TextAnnotation ta, int tokenId, WordNetManager wnManager)
    throws JWNLException {
  String word = getWord(ta, tokenId).toLowerCase();
  String wordPOS = getPOS(ta, tokenId);
  if (POSUtils.isPOSOpenSet(wordPOS)) {
    POS wnPos = getWNPOS(wordPOS);
    return wnManager.getSynonyms(word, wnPos, false);
  } else {
    return new ArrayList<>();
  }
}

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

public static Constituent isTrigramPrep(TextAnnotation ta, int tokenId, String viewName) {
  String word = WordHelpers.getWord(ta, tokenId);
  if (tokenId < ta.size() - 2) {
    String nextWord = WordHelpers.getWord(ta, tokenId + 1);
    String nextNextWord = WordHelpers.getWord(ta, tokenId + 2);
    if (mwPrepositionsList.contains(word + " " + nextWord + " " + nextNextWord))
      return new Constituent("", viewName, ta, tokenId, tokenId + 3);
  }
  return null;
}

代码示例来源: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;
      if ((have || doVerb) && POSUtils.isPOSVerb(WordHelpers.getPOS(ta, tokenId + 1)))
        predicate = false;
            && POSUtils.isPOSVerb(WordHelpers.getPOS(ta, tokenId + 2)))
          predicate = false;

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

public static String getPOS(TextAnnotation ta, int tokenId) {
  return getTokenLabel(ta, tokenId, ViewNames.POS);
}

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

private static String getSafePOS(TextAnnotation ta, int wordPosition) {
  String pos = WordHelpers.getPOS(ta, wordPosition);
  if (pos.length() == 0)
    pos = "*";
  return pos;
}

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

public static boolean isPrep(TextAnnotation ta, int tokenId) {
  String pos = WordHelpers.getPOS(ta, tokenId);
  String word = WordHelpers.getWord(ta, tokenId);
  String lowerCase = word.toLowerCase().trim();
  boolean validPreposition = prepositions.contains(lowerCase);
  boolean isPrepositionPOS = POSUtils.isPOSPreposition(pos);
  // we need to consider the case of "to + verb"
  boolean isToVP = false;
  if (tokenId < ta.size() - 1) {
    if (lowerCase.equals("to") && POSUtils.isPOSVerb(WordHelpers.getPOS(ta, tokenId + 1)))
      isToVP = true;
  }
  return validPreposition && (isPrepositionPOS && !isToVP);
}

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

public static List<String> getHypernymsMostFrequentSense(TextAnnotation ta, int tokenId,
    WordNetManager wnManager) throws JWNLException {
  String word = getWord(ta, tokenId).toLowerCase();
  String wordPOS = getPOS(ta, tokenId);
  if (POSUtils.isPOSOpenSet(wordPOS)) {
    POS wnPos = getWNPOS(wordPOS);
    return wnManager.getHypernyms(word, wnPos, false);
  } else {
    return new ArrayList<>();
  }
}

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

public static boolean isCapitalized(TextAnnotation ta, int tokenId) {
  String word = getWord(ta, tokenId);
  String firstCharacter = word.substring(0, 1);
  String upperCase = firstCharacter.toUpperCase();
  return upperCase.matches("[A-Z]") && upperCase.equals(firstCharacter);
}

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

public static String getLemma(TextAnnotation ta, int tokenId) {
  return getTokenLabel(ta, tokenId, ViewNames.LEMMA).toLowerCase();
}

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

@Override
  public Boolean transform(Constituent input) {
    TextAnnotation ta = input.getTextAnnotation();
    boolean found = false;
    for (int i = input.getStartSpan(); i < input.getEndSpan(); i++) {
      if (WordHelpers.getPOS(ta, i).equals("MD")) {
        found = true;
        break;
      }
    }
    return found;
  }
};

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

String[] pos = new String[ta.size()];
for (int i = 0; i < ta.size(); i++) {
  form[i] = WordHelpers.getWord(ta, i);
  pos[i] = WordHelpers.getPOS(ta, i);

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

public static List<String> getHypernymsMostFrequentSense(TextAnnotation ta, int tokenId,
    WordNetManager wnManager) throws JWNLException {
  String word = getWord(ta, tokenId).toLowerCase();
  String wordPOS = getPOS(ta, tokenId);
  if (POSUtils.isPOSOpenSet(wordPOS)) {
    POS wnPos = getWNPOS(wordPOS);
    return wnManager.getHypernyms(word, wnPos, false);
  } else {
    return new ArrayList<>();
  }
}

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