internal FunctionalSet(DiscourseFunction func, ElementCategory category, Periphery periphery, params NLGElement[] components) { function = func; this.category = category; this.periphery = periphery; this.components = components.ToList(); }
/** * remove complements of the specified DiscourseFunction * * @param function */ public virtual void removeComplements(DiscourseFunction function) { var complements = getFeatureAsElementList(InternalFeature.COMPLEMENTS.ToString()); if (complements == null) { return; } var complementsToRemove = new List <INLGElement>(); foreach (var complement in complements) { if ((int)function == (int)complement.getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString())) { complementsToRemove.add(complement); } } if (!complementsToRemove.isEmpty()) { complements.removeAll(complementsToRemove); setFeature(InternalFeature.COMPLEMENTS.ToString(), complements); } return; }
/** * Utility method to set the discourse function for phrase components, * unless set by user * * @param function * the function * @param phrase * the phrase */ private void checkFunction(DiscourseFunction function, NLGElement phrase) { if (!phrase.hasFeature(InternalFeature.DISCOURSE_FUNCTION)) { phrase.setFeature(InternalFeature.DISCOURSE_FUNCTION, function); } }
public FunctionalSet(DiscourseFunction _func, IElementCategory _category, Periphery _periphery, List <INLGElement> _components) { function = _func; category = _category; periphery = _periphery; components = _components; }
public static FunctionalSet newInstance(DiscourseFunction func, ElementCategory category, Periphery periphery, params NLGElement[] components) { FunctionalSet pair = null; if (components.Length >= 2) { pair = new FunctionalSet(func, category, periphery, components); } return(pair); }
public static FunctionalSet newInstance(DiscourseFunction func, IElementCategory category, Periphery periphery, List <INLGElement> components) { FunctionalSet pair = null; if (components.Count >= 2) { pair = new FunctionalSet(func, category, periphery, components); } return(pair); }
public static IList <FunctionalSet> collectFunctionalPairs(NLGElement phrase1, NLGElement phrase2) { IList <NLGElement> children1 = getAllChildren(phrase1); IList <NLGElement> children2 = getAllChildren(phrase2); IList <FunctionalSet> pairs = new List <FunctionalSet>(); if (children1.Count == children2.Count) { Periphery periph = Periphery.LEFT; for (int i = 0; i < children1.Count; i++) { NLGElement child1 = children1[i]; NLGElement child2 = children2[i]; ElementCategory cat1 = child1.Category; ElementCategory cat2 = child2.Category; DiscourseFunction func1 = (DiscourseFunction)child1.getFeature(InternalFeature.DISCOURSE_FUNCTION); DiscourseFunction func2 = (DiscourseFunction)child2.getFeature(InternalFeature.DISCOURSE_FUNCTION); if (cat1 == cat2 && func1 == func2) { pairs.Add(FunctionalSet.newInstance(func1, cat1, periph, child1, child2)); if (cat1 == LexicalCategory.LexicalCategoryEnum.VERB) { periph = Periphery.RIGHT; } } else { pairs.Clear(); break; } } } return(pairs); }
/** * Iterates through a <code>List</code> of <code>NLGElement</code>s * realisation each element and adding it to the on-going realisation of * 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 elementList * the <code>List</code> of <code>NLGElement</code>s to be * realised. * @param function * the <code>DiscourseFunction</code> each element in the list is * to take. If this is <code>null</code> then the function is not * set and any existing discourse function is kept. */ public static void realiseList(SyntaxProcessor parent, ListElement realisedElement, List <INLGElement> elementList, DiscourseFunction function) { // AG: Change here: the original list structure is kept, i.e. rather // than taking the elements of the list and putting them in the realised // element, we now add the realised elements to a new list and put that // in the realised element list. This preserves constituency for // orthography and morphology processing later. var realisedList = new ListElement(); INLGElement currentElement = null; foreach (var eachElement in elementList) { currentElement = parent.realise(eachElement); if (currentElement != null) { currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(), function); if (eachElement.getFeatureAsBoolean(Feature.APPOSITIVE.ToString())) { currentElement.setFeature(Feature.APPOSITIVE.ToString(), true); } // realisedElement.addComponent(currentElement); realisedList.addComponent(currentElement); } } if (!realisedList.getChildren().isEmpty()) { realisedElement.addComponent(realisedList); } }
/** * Construct a set of compatible phrases and their function * * @param function * their function * @param phrases * the list of constituent phrases for the function. */ public PhraseSet(DiscourseFunction function, params NLGElement[] phrases) { this.function = function; this.phrases = new List <NLGElement>(phrases.ToList()); }
/** * Construct a set of compatible phrases and their function * * @param function * their function * @param phrases * the list of constituent phrases for the function. */ public PhraseSet(DiscourseFunction _function) { this.function = _function; }