gpt4 book ai didi

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

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

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

WordHelpers.getWord介绍

暂无

代码示例

代码示例来源: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 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-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: edu.illinois.cs.cogcomp/illinois-prep-srl

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: CogComp/cogcomp-nlp

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

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

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

代码示例来源: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: 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<>();
  }
}

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

public static boolean isPreviousWordEqual(Constituent m, String[] strs, boolean caseSensitive){
  for(String s: strs){
    if(!caseSensitive)
      s = s.toLowerCase();
    String[] split = s.split(" ");
    int size = split.length;
    boolean find = true;
    for(int k = 0; k < size; k++){
      if(m.getStartSpan()-size>=0){
        String pword = WordHelpers.getWord(m.getTextAnnotation(), m.getStartSpan()-size+k); 
        if(!caseSensitive)
          pword = pword.toLowerCase();
        if(!pword.equals(split[k]))
          find = false;
      }
      else
        find = false;
    
    }
    if(find)
      return true;
  }
  return false;
}
public static void saveObject(String fileName, Object obj){

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

public static boolean isPreviousWordEqual(Constituent m, String[] strs, boolean caseSensitive){
  for(String s: strs){
    if(!caseSensitive)
      s = s.toLowerCase();
    String[] split = s.split(" ");
    int size = split.length;
    boolean find = true;
    for(int k = 0; k < size; k++){
      if(m.getStartSpan()-size>=0){
        String pword = WordHelpers.getWord(m.getTextAnnotation(), m.getStartSpan()-size+k); 
        if(!caseSensitive)
          pword = pword.toLowerCase();
        if(!pword.equals(split[k]))
          find = false;
      }
      else
        find = false;
    
    }
    if(find)
      return true;
  }
  return false;
}
public static void saveObject(String fileName, Object obj){

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

public static List<String> getSynsetMostFrequentSense(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, true);
  } else {
    return new ArrayList<>();
  }
}

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

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 List<String> getSynsetMostFrequentSense(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, true);
  } else {
    return new ArrayList<>();
  }
}

代码示例来源: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: edu.illinois.cs.cogcomp/illinois-edison

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: edu.illinois.cs.cogcomp/LBJCoref

public static boolean isAfterWordEqual(Constituent m, String[] strs, boolean caseSensitive){
  for(String s: strs){
    if(!caseSensitive)
      s = s.toLowerCase();
    String[] split = s.split(" ");
    int size = split.length;
    boolean find = true;
    for(int k = 0; k < size; k++){
      if(m.getEndSpan()+size <= m.getTextAnnotation().getTokens().length) { 
        String pword =WordHelpers.getWord(m.getTextAnnotation(), m.getEndSpan()+k); 
        if(!caseSensitive)
          pword = pword.toLowerCase();
        if(!pword.equals(split[k]))
          find = false;
      }
      else
        find = false;
    }
    if(find)
      return true;
  }
  return false;
}

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

public static boolean isRefenentialMention(Constituent c) {
  if (invalidMentionFile == null)
    return true;
  if (invalidMentionReference == null)
    invalidMentionReference = loadInvalidReference(invalidMentionFile);
  String headWord = WordHelpers.getWord(c.getTextAnnotation(), DocTextAnnotation.getRobustHeadWordPosition(c));
    
  if(querryRefentialMention(c.getSurfaceString(),c))
    return false;
  if(!Character.isUpperCase(headWord.charAt(0)) && querryRefentialMention("|"+headWord+"|",c))
    return false;
  TextAnnotation ta = c.getTextAnnotation();
  if (c.getStartSpan() > 0) {
    String pWord = WordHelpers.getWord(ta, c.getStartSpan() - 1); 
    if(querryRefentialMention(pWord+"[" + c.getSurfaceString() + "]",c))
      return false;
    if(querryRefentialMention(pWord+"|"+headWord+"|",c))
      return false;
  }
  if (c.getEndSpan() <= ta.getTokens().length - 1) {
    String nWord = WordHelpers.getWord(ta, c.getStartSpan() + 1);
    if(querryRefentialMention("[" + c.getSurfaceString() + "]"+ nWord,c))
      return false;
    if(querryRefentialMention("|"+headWord+"|"+nWord,c))
      return false;
  }
  return true;
}

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