if (wps instanceof simplenlg.xmlrealiser.wrapper.XmlDocumentElement) {
return (NLGElement) UnwrapDocumentElement((simplenlg.xmlrealiser.wrapper.XmlDocumentElement) wps);
}
// Handle coordinate phrase specs first, which will cause recursion.
NLGElement cp = UnwrapCoordinatePhraseSpec(wps);
if (cp != null) {
return cp;
}
// Literal text.
if (wps instanceof simplenlg.xmlrealiser.wrapper.XmlStringElement) {
simplenlg.xmlrealiser.wrapper.XmlStringElement wp = (simplenlg.xmlrealiser.wrapper.XmlStringElement) wps;
NLGElement p = factory.createStringElement(wp.getVal());
return p;
}
// WordElements (delegate to UnwrapWordElement) -- useful to have
// because it is called by unWrapPhraseComponents, and pre/post mods
// might be WordElements
if (wps instanceof simplenlg.xmlrealiser.wrapper.XmlWordElement) {
return UnwrapWordElement((simplenlg.xmlrealiser.wrapper.XmlWordElement) wps);
}
// Sentence
else if (wps instanceof simplenlg.xmlrealiser.wrapper.XmlSPhraseSpec) {
simplenlg.xmlrealiser.wrapper.XmlSPhraseSpec wp = (simplenlg.xmlrealiser.wrapper.XmlSPhraseSpec) wps;
SPhraseSpec sp = factory.createClause();
NLGElement vp = null;
ArrayList<NLGElement> subjects = new ArrayList<NLGElement>();
for (simplenlg.xmlrealiser.wrapper.XmlNLGElement p : wp.getSubj()) {
NLGElement p1 = UnwrapNLGElement(p);
checkFunction(simplenlg.features.DiscourseFunction.SUBJECT, p1);
subjects.add(p1);
}
if (subjects.size() > 0) {
sp.setFeature(InternalFeature.SUBJECTS, subjects);
}
if (wp.getVp() != null) {
vp = UnwrapNLGElement(wp.getVp());
sp.setVerbPhrase(vp);
}
if (wp.getCuePhrase() != null) {
NLGElement cue = UnwrapNLGElement(wp.getCuePhrase());
cue.setFeature(InternalFeature.DISCOURSE_FUNCTION,
DiscourseFunction.CUE_PHRASE);
sp.setFeature(Feature.CUE_PHRASE, cue);
}
if (wp.getCOMPLEMENTISER() != null) {
sp.setFeature(Feature.COMPLEMENTISER, wp.getCOMPLEMENTISER());
}
setSFeatures(wp, sp, vp);
// Common phrase components.
UnwrapPhraseComponents(sp, wps);
return sp;
}
// Phrases
else if (wps instanceof simplenlg.xmlrealiser.wrapper.XmlPhraseElement) {
simplenlg.xmlrealiser.wrapper.XmlPhraseElement we = (simplenlg.xmlrealiser.wrapper.XmlPhraseElement) wps;
PhraseElement hp = null;
simplenlg.xmlrealiser.wrapper.XmlWordElement w = we.getHead();
NLGElement head = UnwrapWordElement(w);
// Noun Phrase
if (wps instanceof simplenlg.xmlrealiser.wrapper.XmlNPPhraseSpec) {
simplenlg.xmlrealiser.wrapper.XmlNPPhraseSpec wp = (simplenlg.xmlrealiser.wrapper.XmlNPPhraseSpec) wps;