コード例 #1
0
ファイル: Sentence.java プロジェクト: qjay612/sigmakee
  /**
   * ************************************************************************************************************
   * Put the "direct object" of this process into natural language.
   */
  void formulateNaturalDirectObject() {
    StringBuilder sBuild = new StringBuilder();

    VerbProperties verbProperties = new VerbPropertiesSimpleImpl();
    List<CaseRole> caseRolesToUse =
        verbProperties.getCaseRolesForGrammarRole(
            getVerb().getVerb(), SVOElement.SVOGrammarPosition.DIRECT_OBJECT);

    // It's possible that the direct object slot has already been filled, e.g. by the verb if we
    // didn't know how
    // to translate the process into natural language. Since only one direct object is allowed, in
    // this case we need to
    // precede any objects formulated here with a prefix, and add the data to the indirect object
    // list.
    String prefix = "";
    SVOElement element = directObject;
    if (!directObject.getSurfaceForm().isEmpty()) {
      prefix = "on ";
      element = new SVOElement(SVOGrammarPosition.INDIRECT_OBJECT);
      indirectObjects.add(element);
    }

    for (CaseRole role : caseRolesToUse) {
      String obj = formulateNounPhraseForCaseRole(role, directObject, kb);
      if (!obj.isEmpty()) {
        sBuild.append(prefix).append(" ").append(obj).append(" ");
        getCaseRolesScratchpad().removeAll(role);
        break;
      }
    }

    element.setSurfaceForm(sBuild.toString().replaceAll("\\s+", " ").trim());
  }
コード例 #2
0
ファイル: Sentence.java プロジェクト: qjay612/sigmakee
  /**
   * ************************************************************************************************************
   * Put the subject of this process into natural language.
   */
  void formulateNaturalSubject() {
    StringBuilder sBuild = new StringBuilder();

    VerbProperties verbProperties = new VerbPropertiesSimpleImpl();
    List<CaseRole> caseRolesToUse =
        verbProperties.getCaseRolesForGrammarRole(
            getVerb().getVerb(), SVOElement.SVOGrammarPosition.SUBJECT);

    for (CaseRole role : caseRolesToUse) {
      String obj = formulateNounPhraseForCaseRole(role, subject, kb);
      if (!obj.isEmpty()) {
        sBuild.append(" ").append(obj).append(" ");
        getCaseRolesScratchpad().removeAll(role);
        break;
      }
    }

    subject.setSurfaceForm(sBuild.toString().replaceAll("\\s+", " ").trim());
  }
コード例 #3
0
ファイル: Sentence.java プロジェクト: qjay612/sigmakee
  /**
   * ************************************************************************************************************
   * Put the "indirect object" of this process into natural language.
   */
  void formulateNaturalIndirectObject() {
    VerbProperties verbProperties = new VerbPropertiesSimpleImpl();
    String verb = getVerb().getVerb();
    List<CaseRole> caseRolesToUse =
        verbProperties.getCaseRolesForGrammarRole(
            verb, SVOElement.SVOGrammarPosition.INDIRECT_OBJECT);

    for (CaseRole role : caseRolesToUse) {
      SVOElement element = new SVOElement(SVOGrammarPosition.INDIRECT_OBJECT);
      String obj = formulateNounPhraseForCaseRole(role, element, kb);
      if (!obj.isEmpty()) {
        List<String> preps = verbProperties.getPrepositionForCaseRole(verb, role);
        // TODO: for time being, take just the first one in the list
        String prep = preps.get(0);
        element.setSurfaceForm(prep + " " + obj + " ");
        indirectObjects.add(element);
        getCaseRolesScratchpad().removeAll(role);
      }
    }
  }