/** * Realises the specifier of the noun phrase. * * @param phrase * the <code>PhraseElement</code> representing this noun phrase. * @param parent * the parent <code>SyntaxProcessor</code> that will do the * realisation of the complementiser. * @param realisedElement * the current realisation of the noun phrase. */ private static void realiseSpecifier(PhraseElement phrase, SyntaxProcessor parent, ListElement realisedElement) { INLGElement specifierElement = phrase .getFeatureAsElement(InternalFeature.SPECIFIER.ToString()); if (specifierElement != null && !phrase.getFeatureAsBoolean(InternalFeature.RAISED.ToString()) && !phrase.getFeatureAsBoolean(Feature.ELIDED.ToString())) { if (!specifierElement.isA(LexicalCategoryEnum.PRONOUN) && specifierElement.getCategory().enumType != (int)PhraseCategoryEnum.NOUN_PHRASE) { specifierElement.setFeature(Feature.NUMBER.ToString(), phrase .getFeature(Feature.NUMBER.ToString())); } var currentElement = parent.realise(specifierElement); if (currentElement != null) { currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(), DiscourseFunction.SPECIFIER); realisedElement.addComponent(currentElement); } } }
/** * Realises the cue phrase for the clause if it exists. * * @param phrase * the <code>PhraseElement</code> representing this clause. * @param parent * the parent <code>SyntaxProcessor</code> that will do the * realisation of the complementiser. * @param realisedElement * the current realisation of the clause. */ private static void addCuePhrase(PhraseElement phrase, SyntaxProcessor parent, ListElement realisedElement) { var currentElement = parent.realise(phrase.getFeatureAsElement(Feature.CUE_PHRASE.ToString())); if (currentElement != null) { currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(), DiscourseFunction.CUE_PHRASE); realisedElement.addComponent(currentElement); } }
/** * Checks to see if this clause is a subordinate clause. If it is then the * complementiser is added as a component to the realised element * <b>unless</b> the complementiser has been suppressed. * * @param phrase * the <code>PhraseElement</code> representing this clause. * @param parent * the parent <code>SyntaxProcessor</code> that will do the * realisation of the complementiser. * @param realisedElement * the current realisation of the clause. */ private static void addComplementiser(PhraseElement phrase, SyntaxProcessor parent, ListElement realisedElement) { INLGElement currentElement; if (ClauseStatus.SUBORDINATE.Equals(phrase.getFeature(InternalFeature.CLAUSE_STATUS.ToString())) && !phrase.getFeatureAsBoolean(Feature.SUPRESSED_COMPLEMENTISER.ToString())) { currentElement = parent.realise(phrase.getFeatureAsElement(Feature.COMPLEMENTISER.ToString())); if (currentElement != null) { realisedElement.addComponent(currentElement); } } }
/** * 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); }
/** * Realises the complements of passive clauses; also sets number, person for * passive * * @param phrase * the <code>PhraseElement</code> representing this clause. * @param parent * the parent <code>SyntaxProcessor</code> that will do the * realisation of the complementiser. * @param realisedElement * the current realisation of the clause. * @param verbElement * the <code>NLGElement</code> representing the verb phrase for * this clause. */ private static INLGElement addPassiveComplementsNumberPerson(PhraseElement phrase, SyntaxProcessor parent, ListElement realisedElement, INLGElement verbElement) { object passiveNumber = null; object passivePerson = null; INLGElement currentElement = null; INLGElement splitVerb = null; var verbPhrase = phrase.getFeatureAsElement(InternalFeature.VERB_PHRASE.ToString()); // count complements to set plural feature if more than one var numComps = 0; var coordSubj = false; if (phrase.getFeatureAsBoolean(Feature.PASSIVE.ToString()) && verbPhrase != null && !InterrogativeType.WHAT_OBJECT.Equals(phrase.getFeature(Feature.INTERROGATIVE_TYPE.ToString()))) { // complements of a clause are stored in the VPPhraseSpec foreach (var subject in verbPhrase.getFeatureAsElementList(InternalFeature.COMPLEMENTS.ToString())) { // AG: complement needn't be an NP // subject.isA(PhraseCategory.NOUN_PHRASE) && if (DiscourseFunction.OBJECT.Equals(subject.getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString()))) { subject.setFeature(Feature.PASSIVE.ToString(), true); numComps++; currentElement = parent.realise(subject); if (currentElement != null) { currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(), DiscourseFunction.OBJECT); if (phrase.hasFeature(Feature.INTERROGATIVE_TYPE.ToString())) { splitVerb = currentElement; } else { realisedElement.addComponent(currentElement); } } // flag if passive subject is coordinated with an "and" if (!coordSubj && subject is CoordinatedPhraseElement) { var conj = ((CoordinatedPhraseElement)subject).getConjunction(); coordSubj = (conj != null && conj.Equals("and")); } if (passiveNumber == null) { passiveNumber = subject.getFeature(Feature.NUMBER.ToString()); } else { passiveNumber = NumberAgreement.PLURAL; } if (Person.FIRST.Equals(subject.getFeature(Feature.PERSON.ToString()))) { passivePerson = Person.FIRST; } else if (Person.SECOND.Equals(subject.getFeature(Feature.PERSON.ToString())) && !Person.FIRST.Equals(passivePerson)) { passivePerson = Person.SECOND; } else if (passivePerson == null) { passivePerson = Person.THIRD; } if (Form.GERUND.Equals(phrase.getFeature(Feature.FORM.ToString())) && !phrase.getFeatureAsBoolean(Feature.SUPPRESS_GENITIVE_IN_GERUND.ToString())) { subject.setFeature(Feature.POSSESSIVE.ToString(), true); } } } } if (verbElement != null) { if (passivePerson != null) { verbElement.setFeature(Feature.PERSON.ToString(), passivePerson); // below commented out. for non-passive, number and person set // by checkSubjectNumberPerson // } else { // verbElement.setFeature(Feature.PERSON, phrase // .getFeature(Feature.PERSON)); } if (numComps > 1 || coordSubj) { verbElement.setFeature(Feature.NUMBER.ToString(), NumberAgreement.PLURAL); } else if (passiveNumber != null) { verbElement.setFeature(Feature.NUMBER.ToString(), passiveNumber); } } return(splitVerb); }