示例#1
0
  /**
   * ************************************************************************************************************
   * Return all the entities of the given role in the correct case. Assumes the role will be some
   * kind of noun.
   *
   * @param role
   * @param element
   * @param kb
   * @return
   */
  private String formulateNounPhraseForCaseRole(CaseRole role, SVOElement element, KB kb) {
    if (!getCaseRolesScratchpad().containsKey(role)) {
      return "";
    }
    Set<String> rawNouns = Sentence.getRoleEntities(role, getCaseRolesScratchpad());

    List<String> fixedNouns = Lists.newArrayList();
    // We're assuming that only names and reified objects are in uppercase.
    for (String noun : rawNouns) {
      String temp = noun;
      if (!NLGStringUtils.isVariable(noun)) {
        temp = addProperties(noun);
        if (Noun.takesIndefiniteArticle(noun, kb)) {
          temp = Noun.aOrAn(temp) + " " + temp;
        }
        // Replace the noun with its SUMO representation if it has one.
        String kbStr = SumoProcessCollector.getProperFormOfEntity(noun, kb);
        temp = temp.replaceAll(noun, kbStr);
      }
      fixedNouns.add(temp);
      element.addConsumedCaseRole(role);
    }

    return NLGStringUtils.concatenateWithCommas(fixedNouns);
  }