// Do nothing
}
@Override
public NLGElement realise(NLGElement element) {
NLGElement realisedComponent = null;
StringBuffer realisation = new StringBuffer();
if (element != null) {
ElementCategory category = element.getCategory();
List<NLGElement> components = element.getChildren();
//NB: The order of the if-statements below is important!
// check if this is a canned text first
if (element instanceof StringElement) {
realisation.append(element.getRealisation());
} else if (category instanceof DocumentCategory) {
// && element instanceof DocumentElement
String title = element instanceof DocumentElement ? ((DocumentElement) element)
.getTitle()
: null;
// String title = ((DocumentElement) element).getTitle();
switch ((DocumentCategory) category) {
case DOCUMENT:
case SECTION:
case LIST:
if (title != null) {
realisation.append(title).append('\n');
}
for (NLGElement eachComponent : components) {
realisedComponent = realise(eachComponent);
if (realisedComponent != null) {
realisation.append(realisedComponent
.getRealisation());
}
}
break;
case PARAGRAPH:
if (null != components && 0 < components.size()) {
realisedComponent = realise(components.get(0));
if (realisedComponent != null) {
realisation.append(realisedComponent
.getRealisation());
}
for (int i = 1; i < components.size(); i++) {
if (realisedComponent != null) {
realisation.append(' ');
}
realisedComponent = realise(components.get(i));
if (realisedComponent != null) {
realisation.append(realisedComponent
.getRealisation());
}
}
}
realisation.append("\n\n");
break;
case SENTENCE:
realisation.append(element.getRealisation());
break;
case LIST_ITEM:
// cch fix
//realisation.append(" * ").append(element.getRealisation()); //$NON-NLS-1$
realisation.append(" * "); //$NON-NLS-1$
for (NLGElement eachComponent : components) {
realisedComponent = realise(eachComponent);
if (realisedComponent != null) {
realisation.append(realisedComponent
.getRealisation());
if(components.indexOf(eachComponent) < components.size()-1) {
realisation.append(' ');
}
}
}
//finally, append newline
realisation.append("\n");
break;
}
// also need to check if element is a listelement (items can
// have embedded lists post-orthography) or a coordinate
} else if (element instanceof ListElement || element instanceof CoordinatedPhraseElement) {
for (NLGElement eachComponent : components) {
realisedComponent = realise(eachComponent);
if (realisedComponent != null) {
realisation.append(realisedComponent.getRealisation()).append(' ');
}
}
}
}