private string ProcessStructureRow(Sentence sentence)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<tr>");
            SubjectProcessor sp = new SubjectProcessor();

            foreach (Subject subject in sp.SplitIntoSubjects(sentence.Text))
            {
                sb.Append("<td colspan='");
                sb.Append(subject.Words.Length);
                sb.Append("'>");
                sb.Append("Subject<br/>(");
                sb.Append(subject.Text);
                sb.Append(")");
                sb.Append("</td>");
            }
            VerbPhraseProcessor vpp = new VerbPhraseProcessor();

            foreach (VerbPhrase verbPhrase in vpp.SplitIntoVerbPhrases(sentence.Text))
            {
                sb.Append("<td colspan='");
                sb.Append(verbPhrase.Words.Length);
                sb.Append("'>");
                sb.Append("VP<br/>(");
                sb.Append(verbPhrase.Text);
                sb.Append(")");
                sb.Append("</td>");
            }
            sb.Append("</tr>");
            return(sb.ToString());
        }
        public void SplitSubjectsWithAnu()
        {
            SubjectProcessor sp   = new SubjectProcessor();
            string           test =
                @"soweli anu waso li pilin pona.";

            Collection <Subject> subjects = sp.SplitIntoSubjects(test);

            Assert.AreEqual(2, subjects.Count);
        }
        public void SplitSubjectsInBigSentence()
        {
            SubjectProcessor sp   = new SubjectProcessor();
            string           text =
                @"mije pi lawa sewi suli li kama anpa e mije ante li kama unpa e meli mute li kama pana e soweli lili mute";
            Collection <Subject> subjects = sp.SplitIntoSubjects(text);

            Assert.AreEqual(1, subjects.Count);
            Assert.AreEqual("mije pi lawa sewi suli", subjects[0].Text);
        }
        public void SplitSubjectsWithAndCheckText()
        {
            SubjectProcessor sp   = new SubjectProcessor();
            string           test =
                @"soweli en waso li pilin pona.";

            Collection <Subject> subjects = sp.SplitIntoSubjects(test);

            Assert.AreEqual("soweli", subjects[0].Text);
            Assert.AreEqual("waso", subjects[1].Text);
        }
        private string GlossASentence(Sentence sentence)
        {
            StringBuilder sb = new StringBuilder(sentence.Text.Length);

            sb.Append("<table border='1'><tr>");
            sb.Append("<td colspan='");
            sb.Append(sentence.Words.Length);
            sb.Append("'>");
            sb.Append(sentence.Type.ToString());
            sb.Append("</td>");

            //Splits into SP/SP/SP/VP/VP/VP (large VP's with e's and PP's)
            sb.Append(ProcessStructureRow(sentence));

            sb.Append("<tr>");

            VerbPhraseProcessor vpp = new VerbPhraseProcessor();
            SubjectProcessor    sp  = new SubjectProcessor();
            NounPhraseProcessor npp = new NounPhraseProcessor();
            Lexicon             tp  = new Lexicon();

            int wordsGlossed = 0;

            foreach (Subject subject in sp.SplitIntoSubjects(sentence.Text))
            {
                foreach (NounPhrase np in npp.SplitIntoNounPhrases(subject.Text))
                {
                    sb.Append("<td>");
                    Noun n = new Noun(tp, np.HeadNoun());
                    sb.Append(n.Translate());
                    sb.Append("</td>");

                    foreach (string modifier in np.Modifiers())
                    {
                        sb.Append("<td>");
                        Modifier m = new Modifier(tp, modifier);
                        sb.Append(m.Translate());
                        sb.Append("</td>");
                    }

                    if (np.Type == NpType.Pi)
                    {
                        sb.Append("<td>PI</td>");
                    }

                    wordsGlossed += np.Words.Length;
                }
                if (subject.Type != SubjectType.None)
                {
                    sb.Append("<td>");
                    sb.Append(subject.Type);
                    sb.Append("</td>");
                    wordsGlossed += 1;
                }
            }
            ModalProcessor mp = new ModalProcessor(tp);
            PrepositionalPhraseProcessor ppp = new PrepositionalPhraseProcessor();
            DirectObjectProcessor        dop = new DirectObjectProcessor();

            foreach (VerbPhrase verbPhrase in vpp.SplitIntoVerbPhrases(sentence.Text))
            {
                foreach (Modal modal in mp.SplitIntoModals(verbPhrase.Text))
                {
                    sb.Append("<td>");
                    sb.Append(modal.Translate());
                    sb.Append("</td>");
                    wordsGlossed += 1;
                }

                //The core verb
                //The verbal compounds or adverbs.
                sb.Append("<td>");
                sb.Append("V/Adv");//place holder
                sb.Append("</td>");
                wordsGlossed += 1;

                foreach (DirectObject directObject in dop.SplitIntoDirectObjects(verbPhrase.Text))
                {
                    sb.Append("<td colspan='");
                    sb.Append(directObject.Words.Length);
                    sb.Append("'>");
                    sb.Append(directObject.Text + " DO");//place holder
                    sb.Append("</td>");
                    wordsGlossed += directObject.Words.Length + 1;
                }

                foreach (PrepositionalPhrase prep in ppp.SplitIntoPrepPhrases(verbPhrase.Text))
                {
                    sb.Append("<td colspan='");
                    sb.Append(prep.Words.Length);
                    sb.Append("'>");
                    sb.Append(prep.Text + " PP");//place holder
                    sb.Append("</td>");
                    wordsGlossed += prep.Words.Length;
                }
            }

            //Gap
            if (sentence.Words.Length - wordsGlossed > 0)
            {
                sb.Append("<td colspan='");
                sb.Append(sentence.Words.Length - wordsGlossed);
                sb.Append("'>");
                sb.Append(sentence.Words.Length - wordsGlossed);
                sb.Append("</td>");
            }

            sb.Append("</tr>");

            sb.Append("</table>");
            return(sb.ToString());
        }