コード例 #1
0
        public void Shoud_not_detect_gender_if_auto_detection_is_not_set(string middleName)
        {
            var petrovich = new Petrovich { AutoDetectGender = false, MiddleName = middleName };
            petrovich.InflectMiddleNameTo(Case.Accusative);

            Assert.AreEqual(Gender.Androgynous, petrovich.Gender);
        }
コード例 #2
0
        public void Shoud_detect_gender_if_auto_detection_is_set(string middleName, Gender expected)
        {
            var petrovich = new Petrovich {AutoDetectGender = true, MiddleName = middleName};
            petrovich.InflectMiddleNameTo(Case.Accusative);

            Assert.AreEqual(expected, petrovich.Gender);
        }
コード例 #3
0
        public void Should_return_full_name_if_cast_to_string()
        {
            var petrovich = new Petrovich {
                FirstName = "Петр", LastName = "Петров", MiddleName = "Петрович"
            };

            Assert.AreEqual("Петров Петр Петрович", petrovich.ToString());
        }
コード例 #4
0
        public void Shoud_not_detect_gender_if_auto_detection_is_not_set(string middleName)
        {
            var petrovich = new Petrovich {
                AutoDetectGender = false, MiddleName = middleName
            };

            petrovich.InflectMiddleNameTo(Case.Accusative);

            Assert.AreEqual(Gender.Androgynous, petrovich.Gender);
        }
コード例 #5
0
        public void Shoud_detect_gender_if_auto_detection_is_set(string middleName, Gender expected)
        {
            var petrovich = new Petrovich {
                AutoDetectGender = true, MiddleName = middleName
            };

            petrovich.InflectMiddleNameTo(Case.Accusative);

            Assert.AreEqual(expected, petrovich.Gender);
        }
コード例 #6
0
ファイル: Evaluator.cs プロジェクト: petrovich/petrovich-net
 private static bool EvaluateCase(EvaluateParameters parameters, IEvalCase @case, out string inflectResult)
 {
     var petrovich = new Petrovich
     {
         Gender = @case.Gender
     };
     parameters.PetrovichAccessor(petrovich, @case.Lemma);
     inflectResult = parameters.PetrovichInflectAccessor(petrovich, @case.Case);
     var isActive = inflectResult.ToLower().Equals(@case.Word.ToLower());
     return isActive;
 }
コード例 #7
0
ファイル: Evaluator.cs プロジェクト: veydart/petrovich-net
        private static bool EvaluateCase(EvaluateParameters parameters, IEvalCase @case, out string inflectResult)
        {
            var petrovich = new Petrovich
            {
                Gender = @case.Gender
            };

            parameters.PetrovichAccessor(petrovich, @case.Lemma);
            inflectResult = parameters.PetrovichInflectAccessor(petrovich, @case.Case);
            var isActive = inflectResult.ToLower().Equals(@case.Word.ToLower());

            return(isActive);
        }
コード例 #8
0
        static void Main(string[] args)
        {
            //NPetrovichLite.Tests.TestDataFactory.ReadSurnamesData().OfType<object[]>().ToList();

            //Petrovich petrovich = new Petrovich(@"..\..\..\rules\rules.json", @"..\..\..\rules\gender.json");

            /*
             * Petrovich petrovich = new Petrovich();
             * Console.WriteLine(petrovich.Inflect("Маша", NamePart.FirstName, Case.Dative));
             * Console.WriteLine(petrovich.Inflect("Паша", NamePart.FirstName, Case.Dative));
             * Console.WriteLine(petrovich.Inflect("Саша", NamePart.FirstName, Case.Dative, Gender.Female));
             */

            /*
             * Petrovich petrovich = new Petrovich();
             * Petrovich.FIO a = petrovich.Inflect(new Petrovich.FIO() { lastName = "Пушкин", firstName = "Александр", midName = "Сергеевич" }, Case.Dative);
             * Console.WriteLine(a);
             * Petrovich.FIO b = petrovich.Inflect(new Petrovich.FIO() { lastName = "Воробей" }, Case.Dative, Gender.Female);
             * Console.WriteLine(b);
             * Petrovich.FIO c = petrovich.Inflect(new Petrovich.FIO() { lastName = "Воробей", firstName = "Александр" }, Case.Dative);
             * Console.WriteLine(c);
             */

            /*
             * Petrovich petrovich = new Petrovich();
             * Console.WriteLine(petrovich.GetGender("Пушкин", NamePart.LastName));
             * Console.WriteLine(petrovich.GetGender("Пушкин", null, "Сергеевич"));
             * Console.WriteLine(petrovich.GetGender(new Petrovich.FIO() { lastName = "Воробей", firstName = "Александр" }));
             */

            /*
             * InflectSinglePart testFixture = new InflectSinglePart();
             * testFixture.Init();
             * MethodInfo mi = testFixture.GetType().GetMethod(nameof(InflectSinglePart.TestSinglePartInflection));
             * foreach (object[] par in TestDataFactory.ReadSurnamesData())
             * {
             *  mi.Invoke(testFixture, par);
             * }
             */

            Petrovich petrovich = new Petrovich();

            Console.WriteLine(petrovich.Inflect("Aгриппа", NamePart.LastName, Case.Genitive));
            Console.WriteLine(petrovich.Inflect("Кваша", NamePart.LastName, Case.Genitive));
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: Ceridan/petrovich-net-lite
        static void Main(string[] args)
        {
            //NPetrovichLite.Tests.TestDataFactory.ReadSurnamesData().OfType<object[]>().ToList();

            //Petrovich petrovich = new Petrovich(@"c:\Dev\_Projects\petrovich-net\src\rules\rules.json");
            /*
            Petrovich petrovich = new Petrovich();
            Console.WriteLine(petrovich.Inflect("Маша", NamePart.FirstName, Case.Dative));
            Console.WriteLine(petrovich.Inflect("Паша", NamePart.FirstName, Case.Dative));
            Console.WriteLine(petrovich.Inflect("Саша", NamePart.FirstName, Case.Dative, Gender.Female));
            */

            /*
            Petrovich petrovich = new Petrovich();
            Petrovich.FIO a = petrovich.Inflect(new Petrovich.FIO() { lastName = "Пушкин", firstName = "Александр", midName = "Сергеевич" }, Case.Dative);
            Console.WriteLine(a);
            Petrovich.FIO b = petrovich.Inflect(new Petrovich.FIO() { lastName = "Воробей" }, Case.Dative, Gender.Female);
            Console.WriteLine(b);
            Petrovich.FIO c = petrovich.Inflect(new Petrovich.FIO() { lastName = "Воробей", firstName = "Александр" }, Case.Dative);
            Console.WriteLine(c);
            */

            /*
            Petrovich petrovich = new Petrovich();
            Console.WriteLine(petrovich.GetGender("Пушкин", NamePart.LastName));
            Console.WriteLine(petrovich.GetGender("Пушкин", null, "Сергеевич"));
            Console.WriteLine(petrovich.GetGender(new Petrovich.FIO() { lastName = "Воробей", firstName = "Александр" }));
            */

            /*
            InflectSinglePart testFixture = new InflectSinglePart();
            testFixture.Init();
            MethodInfo mi = testFixture.GetType().GetMethod(nameof(InflectSinglePart.TestSinglePartInflection));
            foreach (object[] par in TestDataFactory.ReadSurnamesData())
            {
                mi.Invoke(testFixture, par);
            }
            */

            Petrovich petrovich = new Petrovich();
            //Console.WriteLine(petrovich.Inflect("Aгриппа", NamePart.LastName, Case.Genitive));
            Console.WriteLine(petrovich.Inflect("Кваша", NamePart.LastName, Case.Genitive));
        }
コード例 #10
0
 public void Init()
 {
     petrovich = new Petrovich();
 }
コード例 #11
0
 public void Init()
 {
     petrovich = new Petrovich();
 }
コード例 #12
0
        public void Should_throw_ArgumentNullException_if_any_name_is_not_provided(string firstName, string lastName, string middleName)
        {
            var petrovich = new Petrovich();

            Assert.Throws <ArgumentNullException>(() => petrovich.InflectTo(Case.Accusative));
        }
コード例 #13
0
        public void Should_throw_ArgumentNullException_if_middle_name_is_not_provided()
        {
            var petrovich = new Petrovich();

            Assert.Throws <ArgumentNullException>(() => petrovich.InflectMiddleNameTo(Case.Accusative));
        }
コード例 #14
0
        public void Should_return_full_name_if_cast_to_string()
        {
            var petrovich = new Petrovich {FirstName = "Петр", LastName = "Петров", MiddleName = "Петрович"};

            Assert.AreEqual("Петров Петр Петрович", petrovich.ToString());
        }
コード例 #15
0
        public void Should_throw_ArgumentNullException_if_any_name_is_not_provided(string firstName, string lastName, string middleName)
        {
            var petrovich = new Petrovich();

            Assert.Throws<ArgumentNullException>(() => petrovich.InflectTo(Case.Accusative));
        }
コード例 #16
0
        public void Should_throw_ArgumentNullException_if_middle_name_is_not_provided()
        {
            var petrovich = new Petrovich();

            Assert.Throws<ArgumentNullException>(() => petrovich.InflectMiddleNameTo(Case.Accusative));
        }