Ejemplo n.º 1
0
        public void FindTheDos()
        {
            DirectObjectProcessor sp = new DirectObjectProcessor();
            string test =
                @"mi mute li lukin e soweli e kala e jan suli.";

            Collection <DirectObject> subjects = sp.SplitIntoDirectObjects(test);

            Assert.AreEqual(3, subjects.Count);
        }
Ejemplo n.º 2
0
        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());
        }