public class DocumentElement extends NLGElement
DocumentElement is a convenient extension of the base
NLGElement class. It used to define elements that form part of
the textual structure (documents, sections, paragraphs, sentences, lists). It
essentially operates as the base class with the addition of some convenience
methods for getting and setting features specific to this type of element.
TextElements can be structured in a tree-like structure where
elements can contain child components. These child components can in turn
contain other child components and so on. There are restrictions on the type
of child components a particular element type can have. These are explained
under the DocumentCategory enumeration.
Instances of this class can be created through the static create methods in
the OrthographyProcessor.
features| Constructor and Description |
|---|
DocumentElement()
The blank constructor.
|
DocumentElement(DocumentCategory category,
String textTitle)
Creates a new DocumentElement with the given category and title.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addComponent(NLGElement element)
Add a single child component to the current list of child components.
|
void |
addComponents(List<?> textComponents)
Adds a collection of
NLGElements to the list of child
components. |
void |
clearComponents()
Removes all the child components from this element.
|
List<NLGElement> |
getChildren()
Child elements of a
DocumentElement are the components. |
List<NLGElement> |
getComponents()
Retrieves the child components of this element.
|
String |
getTitle()
Retrieves the title of this element.
|
String |
printTree(String indent) |
boolean |
removeComponent(NLGElement textComponent)
Removes the specified component from the list of child components.
|
void |
setComponents(List<NLGElement> components)
Replaces the existing components with the supplied list of components.
|
void |
setTitle(String textTitle)
Sets the title of this element.
|
clearAllFeatures, equals, equals, getAllFeatureNames, getAllFeatures, getCategory, getFactory, getFeature, getFeatureAsBoolean, getFeatureAsDouble, getFeatureAsElement, getFeatureAsElementList, getFeatureAsFloat, getFeatureAsInteger, getFeatureAsList, getFeatureAsLong, getFeatureAsString, getFeatureAsStringList, getParent, getRealisation, getTense, hasFeature, isA, isNegated, isPlural, removeFeature, setCategory, setFactory, setFeature, setFeature, setFeature, setFeature, setFeature, setFeature, setNegated, setParent, setPlural, setRealisation, setTense, toStringpublic DocumentElement()
public DocumentElement(DocumentCategory category, String textTitle)
category - the category for this element.textTitle - the title of this element, predominantly used with DOCUMENT
and SECTION types.public void setTitle(String textTitle)
textTitle - the new title for this element.public String getTitle()
public List<NLGElement> getComponents()
List of NLGElements representing the
child components.public void addComponent(NLGElement element)
Add a single child component to the current list of child components. If there are no existing child components a new list is created.
Note that there are restrictions on which child types can be added to
which parent types. Intermediate nodes are added if necessary; eg,
if a sentence is added to a document, the sentence will be embedded
in a paragraph before it is added
See
DocumentCategory for further information.
element - the NLGElement to be added. If this is
NULL the method does nothing.public void addComponents(List<?> textComponents)
Adds a collection of NLGElements to the list of child
components. If there are no existing child components, then a new list is
created.
As with addComponents(...) only legitimate child types are
added to the list.
textComponents - the List of NLGElements to be added.
If this is NULL the method does nothing.public boolean removeComponent(NLGElement textComponent)
textComponent - the component to be removed.true if the element was removed, or
false if the element did not exist, there is no
component list or the the given component to remove is
NULL.public void clearComponents()
public List<NLGElement> getChildren()
DocumentElement are the components. This
method is the same as calling getComponents().getChildren in class NLGElementList of NLGElements representing the
children of this element.public void setComponents(List<NLGElement> components)
clearComponents();
addComponents(components);
public String printTree(String indent)
printTree in class NLGElementCopyright © 2020. All Rights Reserved.