public class WordElement extends NLGElement
Lexicon, and usually the developer retrieves a
WordElement via a lookup method in the lexicon
Words always have a base form, and usually have a
LexicalCategory. They may also have a Lexicon ID.
Words also have features (which are retrieved from the Lexicon), these are held in the standard NLGElement feature map
features| Constructor and Description |
|---|
WordElement()
empty constructor
|
WordElement(String baseForm)
create a WordElement with the specified baseForm (no category or ID
specified)
|
WordElement(String baseForm,
LexicalCategory category)
create a WordElement with the specified baseForm and category
|
WordElement(String baseForm,
LexicalCategory category,
String id)
create a WordElement with the specified baseForm, category, ID
|
WordElement(WordElement currentWord)
creates a duplicate WordElement from an existing WordElement
|
| Modifier and Type | Method and Description |
|---|---|
void |
addInflectionalVariant(Inflection infl)
Specify that this word has an inflectional variant (e.g.
|
void |
addInflectionalVariant(Inflection infl,
String lexicalFeature,
String form)
Add an inflectional variant to this word element.
|
boolean |
equals(Object o)
Check if this WordElement is equal to an object.
|
String |
getBaseForm() |
List<NLGElement> |
getChildren()
This method returns an empty
List as words do not have child
elements. |
Object |
getDefaultInflectionalVariant() |
String |
getDefaultSpellingVariant()
Convenience method, equivalent to
getFeatureAsString(LexicalFeature.DEFAULT_SPELL). |
String |
getId() |
Map<Inflection,simplenlg.framework.WordElement.InflectionSet> |
getInflectionalVariants()
Convenience method to get all the inflectional forms of the word.
|
boolean |
hasInflectionalVariant(Inflection infl)
Check whether this word has a particular inflectional variant
|
String |
printTree(String indent) |
void |
setBaseForm(String baseForm) |
void |
setDefaultInflectionalVariant(Inflection variant)
Set the default inflectional variant of a word.
|
void |
setDefaultSpellingVariant(String variant)
Convenience method to set the default spelling variant of a word.
|
void |
setFeatures(WordElement currentWord)
Sets Features from another existing WordElement into this WordElement.
|
void |
setId(String id) |
String |
toString() |
String |
toXML() |
clearAllFeatures, 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, setTensepublic WordElement()
public WordElement(String baseForm)
baseForm - - base form of WordElementpublic WordElement(String baseForm, LexicalCategory category)
baseForm - - base form of WordElementcategory - - category of WordElementpublic WordElement(String baseForm, LexicalCategory category, String id)
baseForm - - base form of WordElementcategory - - category of WordElementid - - ID of word in lexiconpublic WordElement(WordElement currentWord)
currentWord - - An existing WordElementpublic String getBaseForm()
public String getId()
public void setBaseForm(String baseForm)
baseForm - the baseForm to setpublic void setId(String id)
id - the id to setpublic void setDefaultInflectionalVariant(Inflection variant)
If the default inflectional variant is set, the inflectional forms of the
word may change as a result. This depends on whether inflectional forms
have been specifically associated with this variant, via
addInflectionalVariant(Inflection, String, String).
The NIHDBLexicon associates different inflectional variants
with words, if they are so specified, and adds the correct forms.
variant - The variantpublic Object getDefaultInflectionalVariant()
public Map<Inflection,simplenlg.framework.WordElement.InflectionSet> getInflectionalVariants()
public void setDefaultSpellingVariant(String variant)
setFeature(LexicalFeature.DEFAULT_SPELL, variant).
By default, the spelling variant used is the base form. If otherwise set, this forces the realiser to always use the spelling variant specified.
variant - The spelling variantpublic String getDefaultSpellingVariant()
getFeatureAsString(LexicalFeature.DEFAULT_SPELL). If this
feature is not set, the baseform is returned.public void addInflectionalVariant(Inflection infl, String lexicalFeature, String form)
Lexicon. The idea is that words which have more
than one inflectional variant (for example, a regular and an irregular
form of the past tense), can have a default variant (for example, the
regular), but also store information about the other variants. This comes
in useful in case the default inflectional variant is reset to a new one.
In that case, the stored forms for the new variant are used to inflect
the word.
An example: The verb lie has both a regular form
(lies, lied, lying) and an irregular form (lay, lain, etc).
Assume that the Lexicon provides this information and treats
this as variant information of the same word (as does the
NIHDBLexicon, for example). Typically, the default
inflectional variant is the Inflection.REGULAR. This means
that morphology proceeds to inflect the verb as lies, lying and so
on. If the default inflectional variant is reset to
Inflection.IRREGULAR, the stored irregular forms will be
used instead.
infl - the Inflection pattern with which this form is associatedlexicalFeature - the actual inflectional feature being set, for example
LexicalFeature.PRESENT_3Sform - the actual inflected word formpublic void addInflectionalVariant(Inflection infl)
infl - the variantpublic boolean hasInflectionalVariant(Inflection infl)
infl - the varianttrue if this word has the variantpublic void setFeatures(WordElement currentWord)
currentWord - the WordElement to copy features frompublic String toString()
toString in class NLGElementpublic String toXML()
public List<NLGElement> getChildren()
List as words do not have child
elements.getChildren in class NLGElementList of NLGElements representing the
children of this element.public String printTree(String indent)
printTree in class NLGElementpublic boolean equals(Object o)
equals in class NLGElemento - the objecttrue iff the object is a word element with the same
id and the same baseform and the same features.Copyright © 2020. All Rights Reserved.