Esempio n. 1
0
	    /**
	     * Realise.
	     * 
	     * @param wt
	     *            the wt
	     * @return the string
	     * @throws XMLRealiserException
	     *             the xML realiser exception
	     */
		public static string realise(wrapper.XmlDocumentElement wt)
		{
			string output = "";
			if (wt != null)
			{
				try
				{
					if (lexicon == null)
					{
						lexicon = Lexicon.DefaultLexicon;
					}
					UnWrapper w = new UnWrapper(lexicon);
					DocumentElement t = w.UnwrapDocumentElement(wt);
					if (t != null)
					{
						Realiser r = new Realiser(lexicon);
						r.initialise();

						NLGElement tr = r.realise(t);

						output = tr.Realisation;
					}

				}
				catch (Exception e)
				{
					throw new XMLRealiserException("NLG XMLRealiser Error", e);
				}
			}

			return output;
		}
Esempio n. 2
0
        /**
         * Adds a record to this recording.
         *
         * @param input
         *            the DocumentElement in this record
         * @param output
         *            the realisation
         */
        public virtual void addRecord(wrapper.XmlDocumentElement input, string output)
        {
            if (!recordingOn)
            {
                return;
            }
            DocumentRealisation t = new DocumentRealisation();
            int?   testNumber     = record.Record.Count + 1;
            string testName       = "TEST_" + testNumber.ToString();

            t.Name        = testName;
            t.Document    = input;
            t.Realisation = output;
            record.Record.Add(t);
        }
Esempio n. 3
0
        /**
         * Create simplenlg objects from wrapper objects.
         *
         * @param wt
         *            the wrapper DocumentElement object
         * @return the document element
         */
        public virtual DocumentElement UnwrapDocumentElement(wrapper.XmlDocumentElement wt)
        {
            DocumentElement t = factory.createDocument();

            if (wt.Cat != null)
            {
                Enum.TryParse(wt.Cat.ToString(), out DocumentCategory.DocumentCategoryEnum cat);
                t.Category = new DocumentCategory(cat);
            }
            if (wt.Title != null)
            {
                t.Title = wt.Title;
            }

            foreach (wrapper.XmlNLGElement wp in wt.Child)
            {
                NLGElement p = UnwrapNLGElement(wp);
                t.addComponent(p);
            }

            return(t);
        }