public class NLGFactory extends Object
This class contains methods for creating syntactic phrases. These methods should be used instead of directly invoking new on SPhraseSpec, etc.
The phrase factory should be linked to s lexicon if possible (although it will work without one)
| Constructor and Description |
|---|
NLGFactory()
Creates a new phrase factory with no associated lexicon.
|
NLGFactory(Lexicon newLexicon)
Creates a new phrase factory with the associated lexicon.
|
| Modifier and Type | Method and Description |
|---|---|
AdjPhraseSpec |
createAdjectivePhrase()
Creates a blank adjective phrase with no base adjective set.
|
AdjPhraseSpec |
createAdjectivePhrase(Object adjective)
Creates an adjective phrase wrapping the given adjective.
|
AdvPhraseSpec |
createAdverbPhrase()
Creates a blank adverb phrase that has no adverb.
|
AdvPhraseSpec |
createAdverbPhrase(String adverb)
Creates an adverb phrase wrapping the given adverb.
|
SPhraseSpec |
createClause()
Creates a blank clause with no subject, verb or objects.
|
SPhraseSpec |
createClause(Object subject,
Object verb)
Creates a clause with the given subject and verb but no objects.
|
SPhraseSpec |
createClause(Object subject,
Object verb,
Object directObject)
Creates a clause with the given subject, verb or verb phrase and direct
object but no indirect object.
|
CoordinatedPhraseElement |
createCoordinatedPhrase()
Creates a new (empty) coordinated phrase
|
CoordinatedPhraseElement |
createCoordinatedPhrase(Object coord1,
Object coord2)
Creates a new coordinated phrase with two elements (initially)
|
DocumentElement |
createDocument()
Creates a new document element with no title.
|
DocumentElement |
createDocument(String title)
Creates a new document element with the given title.
|
DocumentElement |
createDocument(String title,
List<DocumentElement> components)
Creates a new document element with the given title and adds all of the
given components in the list
|
DocumentElement |
createDocument(String title,
NLGElement component)
Creates a new document element with the given title and adds the given
component.
|
DocumentElement |
createEnumeratedList()
Creates a new enumerated list element with no components.
|
DocumentElement |
createEnumeratedList(List<DocumentElement> textComponents)
Creates a new enumerated list element and adds all of the given components in the
list
|
DocumentElement |
createEnumeratedList(NLGElement component)
Creates a new section element with the given title and adds the given
component.
|
NLGElement |
createInflectedWord(Object word,
LexicalCategory category)
Create an inflected word element.
|
DocumentElement |
createList()
Creates a new list element with no components.
|
DocumentElement |
createList(List<DocumentElement> textComponents)
Creates a new list element and adds all of the given components in the
list
|
DocumentElement |
createList(NLGElement component)
Creates a new section element with the given title and adds the given
component.
|
DocumentElement |
createListItem()
Creates a list item for adding to a list element.
|
DocumentElement |
createListItem(NLGElement component)
Creates a list item for adding to a list element.
|
NLGElement |
createNLGElement(Object element)
create an NLGElement from the element, no default lexical category
|
NLGElement |
createNLGElement(Object element,
LexicalCategory category)
this method creates an NLGElement from an object If object is null,
return null If the object is already an NLGElement, it is returned
unchanged Exception: if it is an InflectedWordElement, return underlying
WordElement If it is a String which matches a lexicon entry or pronoun,
the relevant WordElement is returned If it is a different String, a
wordElement is created if the string is a single word Otherwise a
StringElement is returned Otherwise throw an exception
|
NPPhraseSpec |
createNounPhrase()
Creates a blank noun phrase with no subject or specifier.
|
NPPhraseSpec |
createNounPhrase(Object noun)
Creates a noun phrase with the given subject but no specifier.
|
NPPhraseSpec |
createNounPhrase(Object specifier,
Object noun)
Creates a noun phrase with the given specifier and subject.
|
DocumentElement |
createParagraph()
Creates a new paragraph element with no components.
|
DocumentElement |
createParagraph(List<DocumentElement> components)
Creates a new paragraph element and adds all of the given components in
the list
|
DocumentElement |
createParagraph(NLGElement component)
Creates a new paragraph element and adds the given component
|
PPPhraseSpec |
createPrepositionPhrase()
Creates a blank preposition phrase with no preposition or complements.
|
PPPhraseSpec |
createPrepositionPhrase(Object preposition)
Creates a preposition phrase with the given preposition.
|
PPPhraseSpec |
createPrepositionPhrase(Object preposition,
Object complement)
Creates a preposition phrase with the given preposition and complement.
|
DocumentElement |
createSection()
Creates a new section element.
|
DocumentElement |
createSection(String title)
Creates a new section element with the given title.
|
DocumentElement |
createSection(String title,
List<DocumentElement> components)
Creates a new section element with the given title and adds all of the
given components in the list
|
DocumentElement |
createSection(String title,
NLGElement component)
Creates a new section element with the given title and adds the given
component.
|
DocumentElement |
createSentence()
Creates a new sentence element with no components.
|
DocumentElement |
createSentence(List<NLGElement> components)
Creates a new sentence element and adds all of the given components.
|
DocumentElement |
createSentence(NLGElement components)
Creates a new sentence element
|
DocumentElement |
createSentence(Object subject,
Object verb)
Creates a sentence with the given subject and verb.
|
DocumentElement |
createSentence(Object subject,
Object verb,
Object complement)
Creates a sentence with the given subject, verb and direct object.
|
DocumentElement |
createSentence(String cannedSentence)
Creates a new sentence with the given canned text.
|
NLGElement |
createStringElement()
Creates a blank canned text phrase with no text.
|
NLGElement |
createStringElement(String text)
Creates a canned text phrase with the given text.
|
VPPhraseSpec |
createVerbPhrase()
Creates a blank verb phrase with no main verb.
|
VPPhraseSpec |
createVerbPhrase(Object verb)
Creates a verb phrase wrapping the main verb given.
|
NLGElement |
createWord(Object word,
LexicalCategory category)
Creates a new element representing a word.
|
void |
setLexicon(Lexicon newLexicon)
Sets the lexicon to be used by this factory.
|
public NLGFactory()
public NLGFactory(Lexicon newLexicon)
newLexicon - the Lexicon to be used with this factory.public void setLexicon(Lexicon newLexicon)
null will remove any existing lexicon from the factory.newLexicon - the new Lexicon to be used.public NLGElement createWord(Object word, LexicalCategory category)
NLGElement then that is returned unchanged. If a
String is passed as the word then the factory will look up
the Lexicon if one exists and use the details found to
create a new WordElement.word - the base word for the new element. This can be a
NLGElement, which is returned unchanged, or a
String, which is used to construct a new
WordElement.category - the LexicalCategory for the word.NLGElement representing the word.public NLGElement createInflectedWord(Object word, LexicalCategory category)
WordElements, and features are set on phrases, it is
sometimes desirable to set features directly on words (for example, when
one wants to elide a specific word, but not its parent phrase).
If the object passed is already a WordElement, then a new
InflectedWordElement is returned which wraps this WordElement
. If the object is a String, then the
WordElement representing this String is looked
up, and a new
InflectedWordElement wrapping this is returned. If no such WordElement
is found, the element returned is an InflectedWordElement
with the supplied string as baseform and no base WordElement
. If an NLGElement is passed, this is returned unchanged.
word - the wordcategory - the categoryInflectedWordElement, or the original supplied
object if it is an NLGElement.public PPPhraseSpec createPrepositionPhrase()
PPPhraseSpec representing this phrase.public PPPhraseSpec createPrepositionPhrase(Object preposition)
preposition - the preposition to be used.PPPhraseSpec representing this phrase.public PPPhraseSpec createPrepositionPhrase(Object preposition, Object complement)
NLGElement representing the preposition is added as the
head feature of this phrase while the complement is added as a normal
phrase complement.preposition - the preposition to be used.complement - the complement of the phrase.PPPhraseSpec representing this phrase.public NLGElement createNLGElement(Object element, LexicalCategory category)
element - - object to look upcategory - - default lexical category of objectpublic NLGElement createNLGElement(Object element)
public NPPhraseSpec createNounPhrase()
NPPhraseSpec representing this phrase.public NPPhraseSpec createNounPhrase(Object noun)
noun - the subject of the phrase.NPPhraseSpec representing this phrase.public NPPhraseSpec createNounPhrase(Object specifier, Object noun)
specifier - the specifier or determiner for the noun phrase.noun - the subject of the phrase.NPPhraseSpec representing this phrase.public AdjPhraseSpec createAdjectivePhrase()
AdjPhraseSpec representing this phrase.public AdjPhraseSpec createAdjectivePhrase(Object adjective)
adjective - the main adjective for this phrase.AdjPhraseSpec representing this phrase.public VPPhraseSpec createVerbPhrase()
VPPhraseSpec representing this phrase.public VPPhraseSpec createVerbPhrase(Object verb)
String is passed in then some parsing is done to see if the
verb contains a particle, for example fall down. The first word
is taken to be the verb while all other words are assumed to form the
particle.verb - the verb to be wrapped.VPPhraseSpec representing this phrase.public AdvPhraseSpec createAdverbPhrase()
AdvPhraseSpec representing this phrase.public AdvPhraseSpec createAdverbPhrase(String adverb)
adverb - the adverb for this phrase.AdvPhraseSpec representing this phrase.public SPhraseSpec createClause()
SPhraseSpec representing this phrase.public SPhraseSpec createClause(Object subject, Object verb)
subject - the subject for the clause as a NLGElement or
String. This forms a noun phrase.verb - the verb for the clause as a NLGElement or
String. This forms a verb phrase.SPhraseSpec representing this phrase.public SPhraseSpec createClause(Object subject, Object verb, Object directObject)
subject - the subject for the clause as a NLGElement or
String. This forms a noun phrase.verb - the verb for the clause as a NLGElement or
String. This forms a verb phrase.directObject - the direct object for the clause as a NLGElement
or String. This forms a complement for the
clause.SPhraseSpec representing this phrase.public NLGElement createStringElement()
PhraseElement representing this phrase.public NLGElement createStringElement(String text)
text - the canned text.PhraseElement representing this phrase.public CoordinatedPhraseElement createCoordinatedPhrase()
CoordinatedPhraseElementpublic CoordinatedPhraseElement createCoordinatedPhrase(Object coord1, Object coord2)
coord1 - - first phrase to be coordinatedcoord2 - = second phrase to be coordinatedCoordinatedPhraseElement for the two given elementspublic DocumentElement createDocument()
DocumentElementpublic DocumentElement createDocument(String title)
title - the title for this element.DocumentElement.public DocumentElement createDocument(String title, List<DocumentElement> components)
title - the title of this element.components - a List of NLGElements that form the
components of this element.DocumentElementpublic DocumentElement createDocument(String title, NLGElement component)
title - the title for this element.component - an NLGElement that becomes the first component of
this document element.DocumentElementpublic DocumentElement createList()
DocumentElement representing the list.public DocumentElement createList(List<DocumentElement> textComponents)
textComponents - a List of NLGElements that form the
components of this element.DocumentElement representing the list.public DocumentElement createList(NLGElement component)
component - an NLGElement that becomes the first component of
this document element.DocumentElement representing the section.public DocumentElement createEnumeratedList()
DocumentElement representing the list.public DocumentElement createEnumeratedList(List<DocumentElement> textComponents)
textComponents - a List of NLGElements that form the
components of this element.DocumentElement representing the list.public DocumentElement createEnumeratedList(NLGElement component)
component - an NLGElement that becomes the first component of
this document element.DocumentElement representing the section.public DocumentElement createListItem()
DocumentElement representing the list item.public DocumentElement createListItem(NLGElement component)
DocumentElement representing the list item.public DocumentElement createParagraph()
DocumentElement representing this paragraphpublic DocumentElement createParagraph(List<DocumentElement> components)
components - a List of NLGElements that form the
components of this element.DocumentElement representing this paragraphpublic DocumentElement createParagraph(NLGElement component)
component - an NLGElement that becomes the first component of
this document element.DocumentElement representing this paragraphpublic DocumentElement createSection()
DocumentElement representing the section.public DocumentElement createSection(String title)
title - the title of the section.DocumentElement representing the section.public DocumentElement createSection(String title, List<DocumentElement> components)
title - the title of this element.components - a List of NLGElements that form the
components of this element.DocumentElement representing the section.public DocumentElement createSection(String title, NLGElement component)
title - the title for this element.component - an NLGElement that becomes the first component of
this document element.DocumentElement representing the section.public DocumentElement createSentence()
DocumentElement representing this sentencepublic DocumentElement createSentence(List<NLGElement> components)
components - a List of NLGElements that form the
components of this element.DocumentElement representing this sentencepublic DocumentElement createSentence(NLGElement components)
components - an NLGElement that becomes the first component of
this document element.DocumentElement representing this sentencepublic DocumentElement createSentence(Object subject, Object verb)
subject - the subject of the sentence.verb - the verb of the sentence.DocumentElement representing this sentencepublic DocumentElement createSentence(Object subject, Object verb, Object complement)
subject - the subject of the sentence.verb - the verb of the sentence.complement - the object of the sentence.DocumentElement representing this sentencepublic DocumentElement createSentence(String cannedSentence)
cannedSentence - the canned text as a String.DocumentElement representing this sentenceCopyright © 2020. All Rights Reserved.