コード例 #1
0
ファイル: Predicate.cs プロジェクト: Laesod/tokipona.parser
        /// <summary>
        /// Verbal Predicate
        /// </summary>
        public TpPredicate(Particle particle, VerbPhrase verbPhrase, ComplexChain directs = null, PrepositionalPhrase[] prepositionals = null)
        {
            if (particle.Text != Particles.o.Text && particle.Text != Particles.li.Text)
            {
                throw new TpSyntaxException("Tp Predicate can only have a Predicate headed by li or o-- got " + particle.Text);
            }
            if (verbPhrase == null && prepositionals == null)
            {
                throw new TpSyntaxException("A verb phrase or prepositional phrase required. (Directs are optional)");
            }
            if (verbPhrase == null && directs == null && prepositionals == null)
            {
                throw new TpSyntaxException("Verb, directs and prepositional phrases all null, not good");
            }

            //TODO: Validate.
            this.particle   = particle;   //li or o
            this.verbPhrase = verbPhrase; //only pi, en
            if (directs != null && directs.Particle.Text != Particles.e.Text)
            {
                throw new TpSyntaxException("Directs must have e as the particle.");
            }

            this.directs = directs;               //only e, pi, en

            this.prepositionals = prepositionals; //only ~prop, pi, en
        }
コード例 #2
0
        public void CanSerialize()
        {
            VerbPhrase hp = new VerbPhrase(Words.jan, new WordSet()
            {
                Words.seme
            });
            TpPredicate p = new TpPredicate(Particles.li, hp, SampleDirectsChain(), ChainTests.SamplePrepsChain());

            Assert.NotNull(p.ToJsonDcJs());
        }
コード例 #3
0
        public void Construction()
        {
            VerbPhrase vp = new VerbPhrase(
                Words.moku,
                new WordSet()
            {
                Words.ken
            },
                new WordSet()
            {
                Words.wawa
            });

            Console.WriteLine(vp.ToString());
            Console.WriteLine(vp.ToString("b"));
        }