public class PhraseElement extends NLGElement
This class defines a phrase. It covers the expected phrase types: noun
phrases, verb phrases, adjective phrases, adverb phrases and prepositional
phrases as well as also covering clauses. Phrases can be constructed from
scratch by setting the correct features of the phrase elements. However, it
is strongly recommended that the PhraseFactory is used to
construct phrases.
features| Constructor and Description |
|---|
PhraseElement(PhraseCategory newCategory)
Creates a new phrase of the given type.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addComplement(NLGElement newComplement)
Adds a new complement to the phrase element.
|
void |
addComplement(String newComplement)
Adds a new complement to the phrase element.
|
void |
addFrontModifier(NLGElement newFrontModifier)
Adds a new front modifier to the phrase element.
|
void |
addFrontModifier(String newFrontModifier)
Adds a new front modifier to the phrase element.
|
void |
addModifier(Object modifier)
Add a modifier to a phrase Use heuristics to decide where it goes
|
void |
addPostModifier(NLGElement newPostModifier)
Adds a new post-modifier to the phrase element.
|
void |
addPostModifier(String newPostModifier)
Adds a new post-modifier to the phrase element.
|
void |
addPreModifier(NLGElement newPreModifier)
Adds a new pre-modifier to the phrase element.
|
void |
addPreModifier(String newPreModifier)
Adds a new pre-modifier to the phrase element.
|
void |
clearComplements()
Removes all existing complements on the phrase.
|
List<NLGElement> |
getChildren()
This method retrieves the child components of this phrase.
|
List<NLGElement> |
getFrontModifiers()
Retrieves the current list of frony modifiers for the phrase.
|
NLGElement |
getHead()
Retrieves the current head of this phrase.
|
List<NLGElement> |
getPostModifiers()
Retrieves the current list of post modifiers for the phrase.
|
List<NLGElement> |
getPreModifiers()
Retrieves the current list of pre-modifiers for the phrase.
|
String |
printTree(String indent) |
void |
setComplement(NLGElement newComplement)
Sets a complement of the phrase element.
|
void |
setComplement(String newComplement)
Sets the complement to the phrase element.
|
void |
setDeterminer(Object newDeterminer)
Deprecated.
Use
NPPhraseSpec.setSpecifier(Object) directly |
void |
setFrontModifier(NLGElement newFrontModifier)
Set the front modifier for this phrase.
|
void |
setFrontModifier(String newFrontModifier)
Set the frontmodifier for this phrase.
|
void |
setHead(Object newHead)
Sets the head, or main component, of this current phrase.
|
void |
setPostModifier(NLGElement newPostModifier)
Set the postmodifier for this phrase.
|
void |
setPostModifier(String newPostModifier)
Set the postmodifier for this phrase.
|
void |
setPreModifier(NLGElement newPreModifier)
Set the premodifier for this phrase.
|
void |
setPreModifier(String newPreModifier)
Set the premodifier for this phrase.
|
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 PhraseElement(PhraseCategory newCategory)
newCategory - the PhraseCategory type for this phrase.public List<NLGElement> getChildren()
This method retrieves the child components of this phrase. The list
returned will depend on the category of the element.
getChildren in class NLGElementList of NLGElements representing the
child elements of this phrase.public void setHead(Object newHead)
Strings are converted to
StringElements. If null is passed in as the new
head then the head feature is removed.newHead - the new value for the head of this phrase.public NLGElement getHead()
NLGElement representing the head.public void addComplement(NLGElement newComplement)
Adds a new complement to the phrase element. Complements will be realised in the syntax after the head element of the phrase. Complements differ from post-modifiers in that complements are crucial to the understanding of a phrase whereas post-modifiers are optional.
If the new complement being added is a clause or a
CoordinatedPhraseElement then its clause status feature is
set to ClauseStatus.SUBORDINATE and it's discourse function
is set to DiscourseFunction.OBJECT by default unless an
existing discourse function exists on the complement.
Complements can have different functions. For example, the phrase John
gave Mary a flower has two complements, one a direct object and one
indirect. If a complement is not specified for its discourse function,
then this is automatically set to DiscourseFunction.OBJECT.
newComplement - the new complement as an NLGElement.public void setComplement(NLGElement newComplement)
Sets a complement of the phrase element. If a complement already exists
of the same DISCOURSE_FUNCTION, it is removed. This replaces complements
set earlier via addComplement(NLGElement)
newComplement - the new complement as an NLGElement.public void addComplement(String newComplement)
Adds a new complement to the phrase element. Complements will be realised in the syntax after the head element of the phrase. Complements differ from post-modifiers in that complements are crucial to the understanding of a phrase whereas post-modifiers are optional.
newComplement - the new complement as a String. It is used to
create a StringElement.public void setComplement(String newComplement)
Sets the complement to the phrase element. This replaces any complements set earlier.
newComplement - the new complement as a String. It is used to
create a StringElement.public void addPostModifier(NLGElement newPostModifier)
newPostModifier - the new post-modifier as an NLGElement.public void addPostModifier(String newPostModifier)
newPostModifier - the new post-modifier as a String. It is used to
create a StringElement.public void setPostModifier(String newPostModifier)
null and replaces them with the given
string.newPostModifier - the postmodifierpublic void setPostModifier(NLGElement newPostModifier)
null and replaces them with the given
string.newPostModifier - the postmodifierpublic void addFrontModifier(NLGElement newFrontModifier)
newFrontModifier - the new front modifier as an NLGElement.public void addFrontModifier(String newFrontModifier)
newFrontModifier - the new front modifier as a String. It is used to
create a StringElement.public void setFrontModifier(String newFrontModifier)
null and replaces them with the given string.newFrontModifier - the front modifierpublic void setFrontModifier(NLGElement newFrontModifier)
null and replaces them with the given string.newFrontModifier - the front modifierpublic void addPreModifier(NLGElement newPreModifier)
newPreModifier - the new pre-modifier as an NLGElement.public void addPreModifier(String newPreModifier)
newPreModifier - the new pre-modifier as a String. It is used to
create a StringElement.public void setPreModifier(String newPreModifier)
null and replaces them with the given
string.newPreModifier - the premodifierpublic void setPreModifier(NLGElement newPreModifier)
null and replaces them with the given
string.newPreModifier - the premodifierpublic void addModifier(Object modifier)
public List<NLGElement> getPreModifiers()
List of NLGElements.public List<NLGElement> getPostModifiers()
List of NLGElements.public List<NLGElement> getFrontModifiers()
List of NLGElements.public String printTree(String indent)
printTree in class NLGElementpublic void clearComplements()
@Deprecated public void setDeterminer(Object newDeterminer)
NPPhraseSpec.setSpecifier(Object) directlynewDeterminer - the new determiner for the phrase.Copyright © 2020. All Rights Reserved.