示例#1
0
        /**
         * Creates a new sentence element
         *
         * @param components
         *            an <code>NLGElement</code> that becomes the first component of
         *            this document element.
         * @return a <code>DocumentElement</code> representing this sentence
         */
        public virtual DocumentElement createSentence(NLGElement components)
        {
            DocumentElement sentence = new DocumentElement(new DocumentCategory(DocumentCategory.DocumentCategoryEnum.SENTENCE), null);

            sentence.addComponent(components);
            return(sentence);
        }
示例#2
0
        /**
         * Creates a new list element and adds all of the given components in the
         * list
         *
         * @param textComponents
         *            a <code>List</code> of <code>NLGElement</code>s that form the
         *            components of this element.
         * @return a <code>DocumentElement</code> representing the list.
         */
        public virtual DocumentElement createList(IList <DocumentElement> textComponents)
        {
            DocumentElement list = new DocumentElement(new DocumentCategory(DocumentCategory.DocumentCategoryEnum.LIST), null);

            list.addComponents(textComponents);
            return(list);
        }
示例#3
0
        /**
         * Creates a sentence with the given subject, verb and direct object. The
         * phrase factory is used to construct a clause that then forms the
         * components of the sentence.
         *
         * @param subject
         *            the subject of the sentence.
         * @param verb
         *            the verb of the sentence.
         * @param complement
         *            the object of the sentence.
         * @return a <code>DocumentElement</code> representing this sentence
         */
        public virtual DocumentElement createSentence(object subject, object verb, object complement)
        {
            DocumentElement sentence = new DocumentElement(new DocumentCategory(DocumentCategory.DocumentCategoryEnum.SENTENCE), null);

            sentence.addComponent(createClause(subject, verb, complement));
            return(sentence);
        }
示例#4
0
        /**
         * Creates a list item for adding to a list element. The list item has the
         * given component.
         *
         * @return a <code>DocumentElement</code> representing the list item.
         */
        public virtual DocumentElement createListItem(NLGElement component)
        {
            DocumentElement listItem = new DocumentElement(new DocumentCategory(DocumentCategory.DocumentCategoryEnum.LIST_ITEM), null);

            listItem.addComponent(component);
            return(listItem);
        }
示例#5
0
        /**
         * Creates a new section element with the given title and adds the given
         * component.
         *
         * @param component
         *            an <code>NLGElement</code> that becomes the first component of
         *            this document element.
         * @return a <code>DocumentElement</code> representing the section.
         * @author Rodrigo de Oliveira - Data2Text Ltd
         */
        public virtual DocumentElement createEnumeratedList(NLGElement component)
        {
            DocumentElement list = new DocumentElement(new DocumentCategory(DocumentCategory.DocumentCategoryEnum.ENUMERATED_LIST), null);

            list.addComponent(component);
            return(list);
        }
        /** promote an NLGElement so that it is at the right level to be added to a DocumentElement/
         * Promotion means adding surrounding nodes at higher doc levels
         * @param element
         * @return
         */
        private NLGElement promote(NLGElement element)
        {
            // check if promotion needed
            if (((DocumentCategory)Category).hasSubPart(element.Category))
            {
                return(element);
            }
            // if element is not a DocumentElement, embed it in a sentence and recurse
            if (!(element is DocumentElement))
            {
                DocumentElement sentence = new DocumentElement(new DocumentCategory(DocumentCategory.DocumentCategoryEnum.SENTENCE), null);
                sentence.addElementToComponents(element);
                return(promote(sentence));
            }

            // if element is a Sentence, promote it to a paragraph
            if (element.Category.Equals(DocumentCategory.DocumentCategoryEnum.SENTENCE))
            {
                DocumentElement paragraph = new DocumentElement(new DocumentCategory(DocumentCategory.DocumentCategoryEnum.PARAGRAPH), null);
                paragraph.addElementToComponents(element);
                return(promote(paragraph));
            }

            // otherwise can't do anything
            return(null);
        }
示例#7
0
        /**
         * Creates a new document element with the given title and adds the given
         * component.
         *
         * @param title
         *            the title for this element.
         * @param component
         *            an <code>NLGElement</code> that becomes the first component of
         *            this document element.
         * @return a <code>DocumentElement</code>
         */
        public virtual DocumentElement createDocument(string title, NLGElement component)
        {
            DocumentElement element = new DocumentElement(new DocumentCategory(DocumentCategory.DocumentCategoryEnum.DOCUMENT), title);

            if (component != null)
            {
                element.addComponent(component);
            }
            return(element);
        }
示例#8
0
        /**
         * Creates a new document element with the given title and adds all of the
         * given components in the list
         *
         * @param title
         *            the title of this element.
         * @param components
         *            a <code>List</code> of <code>NLGElement</code>s that form the
         *            components of this element.
         * @return a <code>DocumentElement</code>
         */
        public virtual DocumentElement createDocument(string title, IList <DocumentElement> components)
        {
            DocumentElement document = new DocumentElement(new DocumentCategory(DocumentCategory.DocumentCategoryEnum.DOCUMENT), title);

            if (components != null)
            {
                document.addComponents(components);
            }
            return(document);
        }
示例#9
0
        /**
         * Creates a new sentence with the given canned text. The canned text is
         * used to form a canned phrase (from the phrase factory) which is then
         * added as the component to sentence element.
         *
         * @param cannedSentence
         *            the canned text as a <code>String</code>.
         * @return a <code>DocumentElement</code> representing this sentence
         */
        public virtual DocumentElement createSentence(string cannedSentence)
        {
            DocumentElement sentence = new DocumentElement(new DocumentCategory(DocumentCategory.DocumentCategoryEnum.SENTENCE), null);

            if (!ReferenceEquals(cannedSentence, null))
            {
                sentence.addComponent(createStringElement(cannedSentence));
            }
            return(sentence);
        }
示例#10
0
        /**
         * Creates a new section element with the given title and adds the given
         * component.
         *
         * @param title
         *            the title for this element.
         * @param component
         *            an <code>NLGElement</code> that becomes the first component of
         *            this document element.
         * @return a <code>DocumentElement</code> representing the section.
         */
        public virtual DocumentElement createSection(string title, NLGElement component)
        {
            DocumentElement section = new DocumentElement(new DocumentCategory(DocumentCategory.DocumentCategoryEnum.SECTION), title);

            if (component != null)
            {
                section.addComponent(component);
            }
            return(section);
        }
示例#11
0
        /**
         * Creates a new paragraph element and adds the given component
         *
         * @param component
         *            an <code>NLGElement</code> that becomes the first component of
         *            this document element.
         * @return a <code>DocumentElement</code> representing this paragraph
         */
        public virtual DocumentElement createParagraph(NLGElement component)
        {
            DocumentElement paragraph = new DocumentElement(new DocumentCategory(DocumentCategory.DocumentCategoryEnum.PARAGRAPH), null);

            if (component != null)
            {
                paragraph.addComponent(component);
            }
            return(paragraph);
        }