public INLGElement realise(INLGElement phrase1, INLGElement phrase2) { INLGElement result = null; if (phrase1 is PhraseElement && phrase2 is PhraseElement && phrase1.getCategory().enumType == (int)PhraseCategoryEnum.CLAUSE && phrase2.getCategory().enumType == (int)PhraseCategoryEnum.CLAUSE) { var funcSets = AggregationHelper.collectFunctionalPairs(_syntax.realise(phrase1), _syntax.realise(phrase2)); applyForwardConjunctionReduction(funcSets); applyBackwardConjunctionReduction(funcSets); result = _factory.createCoordinatedPhrase(phrase1, phrase2); } return(result); }
/** * Perform aggregation on a single phrase. This method only works on a * {@link simplenlg.framework.CoordinatedPhraseElement}, in which case it * calls {@link #apply(List)} on the children of the coordinated phrase, * returning a coordinated phrase whose children are the result. * * @param phrase * @return aggregated result */ public INLGElement apply(INLGElement phrase) { INLGElement result = null; var element = phrase as CoordinatedPhraseElement; if (element != null) { var children = element.getChildren(); var aggregated = apply(children); if (aggregated.Count == 1) { result = aggregated[0]; } else { result = factory.createCoordinatedPhrase(); foreach (var agg in aggregated) { ((CoordinatedPhraseElement)result).addCoordinate(agg); } } } if (result != null) { foreach (var feature in phrase.getAllFeatureNames()) { if (result is SPhraseSpec) { ((SPhraseSpec)result).setFeature(feature, phrase.getFeature(feature)); } else { result.setFeature(feature, phrase.getFeature(feature)); } } } return(result); }