/** * Adds <em>not</em> to the stack if the phrase is negated. * * @param phrase * the <code>PhraseElement</code> representing this noun phrase. * @param vgComponents * the stack of verb components in the verb group. * @param frontVG * the first verb in the verb group. * @param hasModal * the phrase has a modal * @return the new element for the front of the group. */ private static INLGElement createNot(PhraseElement phrase, Stack <INLGElement> vgComponents, INLGElement frontVG, bool hasModal) { var newFront = frontVG; if (phrase.getFeatureAsBoolean(Feature.NEGATED.ToString())) { var factory = phrase.getFactory(); // before adding "do", check if this is an object WH // interrogative // in which case, don't add anything as it's already done by // ClauseHelper var interrType = phrase.getFeature(Feature.INTERROGATIVE_TYPE.ToString()); var addDo = !(InterrogativeType.WHAT_OBJECT.Equals(interrType) || InterrogativeType.WHO_OBJECT .Equals(interrType)); if (!vgComponents.empty() || frontVG != null && isCopular(frontVG)) { vgComponents.push(new InflectedWordElement( "not", new LexicalCategory_ADVERB())); } else { if (frontVG != null && !hasModal) { frontVG.setFeature(Feature.NEGATED.ToString(), true); vgComponents.push(frontVG); } vgComponents.push(new InflectedWordElement( "not", new LexicalCategory_ADVERB())); if (addDo) { if (factory != null) { newFront = factory.createInflectedWord("do", new LexicalCategory_VERB()); } else { newFront = new InflectedWordElement( "do", new LexicalCategory_VERB()); } } } } return(newFront); }
/** * The main method for controlling the syntax realisation of clauses. * * @param parent * the parent <code>SyntaxProcessor</code> that called this * method. * @param phrase * the <code>PhraseElement</code> representation of the clause. * @return the <code>NLGElement</code> representing the realised clause. */ public static INLGElement realise(SyntaxProcessor parent, PhraseElement phrase) { ListElement realisedElement = null; var phraseFactory = phrase.getFactory(); INLGElement splitVerb = null; var interrogObj = false; if (phrase != null) { realisedElement = new ListElement(); var verbElement = phrase.getFeatureAsElement(InternalFeature.VERB_PHRASE.ToString()); if (verbElement == null) { verbElement = phrase.getHead(); } checkSubjectNumberPerson(phrase, verbElement); checkDiscourseFunction(phrase); copyFrontModifiers(phrase, verbElement); addComplementiser(phrase, parent, realisedElement); addCuePhrase(phrase, parent, realisedElement); if (phrase.hasFeature(Feature.INTERROGATIVE_TYPE.ToString())) { var inter = phrase.getFeature(Feature.INTERROGATIVE_TYPE.ToString()); interrogObj = (InterrogativeType.WHAT_OBJECT.Equals(inter) || InterrogativeType.WHO_OBJECT.Equals(inter) || InterrogativeType.HOW_PREDICATE.Equals(inter) || InterrogativeType.HOW.Equals(inter) || InterrogativeType.WHY.Equals(inter) || InterrogativeType.WHERE.Equals(inter)); splitVerb = realiseInterrogative(phrase, parent, realisedElement, phraseFactory, verbElement); } else { PhraseHelper.realiseList(parent, realisedElement, phrase.getFeatureAsElementList(InternalFeature.FRONT_MODIFIERS.ToString()), DiscourseFunction.FRONT_MODIFIER); } addSubjectsToFront(phrase, parent, realisedElement, splitVerb); var passiveSplitVerb = addPassiveComplementsNumberPerson(phrase, parent, realisedElement, verbElement); if (passiveSplitVerb != null) { splitVerb = passiveSplitVerb; } // realise verb needs to know if clause is object interrogative realiseVerb(phrase, parent, realisedElement, splitVerb, verbElement, interrogObj); addPassiveSubjects(phrase, parent, realisedElement, phraseFactory); addInterrogativeFrontModifiers(phrase, parent, realisedElement); addEndingTo(phrase, parent, realisedElement, phraseFactory); } return(realisedElement); }
/** * Creates the appropriate pronoun if the subject of the noun phrase is * pronominal. * * @param parent * the parent <code>SyntaxProcessor</code> that will do the * realisation of the complementiser. * @param phrase * the <code>PhraseElement</code> representing this noun phrase. * @return the <code>NLGElement</code> representing the pronominal. */ private static INLGElement createPronoun(SyntaxProcessor parent, PhraseElement phrase) { var pronoun = "it"; var phraseFactory = phrase.getFactory(); var personValue = phrase.getFeature(Feature.PERSON.ToString()); if (Person.FIRST.Equals(personValue)) { pronoun = "I"; } else if (Person.SECOND.Equals(personValue)) { pronoun = "you"; } else { var genderValue = phrase.getFeature(LexicalFeature.GENDER); if (Gender.FEMININE.Equals(genderValue)) { pronoun = "she"; } else if (Gender.MASCULINE.Equals(genderValue)) { pronoun = "he"; } } // AG: createWord now returns WordElement; so we embed it in an // inflected word element here INLGElement element; var proElement = phraseFactory.createWord(pronoun, new LexicalCategory_PRONOUN()); if (proElement is WordElement) { element = new InflectedWordElement((WordElement)proElement); element.setFeature(LexicalFeature.GENDER, ((WordElement)proElement).getFeature(LexicalFeature.GENDER)); // Ehud - also copy over person element.setFeature(Feature.PERSON.ToString(), ((WordElement)proElement).getFeature(Feature.PERSON.ToString())); } else { element = proElement; } element.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(), DiscourseFunction.SPECIFIER); element.setFeature(Feature.POSSESSIVE.ToString(), phrase .getFeature(Feature.POSSESSIVE.ToString())); element .setFeature(Feature.NUMBER.ToString(), phrase.getFeature(Feature.NUMBER.ToString())); if (phrase.hasFeature(InternalFeature.DISCOURSE_FUNCTION.ToString())) { element.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(), phrase .getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString())); } return(element); }