Package simplenlg.framework

Examples of simplenlg.framework.NLGElement


   *            the <code>NLGElement</code> representing the verb phrase for
   *            this clause.
   */
  private static void checkSubjectNumberPerson(PhraseElement phrase,
      NLGElement verbElement) {
    NLGElement currentElement = null;
    List<NLGElement> subjects = phrase
        .getFeatureAsElementList(InternalFeature.SUBJECTS);
    boolean pluralSubjects = false;
    Person person = null;

    if (subjects != null) {
      switch (subjects.size()) {
      case 0:
        break;

      case 1:
        currentElement = subjects.get(0);
        // coordinated NP with "and" are plural (not coordinated NP with
        // "or")
        if (currentElement instanceof CoordinatedPhraseElement
            && ((CoordinatedPhraseElement) currentElement)
                .checkIfPlural())
          pluralSubjects = true;
        else if (currentElement.getFeature(Feature.NUMBER) == NumberAgreement.PLURAL)
          pluralSubjects = true;
        else if (currentElement.isA(PhraseCategory.NOUN_PHRASE)) {
          NLGElement currentHead = currentElement
              .getFeatureAsElement(InternalFeature.HEAD);
          person = (Person) currentElement.getFeature(Feature.PERSON);
          if ((currentHead.getFeature(Feature.NUMBER) == NumberAgreement.PLURAL))
            pluralSubjects = true;
          else if (currentHead instanceof ListElement) {
            pluralSubjects = true;
            /*
             * } else if (currentElement instanceof
View Full Code Here


    // TODO Auto-generated method stub
    return null;
  }

  public NLGElement realise(NLGElement phrase1, NLGElement phrase2) {
    NLGElement result = null;

    if (phrase1 instanceof PhraseElement
        && phrase2 instanceof PhraseElement
        && phrase1.getCategory() == PhraseCategory.CLAUSE
        && phrase2.getCategory() == PhraseCategory.CLAUSE) {
View Full Code Here

   * @param realisedElement
   *            the current realisation of the noun phrase.
   */
  private static void realiseHeadNoun(PhraseElement phrase,
      SyntaxProcessor parent, ListElement realisedElement) {
    NLGElement headElement = phrase.getHead();

    if (headElement != null) {
      headElement.setFeature(Feature.ELIDED, phrase
          .getFeature(Feature.ELIDED));
      headElement.setFeature(LexicalFeature.GENDER, phrase
          .getFeature(LexicalFeature.GENDER));
      headElement.setFeature(InternalFeature.ACRONYM, phrase
          .getFeature(InternalFeature.ACRONYM));
      headElement.setFeature(Feature.NUMBER, phrase
          .getFeature(Feature.NUMBER));
      headElement.setFeature(Feature.PERSON, phrase
          .getFeature(Feature.PERSON));
      headElement.setFeature(Feature.POSSESSIVE, phrase
          .getFeature(Feature.POSSESSIVE));
      headElement.setFeature(Feature.PASSIVE, phrase
          .getFeature(Feature.PASSIVE));
      NLGElement currentElement = parent.realise(headElement);
      currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION,
          DiscourseFunction.SUBJECT);
      realisedElement.addComponent(currentElement);
    }
  }
View Full Code Here

   * @param realisedElement
   *            the current realisation of the noun phrase.
   */
  private static void realiseSpecifier(PhraseElement phrase,
      SyntaxProcessor parent, ListElement realisedElement) {
    NLGElement specifierElement = phrase
        .getFeatureAsElement(InternalFeature.SPECIFIER);

    if (specifierElement != null
        && !phrase.getFeatureAsBoolean(InternalFeature.RAISED)
            .booleanValue() && !phrase.getFeatureAsBoolean(Feature.ELIDED).booleanValue()) {

      if (!specifierElement.isA(LexicalCategory.PRONOUN)) {
        specifierElement.setFeature(Feature.NUMBER, phrase
            .getFeature(Feature.NUMBER));
      }
     
      NLGElement currentElement = parent.realise(specifierElement);
     
      if (currentElement != null) {
        currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION,
            DiscourseFunction.SPECIFIER);
        realisedElement.addComponent(currentElement);
      }
    }
  }
View Full Code Here

      do {
        changesMade = false;
        for (int i = 0; i < orderedModifiers.size() - 1; i++) {
          if (getMinPos(orderedModifiers.get(i)) > getMaxPos(orderedModifiers
              .get(i + 1))) {
            NLGElement temp = orderedModifiers.get(i);
            orderedModifiers.set(i, orderedModifiers.get(i + 1));
            orderedModifiers.set(i + 1, temp);
            changesMade = true;
          }
        }
View Full Code Here

        pronoun = "he"; //$NON-NLS-1$
      }
    }
    // AG: createWord now returns WordElement; so we embed it in an
    // inflected word element here
    NLGElement element;
    NLGElement proElement = phraseFactory.createWord(pronoun,
        LexicalCategory.PRONOUN);
   
    if (proElement instanceof WordElement) {
      element = new InflectedWordElement((WordElement) proElement);
      element.setFeature(LexicalFeature.GENDER, ((WordElement) proElement).getFeature(LexicalFeature.GENDER))
View Full Code Here

        DocumentElement t = w.UnwrapDocumentElement(wt);
        if (t != null) {
          Realiser r = new Realiser(lexicon);
          r.initialise();

          NLGElement tr = r.realise(t);

          output = tr.getRealisation();
        }

      } catch (Exception e) {
        throw new XMLRealiserException("NLG XMLRealiser Error", e);
      }
View Full Code Here

  public void setAdverb(Object adverb) {
    if (adverb instanceof NLGElement)
      setHead(adverb);
    else {
      // create noun as word
      NLGElement adverbElement = getFactory().createWord(adverb, LexicalCategory.ADVERB);

      // set head of NP to nounElement
      setHead(adverbElement);
    }
  }
View Full Code Here

   * sets the noun (head) of a noun phrase
   *
   * @param noun
   */
  public void setNoun(Object noun) {
    NLGElement nounElement = getFactory().createNLGElement(noun,
        LexicalCategory.NOUN);
    setHead(nounElement);
  }
View Full Code Here

      ((NLGElement) specifier).setFeature(
          InternalFeature.DISCOURSE_FUNCTION,
          DiscourseFunction.SPECIFIER);
    } else {
      // create specifier as word (assume determiner)
      NLGElement specifierElement = getFactory().createWord(specifier,
          LexicalCategory.DETERMINER);

      // set specifier feature
      if (specifierElement != null) {
        setFeature(InternalFeature.SPECIFIER, specifierElement);
        specifierElement.setFeature(InternalFeature.DISCOURSE_FUNCTION,
            DiscourseFunction.SPECIFIER);
      }
    }
  }
View Full Code Here

TOP

Related Classes of simplenlg.framework.NLGElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.