public class SPhraseSpec extends PhraseElement
This class defines a clause (sentence-like phrase). It is essentially a
wrapper around the PhraseElement class, with methods for setting
common constituents such as Subject. For example, the setVerb
method in this class sets the head of the element to be the specified verb
From an API perspective, this class is a simplified version of the
SPhraseSpec class in simplenlg V3. It provides an alternative way for
creating syntactic structures, compared to directly manipulating a V4
PhraseElement.
Methods are provided for setting and getting the following constituents:
NOTE: The setModifier method will attempt to automatically determine whether a modifier should be expressed as a FrontModifier, PreModifier, or PostModifier
Features (such as negated) must be accessed via the setFeature
and getFeature methods (inherited from NLGElement).
Features which are often set on SPhraseSpec include
SPhraseSpec are produced by the createClause method
of a PhraseFactory
features| Constructor and Description |
|---|
SPhraseSpec(NLGFactory phraseFactory)
create an empty clause
|
| Modifier and Type | Method and Description |
|---|---|
void |
addComplement(NLGElement complement)
Adds a new complement to the phrase element.
|
void |
addComplement(String newComplement)
Adds a new complement to the phrase element.
|
void |
addModifier(Object modifier)
Add a modifier to a clause Use heuristics to decide where it goes
|
void |
addPreModifier(NLGElement newPreModifier)
Adds a new pre-modifier to the phrase element.
|
Object |
getFeature(String featureName)
Retrieves the value of the feature.
|
NLGElement |
getIndirectObject()
Returns the indirect object of a clause (assumes there is only one)
|
NLGElement |
getObject()
Returns the direct object of a clause (assumes there is only one)
|
NLGElement |
getSubject()
Returns the subject of a clause (assumes there is only one)
|
NLGElement |
getVerb()
Returns the verb of a clause
|
NLGElement |
getVerbPhrase() |
void |
setFeature(String featureName,
boolean featureValue)
A convenience method for setting boolean features.
|
void |
setFeature(String featureName,
Object featureValue)
adds a feature, possibly to the underlying VP as well as the SPhraseSpec
itself
|
void |
setIndirectObject(Object indirectObject)
Set the indirect object of a clause (assumes this is the only direct
indirect object)
|
void |
setObject(Object object)
Sets the direct object of a clause (assumes this is the only direct
object)
|
void |
setSubject(Object subject)
Sets the subject of a clause (assumes this is the only subject)
|
void |
setVerb(Object verb)
Set the verb of a clause
|
void |
setVerbPhrase(NLGElement vp) |
addFrontModifier, addFrontModifier, addPostModifier, addPostModifier, addPreModifier, clearComplements, getChildren, getFrontModifiers, getHead, getPostModifiers, getPreModifiers, printTree, setComplement, setComplement, setDeterminer, setFrontModifier, setFrontModifier, setHead, setPostModifier, setPostModifier, setPreModifier, setPreModifierclearAllFeatures, equals, equals, getAllFeatureNames, getAllFeatures, getCategory, getFactory, getFeatureAsBoolean, getFeatureAsDouble, getFeatureAsElement, getFeatureAsElementList, getFeatureAsFloat, getFeatureAsInteger, getFeatureAsList, getFeatureAsLong, getFeatureAsString, getFeatureAsStringList, getParent, getRealisation, getTense, hasFeature, isA, isNegated, isPlural, removeFeature, setCategory, setFactory, setFeature, setFeature, setFeature, setFeature, setNegated, setParent, setPlural, setRealisation, setTense, toStringpublic SPhraseSpec(NLGFactory phraseFactory)
public void setFeature(String featureName, Object featureValue)
setFeature in class NLGElementfeatureName - the name of the feature.featureValue - the new value of the feature or null if the
feature is to be removed.NLGElement.setFeature(java.lang.String,
java.lang.Object)public void addPreModifier(NLGElement newPreModifier)
PhraseElementaddPreModifier in class PhraseElementnewPreModifier - the new pre-modifier as an NLGElement.public void addComplement(NLGElement complement)
PhraseElementAdds 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.
addComplement in class PhraseElementcomplement - the new complement as an NLGElement.public void addComplement(String newComplement)
PhraseElementAdds 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.
addComplement in class PhraseElementnewComplement - the new complement as a String. It is used to
create a StringElement.public void setFeature(String featureName, boolean featureValue)
NLGElementsetFeature in class NLGElementfeatureName - the name of the feature.featureValue - the boolean value of the feature.public Object getFeature(String featureName)
NLGElementgetFeature in class NLGElementfeatureName - the name of the feature.Object value of the feature.public NLGElement getVerbPhrase()
public void setVerbPhrase(NLGElement vp)
public void setVerb(Object verb)
public NLGElement getVerb()
public void setSubject(Object subject)
public NLGElement getSubject()
public void setObject(Object object)
public NLGElement getObject()
public void setIndirectObject(Object indirectObject)
public NLGElement getIndirectObject()
public void addModifier(Object modifier)
addModifier in class PhraseElementCopyright © 2020. All Rights Reserved.