/** * 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 NLGElement createPronoun(SyntaxProcessor parent, PhraseElement phrase) { String pronoun = "it"; // $NON-NLS-1$ NLGFactory phraseFactory = phrase.getFactory(); Object personValue = phrase.getFeature(Feature.PERSON); if (Person.FIRST.equals(personValue)) { pronoun = "I"; // $NON-NLS-1$ } else if (Person.SECOND.equals(personValue)) { pronoun = "you"; // $NON-NLS-1$ } else { Object genderValue = phrase.getFeature(LexicalFeature.GENDER); if (Gender.FEMININE.equals(genderValue)) { pronoun = "she"; // $NON-NLS-1$ } else if (Gender.MASCULINE.equals(genderValue)) { 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)); // Ehud - also copy over person element.setFeature(Feature.PERSON, ((WordElement) proElement).getFeature(Feature.PERSON)); } else { element = proElement; } element.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.SPECIFIER); element.setFeature(Feature.POSSESSIVE, phrase.getFeature(Feature.POSSESSIVE)); element.setFeature(Feature.NUMBER, phrase.getFeature(Feature.NUMBER)); if (phrase.hasFeature(InternalFeature.DISCOURSE_FUNCTION)) { element.setFeature( InternalFeature.DISCOURSE_FUNCTION, phrase.getFeature(InternalFeature.DISCOURSE_FUNCTION)); } return element; }
/** * 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) { 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); } } }
/** * Realises the head noun 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 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); } }