simplenlg.features.LexicalFeature Maven / Gradle / Ivy
Show all versions of SimpleNLG Show documentation
/*
* The contents of this file are subject to the Mozilla Public License
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* https://www.mozilla.org/en-US/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is "Simplenlg".
*
* The Initial Developer of the Original Code is Ehud Reiter, Albert Gatt and Dave Westwater.
* Portions created by Ehud Reiter, Albert Gatt and Dave Westwater are Copyright (C) 2010-11 The University of Aberdeen. All Rights Reserved.
*
* Contributor(s): Ehud Reiter, Albert Gatt, Dave Westwater, Roman Kutlak, Margaret Mitchell, and Saad Mahamood.
*/
package simplenlg.features;
import simplenlg.framework.ElementCategory;
import simplenlg.framework.LexicalCategory;
import simplenlg.framework.PhraseCategory;
/**
*
* This class defines a list of constant values used by SimpleNLG lexicons. Note
* that there are three feature classes in SimpleNLG.
*
* -
Feature
: features typically set up developers invoking
* SimpleNLG
* -
LexicalFeature
: features typically set up the SimpleNLG
* lexicon
* -
InternalFeature
: features typically used internally by
* SimpleNLG
*
*
* Elements in the system can, in theory, take any kind of feature. Some
* features will only be expected by certain processors, however. Developers can
* define their own features but should choose names that do not conflict with
* those presented here.
*
*
* The details for each feature are supplied in a table. The entries are:
*
*
*
* Feature name
* This is the name that will appear in the element's feature list as
* produced by the toString()
method or by calling
* getAllFeatureNames
*
*
* Expected type
* As features are represented as a Map
connecting a
* String
and an Object
then, in theory, a feature can
* take any object as a value. This table entry defines the type that the
* SimpleNLG system expects.
*
*
* Created by
* Defines where the feature is created. In addition, all features can be
* added specifically by users
*
*
* Used by
* Defines which processors use the feature.
*
*
* Applies to
* Defines which structural, syntactical or lexical elements this feature is
* applied to.
*
*
* Default
* Any default values attributed to the feature are given here.
*
*
*
*
* @author E. Reiter and D. Westwater, University of Aberdeen.
* @version 4.0
*/
@SuppressWarnings("nls")
public abstract class LexicalFeature {
/**
*
* This feature is used to map an acronym element to the full forms of the
* acronym.
*
*
*
* Feature name
* acronymOf
*
*
* Expected type
* List
*
*
* Created by
* Lexicons that support acronyms should set this feature.
*
*
* Used by
* No processors currently use this feature.
*
*
* Applies to
* Any lexical item.
*
*
* Default
* null
*
*
*/
public static final String ACRONYM_OF = "acronym_of";
/**
*
* This feature is used to map a word to its acronyms.
*
*
*
* Feature name
* acronyms
*
*
* Expected type
* List
*
*
* Created by
* Lexicons that support acronyms should set this feature.
*
*
* Used by
* No processors currently use this feature.
*
*
* Applies to
* Any lexical item.
*
*
* Default
* null
*
*
*/
public static final String ACRONYMS = "acronyms";
/*
* This feature is used to list all the possible inflectional variants
* of a word. For example, the word fish can be both uncount
* (plural: fish) and reg (plural: fishes).
Feature name infl
* Expected type
* List
Created
* by Lexicons that support inflectional variants should set
* this feature. Used by No processors
* currently use this feature. Applies to
* Any lexical item. Default
* null
*/
// public static final String INFLECTIONS = "infl";
/**
*
* This feature is used to specify, for a given word, what its default
* inflectional variant is, if more than one is possible.
*
*
*
* Feature name
* default_infl
*
*
* Expected type
* Inflection
*
*
* Created by
* Lexicons that support multiple inflectional variants should set this
* feature.
*
*
* Used by
* {@link simplenlg.morphology.english.MorphologyProcessor}.
*
*
* Applies to
* Nouns and verbs.
*
*
* Default
* null
*
*
*/
public static final String DEFAULT_INFL = "default_infl";
/**
*
* This feature is used to specify the spelling variants of a word.
*
*
*
* Feature name
* spell_vars
*
*
* Expected type
* List
*
*
* Created by
* Lexicons that support multiple spelling variants should set this
* feature.
*
*
* Used by
* No processors currently use this feature.
*
*
* Applies to
* Any lexical item.
*
*
* Default
* null
*
*
*/
public static final String SPELL_VARS = "spell_vars";
/**
*
* This feature is used to specify the default spelling variant of a word,
* if it has more than one.
*
*
*
* Feature name
* default_spell
*
*
* Expected type
* String
*
*
* Created by
* Lexicons that support multiple spelling variants should set this
* feature.
*
*
* Used by
* {@link simplenlg.morphology.english.MorphologyProcessor}
*
*
* Applies to
* Any lexical item.
*
*
* Default
* null
*
*
*/
public static final String DEFAULT_SPELL = "default_spell";
/**
*
* This feature is used to define the base form for phrases and words.
*
*
*
* Feature name
* baseForm
*
*
* Expected type
* String
*
*
* Created by
* The lexicon accessor also creates the feature when looking up words
* in the lexicon. Sometimes the phrase factory sets this feature as well,
* as an approximate realisation for debuggin purposes
*
*
* Used by
* The morphology processor uses the base form in its simple rules for
* determining word inflection. The morphology processor and syntax
* processor also use the base form for lexicon look ups if the base word
* has not been set. Base forms on phrases are purely to aid debugging.
*
*
* Applies to
* Phrases and words.
*
*
* Default
* null
*
*
*/
public static final String BASE_FORM = "base_form";
/**
*
* This feature is used for determining the position of adjectives. Setting
* this value to true means that the adjective can occupy the
* classifying position.
*
*
*
* Feature name
* classifying
*
*
* Expected type
* Boolean
*
*
* Created by
* Any lexicon that supports adjective positioning.
*
*
* Used by
* The syntax processor to determine the ordering of adjectives.
*
*
* Applies to
* Adjectives within noun phrases.
*
*
* Default
* Boolean.FALSE
*
*
*/
public static final String CLASSIFYING = "classifying";
/**
*
* This feature is used for determining the position of adjectives. Setting
* this value to true means that the adjective can occupy the
* colour position.
*
*
*
* Feature name
* colour
*
*
* Expected type
* Boolean
*
*
* Created by
* Any lexicon that supports adjective positioning.
*
*
* Used by
* The syntax processor to determine the ordering of adjectives.
*
*
* Applies to
* Adjectives within noun phrases.
*
*
* Default
* Boolean.FALSE
*
*
*/
public static final String COLOUR = "colour";
/**
*
* This feature gives the comparative form for adjectives and adverbs. For
* example, dizzier is the comparative form of dizzy,
* fatter is the comparative form of fat and
* earlier is the comparative form of early.
*
*
*
* Feature name
* comparative
*
*
* Expected type
* String
*
*
* Created by
* Can be created automatically by the lexicon or added manually by
* users.
*
*
* Used by
* The morphology processor uses this information to correctly inflect
* words.
*
*
* Applies to
* Adjectives and adverbs only.
*
*
* Default
* null
*
*
*/
public static final String COMPARATIVE = "comparative";
/**
*
* This feature determines if a verb is ditransitive, meaning that it can
* have a subject, direct object and indirect object. For example in the
* phrase he gave Mary ten pounds, the verb give has three
* components: the subject is the person doing the giving (he), the
* direct object is the object being passed (ten pounds) and the
* indirect object is the recipient (Mary).
*
*
*
* Feature name
* ditransitive
*
*
* Expected type
* Boolean
*
*
* Created by
* The feature is set by the lexicon if it supports the recording of the
* transitive nature of verbs.
*
*
* Used by
* The ditransitive value is currently not used.
*
*
* Applies to
* Verbs only.
*
*
* Default
* Boolean.FALSE
*
*
*/
public static final String DITRANSITIVE = "ditransitive";
/**
*
* This feature determines whether a noun is masculine, feminine or neuter
* in nature.
*
*
*
* Feature name
* gender
*
*
* Expected type
* Gender
*
*
* Created by
* The phrase factory creates the gender of pronouns when creating
* phrases and on all nouns within a noun phrase.
*
*
* Used by
* The syntax processor ensures that the head noun in a noun phrase has
* a gender matching that applied to the phrase as a whole. The morphology
* processor uses gender to determine the appropriate form for pronouns and
* for setting the form of some verbs.
*
*
* Applies to
* Specifically it applies to nouns and pronouns but the feature is also
* written to noun phrases and verbs.
*
*
* Default
* Gender.NEUTER
*
*
*/
public static final String GENDER = "gender";
/**
*
* This flag determines if an adverb is an intensifier, such as
* very.
*
*
*
* Feature name
* intensifier
*
*
* Expected type
* Boolean
*
*
* Created by
* The information is read from Lexicons that support this feature.
*
*
* Used by
* Currently not used.
*
*
* Applies to
* Adverbs only.
*
*
* Default
* Boolean.FALSE
.
*
*
*/
public static final String INTENSIFIER = "intensifier";
/**
*
* This flag highlights a verb that can only take a subject and no objects.
*
*
*
* Feature name
* intransitive
*
*
* Expected type
* Boolean
*
*
* Created by
* The information is read from Lexicons that support this feature.
*
*
* Used by
* Currently not used.
*
*
* Applies to
* Verbs only.
*
*
* Default
* Boolean.FALSE
.
*
*
*/
public static final String INTRANSITIVE = "intransitive";
/*
* This feature represents non-countable nouns such as mud,
* sand and water.
* Feature name nonCount
* Expected type Boolean
* Created by Supporting lexicons.
* Used by The morphology processor will not pluralise
* non-countable nouns. Applies to Nouns
* only. Default
* Boolean.FALSE
.
*/
// public static final String NON_COUNT = "nonCount";
/**
*
* This feature gives the past tense form of a verb. For example, the past
* tense of eat is ate, the past tense of walk is
* walked.
*
*
*
* Feature name
* past
*
*
* Expected type
* String
*
*
* Created by
* All supporting lexicons but can be set by the user for irregular
* cases.
*
*
* Used by
* The morphology processor uses this feature to correctly inflect
* verbs. This feature will be looked at first before any reference to
* lexicons or morphology rules.
*
*
* Applies to
* Verbs and verb phrases only.
*
*
* Default
* null
.
*
*
*/
public static final String PAST = "past";
/**
*
* This feature gives the past participle tense form of a verb. For many
* verbs the past participle is exactly the same as the past tense, for
* example, the verbs talk, walk and say have
* past tense and past participles of talked, walked and
* said. Contrast this with the verbs do, eat and
* sing. The past tense of these verbs is did,
* ate and sang respectively. while the respective past
* participles are done, eaten and sung
*
*
*
* Feature name
* pastParticiple
*
*
* Expected type
* String
*
*
* Created by
* All supporting lexicons but can be set by the user for irregular
* cases.
*
*
* Used by
* The morphology processor uses this feature to correctly inflect
* verbs. This feature will be looked at first before any reference to
* lexicons or morphology rules.
*
*
* Applies to
* Verbs and verb phrases only.
*
*
* Default
* null
.
*
*
*/
public static final String PAST_PARTICIPLE = "pastParticiple";
/**
*
* This feature gives the plural form of a noun. For example, the plural of
* dog is dogs and the plural of sheep is
* sheep.
*
*
*
* Feature name
* plural
*
*
* Expected type
* String
*
*
* Created by
* All supporting lexicons but can be set by the user for irregular
* cases.
*
*
* Used by
* The morphology processor uses this feature to correctly inflect
* plural nouns. This feature will be looked at first before any reference
* to lexicons or morphology rules.
*
*
* Applies to
* Nouns only.
*
*
* Default
* null
.
*
*
*/
public static final String PLURAL = "plural";
/**
*
* This flag is set on adjectives that can also be used as a predicate. For
* example happy.
*
*
*
* Feature name
* predicative
*
*
* Expected type
* Boolean
*
*
* Created by
* Any supporting lexicon.
*
*
* Used by
* Currently not used.
*
*
* Applies to
* Adjectives only.
*
*
* Default
* Boolean.FALSE
.
*
*
*/
public static final String PREDICATIVE = "predicative";
/**
*
* This feature gives the present participle form of a verb. For example,
* the present participle form of eat is eating and the
* present participle form of walk is walking.
*
*
*
* Feature name
* presentParticiple
*
*
* Expected type
* String
*
*
* Created by
* All supporting lexicons but can be set by the user for irregular
* cases.
*
*
* Used by
* The morphology processor uses this feature to correctly inflect
* verbs. This feature will be looked at first before any reference to
* lexicons or morphology rules.
*
*
* Applies to
* Verbs only.
*
*
* Default
* null
.
*
*
*/
public static final String PRESENT_PARTICIPLE = "presentParticiple";
/**
*
* This feature gives the present third person singular form of a verb. For
* example, the present participle form of eat is eats as
* in the dog eats. Another example is ran being the
* present third person singular form of run as in
* John ran home.
*
*
*
* Feature name
* present3s
*
*
* Expected type
* String
*
*
* Created by
* All supporting lexicons but can be set by the user for irregular
* cases.
*
*
* Used by
* The morphology processor uses this feature to correctly inflect
* verbs. This feature will be looked at first before any reference to
* lexicons or morphology rules.
*
*
* Applies to
* Verbs only.
*
*
* Default
* null
.
*
*
*/
public static final String PRESENT3S = "present3s";
/**
*
* This flag is used to determine whether a noun is a proper noun, such as a
* person's name.
*
*
*
* Feature name
* proper
*
*
* Expected type
* Boolean
*
*
* Created by
* Can be set by supporting lexicons or by the user.
*
*
* Used by
* The morphology processor will not pluralise proper nouns.
*
*
* Applies to
* Nouns only.
*
*
* Default
* Boolean.FALSE
.
*
*
*/
public static final String PROPER = "proper";
/**
*
* This feature is used for determining the position of adjectives. Setting
* this value to true means that the adjective can occupy the
* qualitative position.
*
*
*
* Feature name
* qualitative
*
*
* Expected type
* Boolean
*
*
* Created by
* Any lexicon that supports adjective positioning.
*
*
* Used by
* The syntax processor to determine the ordering of adjectives.
*
*
* Applies to
* Adjectives within noun phrases.
*
*
* Default
* Boolean.FALSE
*
*
*/
public static final String QUALITATIVE = "qualitative";
/**
*
* This flag is set if a pronoun is written in the reflexive form. For
* example, myself, yourself, ourselves.
*
*
*
* Feature name
* isReflexive
*
*
* Expected type
* Boolean
*
*
* Created by
* The phrase factory will recognise personal pronouns in reflexive
* form.
*
*
* Used by
* The morphology processor will correctly inflect reflexive pronouns.
*
*
* Applies to
* Pronouns only.
*
*
* Default
* Boolean.FALSE
*
*
*/
public static final String REFLEXIVE = "reflexive";
/**
*
* This feature is used to define whether an adverb can be used as a clause
* modifier, which are normally applied at the beginning of clauses. For
* example, unfortunately.
*
*
*
* Feature name
* sentenceModifier
*
*
* Expected type
* Boolean
*
*
* Created by
* Any lexicon that supports this feature.
*
*
* Used by
* generic addModifier methods, to decide where to put an adverb
*
*
* Applies to
* Adverbs only.
*
*
* Default
* Boolean.FALSE
*
*
*/
public static final String SENTENCE_MODIFIER = "sentence_modifier";
/**
*
* This feature gives the superlative form for adjectives and adverbs. For
* example, fattest is the superlative form of fat and
* earliest is the superlative form of early.
*
*
*
* Feature name
* superlative
*
*
* Expected type
* String
*
*
* Created by
* Can be created automatically by the lexicon or added manually by
* users.
*
*
* Used by
* The morphology processor uses this information to correctly inflect
* words.
*
*
* Applies to
* Adjectives and adverbs only.
*
*
* Default
* null
*
*
*/
public static final String SUPERLATIVE = "superlative";
/**
*
* This flag highlights a verb that can only take a subject and an object.
*
*
*
* Feature name
* transitive
*
*
* Expected type
* Boolean
*
*
* Created by
* Any lexicon supporting this feature.
*
*
* Used by
* Currently not used.
*
*
* Applies to
* Verbs only.
*
*
* Default
* Boolean.FALSE
.
*
*
*/
public static final String TRANSITIVE = "transitive";
/**
*
* This feature is used to define whether an adverb can be used as a verb
* modifier, which are normally added in a phrase before the verb itself.
* For example, quickly.
*
*
*
* Feature name
* verbModifier
*
*
* Expected type
* Boolean
*
*
* Created by
* Any lexicon that supports this feature.
*
*
* Used by
* generic addModifier methods, to decide where to put an adverb.
*
*
* Applies to
* Adverbs only.
*
*
* Default
* Boolean.FALSE
*
*
*/
public static final String VERB_MODIFIER = "verb_modifier";
/**
*
* This feature determines if the pronoun is an expletive or not. Expletive
* pronouns are usually it or there in sentences such as:
* It is raining now.
* There are ten desks in the room.
*
*
*
* Feature name
* isExpletive
*
*
* Expected type
* Boolean
*
*
* Created by
* The feature needs to be set by the user.
*
*
* Used by
* The syntax processor uses the expletive on verb phrases for
* determining the correct number agreement.
*
*
* Applies to
* Certain pronouns when used as subjects of verb phrases.
*
*
* Default
* Boolean.FALSE
*
*
*/
public static final String EXPLETIVE_SUBJECT = "expletive_subject";
/**
* The constructor is never needed.
*/
private LexicalFeature() {
// do nothing
}
/**
* Return those features related to a word's inflection, depending on its
* category, that is, the constants for
* PAST, PAST_PARTICIPLE, PLURAl, PRESENT_PARTICIPLE, PRESENT3S, COMPARATIVE
* or SUPERLATIVE
.
*
* @param cat the category
* @return the inflectional feature names
*/
public static String[] getInflectionalFeatures(ElementCategory cat) {
if(PhraseCategory.NOUN_PHRASE.equals(cat) || LexicalCategory.NOUN.equals(cat))
return new String[]{PLURAL};
else if(PhraseCategory.VERB_PHRASE.equals(cat) || LexicalCategory.VERB.equals(cat))
return new String[]{PAST, PAST_PARTICIPLE, PRESENT_PARTICIPLE, PRESENT3S};
else if(PhraseCategory.ADJECTIVE_PHRASE.equals(cat) || LexicalCategory.ADJECTIVE.equals(cat))
return new String[]{COMPARATIVE, SUPERLATIVE};
else
return null;
}
}