Esempio n. 1
0
        private string SP(PhonWord pw, int pos)
        // Second Part
        {
            string secondPart;
            string w = pw.GetWord();

            if (pos == w.Length - 1)
            {
                secondPart = "";
            }
            else
            {
                secondPart = w.Substring(pos + 1, w.Length - (pos + 1));
            }
            return(secondPart);
        }
Esempio n. 2
0
        } // TestAutomRule

        private string FP(PhonWord pw, int pos)
        // First Part
        {
            return(pw.GetWord().Substring(0, pos));
        }
Esempio n. 3
0
        public void TestCheck2()
        // les Regles. Vérifions qu'elles fonctionnent.
        // Chaque règle est testée en détail ailleurs.
        {
            AutomRuleFilter arf;
            int             pos;
            string          tstRFS;
            string          rTxt;
            bool            cRes;
            TheText         tt;
            PhonWord        pw;

            TheText.Init();
            Config conf = new Config();

            tstRFS = @"this.Regle_ient,";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("glorifient quotient rififi mortifient qui i");
            pw     = new PhonWord(tt, 0, 9, conf); // "glorifient'"
            Assert.AreEqual("glorifient", pw.GetWord());
            Assert.IsTrue(arf.Check(pw, 6, "glorif", "ent"));
            Assert.IsTrue(arf.Check(pw, 8, "glorifie", "t"));
            pw = new PhonWord(tt, 11, 18, conf); // "quotient'"
            Assert.AreEqual("quotient", pw.GetWord());
            Assert.IsFalse(arf.Check(pw, 4, "quot", "ent"));
            pw = new PhonWord(tt, 20, 25, conf); // "rififi'"
            Assert.AreEqual("rififi", pw.GetWord());
            Assert.IsFalse(arf.Check(pw, 3, "rif", "fi"));
            pw = new PhonWord(tt, 27, 36, conf); // "mortifient'"
            Assert.AreEqual("mortifient", pw.GetWord());
            Assert.IsTrue(arf.Check(pw, 6, "mortif", "ent"));
            Assert.IsFalse(arf.Check(pw, 4, "mort", "fient"));
            pw = new PhonWord(tt, 38, 40, conf); // "qui'"
            Assert.AreEqual("qui", pw.GetWord());
            Assert.IsFalse(arf.Check(pw, 2, "qu", ""));
            pw = new PhonWord(tt, 42, 42, conf); // "i'"
            Assert.AreEqual("i", pw.GetWord());
            Assert.IsFalse(arf.Check(pw, 0, "", ""));


            tstRFS = @"this.Regle_mots_ent,";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("interférent");
            pw     = new PhonWord(tt, 0, tt.ToString().Length - 1, conf);
            Assert.IsTrue(arf.Check(pw, 8, "interfér", "nt"));

            tstRFS = @"this.Regle_ment,";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("assurément");
            pw     = new PhonWord(tt, 0, tt.ToString().Length - 1, conf);
            Assert.IsTrue(arf.Check(pw, 7, "assurém", "nt"));
            tt = new TheText("amplement");
            pw = new PhonWord(tt, 0, tt.ToString().Length - 1, conf);
            Assert.IsTrue(arf.Check(pw, 6, "amplem", "nt"));


            tstRFS = @"this.Regle_verbe_mer,";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("clament");
            pw     = new PhonWord(tt, 0, tt.ToString().Length - 1, conf);
            Assert.IsTrue(arf.Check(pw, 4, "clam", "nt"));

            tstRFS = @"this.Regle_er,";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("amer");
            pw     = new PhonWord(tt, 0, tt.ToString().Length - 1, conf);
            Assert.IsTrue(arf.Check(pw, 2, "am", "r"));

            tstRFS = @"this.Regle_avoir,";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("eûmes");
            pw     = new PhonWord(tt, 0, tt.ToString().Length - 1, conf);
            Assert.IsTrue(arf.Check(pw, 0, "", "ûmes"));

            tstRFS = @"this.Regle_s_final,";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("versus");
            pw     = new PhonWord(tt, 0, tt.ToString().Length - 1, conf);
            Assert.IsTrue(arf.Check(pw, 5, "versu", ""));

            tstRFS = @"this.Regle_t_final,";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("comput");
            pw     = new PhonWord(tt, 0, tt.ToString().Length - 1, conf);
            Assert.IsTrue(arf.Check(pw, 5, "compu", ""));

            tstRFS = @"this.Regle_tien,";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("tienne");
            pw     = new PhonWord(tt, 0, tt.ToString().Length - 1, conf);
            Assert.IsTrue(arf.Check(pw, 0, "", "ienne"));
        }
Esempio n. 4
0
        public void TestCheck1()
        {
            // Let's reuse the rulefilters of the Test_AutomRuleFilter method
            AutomRuleFilter arf;
            int             pos;
            string          tstRFS;
            string          rTxt;
            bool            cRes;
            TheText         tt;
            PhonWord        pw;
            List <PhonWord> pws;
            int             wordI;

            TheText.Init();
            Config conf = new Config();

            // ****************************** TEST 1 **************************************
            tstRFS = @"{ '+':/$/ i, '-':/ ^/ i }";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("l'automne et les Violons");
            pw     = new PhonWord(tt, 0, 0, conf); // "l"
            Assert.IsTrue(arf.Check(pw, 0, "", ""));
            pw = new PhonWord(tt, 17, 23, conf);   // Violons
            Assert.AreEqual("violons", pw.GetWord());
            Assert.IsFalse(arf.Check(pw, 1, "v", "olons"));

            // ****************************** TEST 2 **************************************
            tstRFS = @"{ '-':/ ^/ i, '+':/st$/ i }";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("le chst est bleu");
            pw     = new PhonWord(tt, 8, 10, conf); // "est"
            Assert.AreEqual("est", pw.GetWord());
            Assert.IsTrue(arf.Check(pw, 0, "", "st"));
            Assert.IsFalse(arf.Check(pw, 1, "e", "t"));
            pw = new PhonWord(tt, 3, 6, conf); // "chst"
            Assert.AreEqual("chst", pw.GetWord());
            Assert.IsFalse(arf.Check(pw, 1, "c", "st"));
            Assert.IsFalse(arf.Check(pw, 0, "", "ast"));
            pw = new PhonWord(tt, 12, 15, conf); // "bleu"
            Assert.AreEqual("bleu", pw.GetWord());
            Assert.IsFalse(arf.Check(pw, 2, "bl", "u"));
            Assert.IsFalse(arf.Check(pw, 3, "ble", ""));

            // ****************************** TEST 3 **************************************
            tstRFS = @"this.Regle_nc_ai_final,";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("Je mangeai chantais plaisir balai essai");
            pw     = new PhonWord(tt, 0, 1, conf); // "je"
            Assert.AreEqual("je", pw.GetWord());
            Assert.IsFalse(arf.Check(pw, 1, "j", ""));
            pw = new PhonWord(tt, 3, 9, conf); // "mangeai"
            Assert.AreEqual("mangeai", pw.GetWord());
            Assert.IsFalse(arf.Check(pw, 0, "", "angeai"));
            Assert.IsFalse(arf.Check(pw, 1, "m", "ngeai"));
            Assert.IsFalse(arf.Check(pw, 2, "ma", "geai"));
            Assert.IsFalse(arf.Check(pw, 3, "man", "eai"));
            Assert.IsFalse(arf.Check(pw, 4, "mang", "ai"));
            Assert.IsFalse(arf.Check(pw, 5, "mange", "i"));
            Assert.IsFalse(arf.Check(pw, 6, "mangea", ""));
            pw = new PhonWord(tt, 11, 18, conf); // "chantais"
            Assert.AreEqual("chantais", pw.GetWord());
            Assert.IsFalse(arf.Check(pw, 5, "chant", "is"));
            pw = new PhonWord(tt, 20, 26, conf); // "plaisir"
            Assert.AreEqual("plaisir", pw.GetWord());
            Assert.IsFalse(arf.Check(pw, 2, "pl", "isir"));
            pw = new PhonWord(tt, 28, 32, conf); // "balai"
            Assert.AreEqual("balai", pw.GetWord());
            Assert.IsTrue(arf.Check(pw, 3, "bal", "i"));
            Assert.IsFalse(arf.Check(pw, 1, "b", "lai"));
            pw = new PhonWord(tt, 34, 38, conf); // "essai"
            Assert.AreEqual("essai", pw.GetWord());
            Assert.IsTrue(arf.Check(pw, 3, "ess", "i"));
            Assert.IsFalse(arf.Check(pw, 1, "e", "sai"));
            Assert.IsFalse(arf.Check(pw, 4, "essa", ""));

            // ****************************** TEST 4 **************************************
            tstRFS = @"{'+':/('|’)/i}";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("j'aimé l'arbre d'abord t'es c'est");
            pw     = new PhonWord(tt, 0, 1, conf); // "j'"
            Assert.AreEqual("j\'", pw.GetWord());
            Assert.IsTrue(arf.Check(pw, 0, "", "\'"));
            Assert.IsFalse(arf.Check(pw, 1, "j", ""));
            pw = new PhonWord(tt, 7, 8, conf); // "l'"
            Assert.AreEqual("l\'", pw.GetWord());
            Assert.IsTrue(arf.Check(pw, 0, "", "\'"));
            Assert.IsFalse(arf.Check(pw, 1, "l", ""));
            pw = new PhonWord(tt, 15, 16, conf); // "d'"
            Assert.AreEqual("d\'", pw.GetWord());
            Assert.IsTrue(arf.Check(pw, 0, "", "\'"));
            Assert.IsFalse(arf.Check(pw, 1, "d", ""));
            pw = new PhonWord(tt, 23, 24, conf); // "t'"
            Assert.AreEqual("t\'", pw.GetWord());
            Assert.IsTrue(arf.Check(pw, 0, "", "\'"));
            Assert.IsFalse(arf.Check(pw, 1, "t", ""));
            pw = new PhonWord(tt, 28, 29, conf); // "c'"
            Assert.AreEqual("c\'", pw.GetWord());
            Assert.IsTrue(arf.Check(pw, 0, "", "\'"));
            Assert.IsFalse(arf.Check(pw, 1, "c", ""));
            pw = new PhonWord(tt, 2, 5, conf); // "aimé"
            Assert.AreEqual("aimé", pw.GetWord());
            Assert.IsFalse(arf.Check(pw, 1, "a", "mé"));
            Assert.IsFalse(arf.Check(pw, 2, "aim", ""));

            // ****************************** TEST 6 **************************************
            tstRFS = @"{'+':/ll/i,'-':/[bcçdfghjklmnpqrstvwxz](u?)/i}";
            pos    = 0;
            arf    = new AutomRuleFilter(tstRFS, ref pos);
            tt     = new TheText("briefing, berlingot, bille, imbécile, limbe, afin, paille, triage, guilleret");
            pws    = tt.GetPhonWordList(conf);

            // briefing
            wordI = 0;
            pos   = 5;
            Assert.IsFalse(arf.Check(pws[wordI], pos, FP(pws[wordI], pos), SP(pws[wordI], pos)));

            // berlingot
            wordI = 1;
            pos   = 4;
            Assert.IsFalse(arf.Check(pws[wordI], pos, FP(pws[wordI], pos), SP(pws[wordI], pos)));

            // bille
            wordI = 2;
            pos   = 1;
            Assert.IsTrue(arf.Check(pws[wordI], pos, FP(pws[wordI], pos), SP(pws[wordI], pos)));

            // imbécile
            wordI = 3;
            pos   = 5;
            Assert.IsFalse(arf.Check(pws[wordI], pos, FP(pws[wordI], pos), SP(pws[wordI], pos)));

            // limbe
            wordI = 4;
            pos   = 1;
            Assert.IsFalse(arf.Check(pws[wordI], pos, FP(pws[wordI], pos), SP(pws[wordI], pos)));

            // afin
            wordI = 5;
            pos   = 2;
            Assert.IsFalse(arf.Check(pws[wordI], pos, FP(pws[wordI], pos), SP(pws[wordI], pos)));

            // paille
            wordI = 6;
            pos   = 2;
            Assert.IsFalse(arf.Check(pws[wordI], pos, FP(pws[wordI], pos), SP(pws[wordI], pos)));

            // triage
            wordI = 7;
            pos   = 2;
            Assert.IsFalse(arf.Check(pws[wordI], pos, FP(pws[wordI], pos), SP(pws[wordI], pos)));

            // guilleret
            wordI = 8;
            pos   = 2;
            Assert.IsTrue(arf.Check(pws[wordI], pos, FP(pws[wordI], pos), SP(pws[wordI], pos)));
        }