Пример #1
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 DocumentElement createSentence(object subject, object verb, object complement)
        {
            var sentence = new DocumentElement(new DocumentCategory_SENTENCE(), null);

            sentence.addComponent(createClause(subject, verb, complement));
            return(sentence);
        }
Пример #2
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 DocumentElement createListItem(INLGElement component)
        {
            var listItem = new DocumentElement(new DocumentCategory_LIST_ITEM(), null);

            listItem.addComponent(component);
            return(listItem);
        }
Пример #3
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 DocumentElement createSentence(INLGElement components)
        {
            var sentence = new DocumentElement(new DocumentCategory_SENTENCE(), null);

            sentence.addComponent(components);
            return(sentence);
        }
Пример #4
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 DocumentElement createEnumeratedList(INLGElement component)
        {
            var list = new DocumentElement(new DocumentCategory_ENUMERATED_LIST(), null);

            list.addComponent(component);
            return(list);
        }
Пример #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.
         */

        public DocumentElement createList(INLGElement component)
        {
            var list = new DocumentElement(new DocumentCategory_LIST(), null);

            list.addComponent(component);
            return(list);
        }
Пример #6
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 DocumentElement createList(List <INLGElement> textComponents)
        {
            var list = new DocumentElement(new DocumentCategory_LIST(), null);

            list.addComponents(textComponents);
            return(list);
        }
Пример #7
0
        /** 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 INLGElement promote(INLGElement element)
        {
            // check if promotion needed
            if (((IDocumentCategory)this.getCategory()).hasSubPart(element.getCategory()))
            {
                return(element);
            }
            // if element is not a DocumentElement, embed it in a sentence and recurse
            if (!(element is DocumentElement))
            {
                var sentence = new DocumentElement(new DocumentCategory_SENTENCE(), null);
                sentence.addElementToComponents(element);
                return(promote(sentence));
            }

            // if element is a Sentence, promote it to a paragraph
            if (!(element is IDocumentCategory))
            {
                if (element.getCategory().enumType == (int)DocumentCategoryEnum.SENTENCE)
                {
                    var paragraph = new DocumentElement(new DocumentCategory_PARAGRAPH(), null);
                    paragraph.addElementToComponents(element);
                    return(promote(paragraph));
                }
            }
            // otherwise can't do anything
            return(null);
        }
Пример #8
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 DocumentElement createDocument(string title, INLGElement component)
        {
            var element = new DocumentElement(new DocumentCategory_DOCUMENT(), title);

            if (component != null)
            {
                element.addComponent(component);
            }
            return(element);
        }
Пример #9
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 DocumentElement createDocument(string title, List <INLGElement> components)
        {
            var document = new DocumentElement(new DocumentCategory_DOCUMENT(), title);

            if (components != null)
            {
                document.addComponents(components);
            }
            return(document);
        }
Пример #10
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 DocumentElement createSentence(string cannedSentence)
        {
            var sentence = new DocumentElement(new DocumentCategory_SENTENCE(), null);

            if (cannedSentence != null)
            {
                sentence.addComponent(createStringElement(cannedSentence));
            }
            return(sentence);
        }
Пример #11
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 DocumentElement createSection(string title, INLGElement component)
        {
            var section = new DocumentElement(new DocumentCategory_SECTION(), title);

            if (component != null)
            {
                section.addComponent(component);
            }
            return(section);
        }
Пример #12
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 DocumentElement createParagraph(INLGElement component)
        {
            var paragraph = new DocumentElement(new DocumentCategory_PARAGRAPH(), null);

            if (component != null)
            {
                paragraph.addComponent(component);
            }
            return(paragraph);
        }
Пример #13
0
        /**
         * Convenience class to realise any NLGElement as a sentence
         *
         * @param element
         * @return string realisation of the NLGElement
         */

        public string realiseSentence(INLGElement element)
        {
            INLGElement realised = null;

            if (element is DocumentElement)
            {
                realised = realise(element);
            }
            else
            {
                var sentence = new DocumentElement(new DocumentCategory_SENTENCE(), null);
                sentence.addComponent(element);
                realised = realise(sentence);
            }

            if (realised == null)
            {
                return(null);
            }
            else
            {
                return(realised.getRealisation());
            }
        }
Пример #14
0
 public static string Realize(DocumentElement documentElement) => Realize(new RequestType
 {
     Document = documentElement
 });