Пример #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 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);
        }
Пример #7
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);
        }
Пример #8
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);
        }
Пример #9
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);
        }
Пример #10
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());
            }
        }