Example #1
0
        private string IsPersonLine(string str)
        {
            switch (NumbersType)
            {
            case PersonNumbersType.pnDAboville:
                return(ImportUtils.IsPersonLine_DAboville(str));

            case PersonNumbersType.pnKonovalov:
                return(ImportUtils.IsPersonLine_Konovalov(str));

            default:
                return(null);
            }
        }
Example #2
0
        private bool AnalyseRaw()
        {
            if (SourceType == SourceType.stTable)
            {
                return(false);
            }

            try
            {
                IProgressController progress = AppHost.Progress;

                try
                {
                    int[] numberStats = new int[3];

                    int num = fRawContents.Count;
                    progress.ProgressInit(fLangMan.LS(ILS.LSID_Analysis), num);

                    for (int i = 0; i < num; i++)
                    {
                        string  txt     = fRawContents[i].Trim();
                        RawLine rawLine = (RawLine)fRawContents.GetObject(i);

                        if (!string.IsNullOrEmpty(txt))
                        {
                            if (IsGenerationLine(txt))
                            {
                                rawLine.Type = RawLineType.rltRomeGeneration;
                            }
                            else
                            {
                                PersonNumbersType numbType = PersonNumbersType.pnUndefined;

                                if (!string.IsNullOrEmpty(ImportUtils.IsPersonLine_DAboville(txt)))
                                {
                                    rawLine.Type = RawLineType.rltPerson;
                                    numbType     = PersonNumbersType.pnDAboville;
                                    numberStats[1]++;
                                }
                                else if (!string.IsNullOrEmpty(ImportUtils.IsPersonLine_Konovalov(txt)))
                                {
                                    rawLine.Type = RawLineType.rltPerson;
                                    numbType     = PersonNumbersType.pnKonovalov;
                                    numberStats[2]++;
                                }

                                rawLine.NumbersType = numbType;
                            }
                        }
                        else
                        {
                            rawLine.Type = RawLineType.rltEOF;
                        }

                        progress.ProgressStep(i + 1);
                    }

                    if (numberStats[1] > numberStats[2])
                    {
                        CanNumbersType = PersonNumbersType.pnDAboville;
                    }
                    else
                    {
                        CanNumbersType = PersonNumbersType.pnKonovalov;
                    }

                    return(true);
                }
                finally
                {
                    progress.ProgressDone();
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("Importer.AnalyseRaw(): " + ex.Message);
                return(false);
            }
        }
Example #3
0
        public void Test_ValidCases()
        {
            string pid;

            pid = ImportUtils.IsPersonLine_Konovalov("1. Ivan");
            Assert.AreEqual("1.", pid, "[v1]");

            pid = ImportUtils.IsPersonLine_Konovalov("2-1. Ivan");
            Assert.AreEqual("2-1.", pid);

            pid = ImportUtils.IsPersonLine_Konovalov("11-21. Ivan");
            Assert.AreEqual("11-21.", pid);

            pid = ImportUtils.IsPersonLine_Konovalov("11-21/1. Ivan");
            Assert.AreEqual("11-21/1.", pid);

            pid = ImportUtils.IsPersonLine_Konovalov("11-21/?. Ivan");
            Assert.AreEqual("11-21/?.", pid, "[v2]");

            pid = ImportUtils.IsPersonLine_Konovalov("11-21/1 (test+2, test). Ivan");
            Assert.AreEqual("11-21/1 (test+2, test).", pid);



            var plRet = ImportUtils.ParsePersonLine_Konovalov("11-21/1 (test+2, test). Ivan");

            Assert.AreEqual("11", plRet.PersId);
            Assert.AreEqual("21", plRet.ParentId);
            Assert.AreEqual("1", plRet.MarNum);
            Assert.AreEqual("(test+2, test)", plRet.ExtData);
            Assert.IsNotNull(plRet);

            plRet = ImportUtils.ParsePersonLine_Konovalov("11-21/?. Ivan");
            Assert.AreEqual("11", plRet.PersId);
            Assert.AreEqual("21", plRet.ParentId);
            Assert.AreEqual("?", plRet.MarNum);
            Assert.AreEqual("", plRet.ExtData);
            Assert.IsNotNull(plRet);



            pid = ImportUtils.IsPersonLine_DAboville("1. Ivan");
            Assert.AreEqual("1.", pid, "[v2-1]");

            pid = ImportUtils.IsPersonLine_DAboville("1.1. Ivan");
            Assert.AreEqual("1.1.", pid, "[v2-2]");

            pid = ImportUtils.IsPersonLine_DAboville("11.21.31.11. Ivan");
            Assert.AreEqual("11.21.31.11.", pid, "[v2-3]");



            plRet = ImportUtils.ParsePersonLine_DAboville("1. Ivan");
            Assert.AreEqual("1.", plRet.PersId);
            Assert.AreEqual("", plRet.ParentId);
            Assert.AreEqual("", plRet.MarNum);
            Assert.AreEqual("", plRet.ExtData);
            Assert.IsNotNull(plRet);

            plRet = ImportUtils.ParsePersonLine_DAboville("11.21.31.11. Ivan");
            Assert.AreEqual("11.21.31.11.", plRet.PersId);
            Assert.AreEqual("11.21.31.", plRet.ParentId);
            Assert.AreEqual("", plRet.MarNum);
            Assert.AreEqual("", plRet.ExtData);
            Assert.IsNotNull(plRet);



            var slRet = ImportUtils.ParseSpouseLine("Ж: Ivanova");

            Assert.AreEqual("Ж", slRet.Spouse, "[v3-1]");
            Assert.AreEqual(1, slRet.MarrNum, "[v3-1]");
            Assert.AreEqual("", slRet.ExtData);
            Assert.IsNotNull(slRet, "[v3-1]");

            slRet = ImportUtils.ParseSpouseLine("Ж2 (test): Ivanova");
            Assert.AreEqual("Ж", slRet.Spouse, "[v3-2]");
            Assert.AreEqual(2, slRet.MarrNum, "[v3-2]");
            Assert.AreEqual("(test)", slRet.ExtData, "[v3-2]");
            Assert.IsNotNull(slRet, "[v3-2]");

            slRet = ImportUtils.ParseSpouseLine("Ж - Ivanova");
            Assert.AreEqual("Ж", slRet.Spouse, "[v3-3]");
            Assert.AreEqual(1, slRet.MarrNum, "[v3-3]");
            Assert.AreEqual("", slRet.ExtData);
            Assert.IsNotNull(slRet, "[v3-3]");

            slRet = ImportUtils.ParseSpouseLine("Ж3 (test2) - Ivanova");
            Assert.AreEqual("Ж", slRet.Spouse, "[v3-4]");
            Assert.AreEqual(3, slRet.MarrNum, "[v3-4]");
            Assert.AreEqual("(test2)", slRet.ExtData, "[v3-4]");
            Assert.IsNotNull(slRet, "[v3-4]");
        }
Example #4
0
        public void Test_InvalidCases()
        {
            string pid;

            pid = ImportUtils.IsPersonLine_Konovalov("-1. Ivan");
            Assert.AreEqual(null, pid);

            pid = ImportUtils.IsPersonLine_Konovalov("1 Ivan");
            Assert.AreEqual(null, pid);

            pid = ImportUtils.IsPersonLine_Konovalov("1-. Ivan");
            Assert.AreEqual(null, pid);

            pid = ImportUtils.IsPersonLine_Konovalov("11-11 Ivan");
            Assert.AreEqual(null, pid);

            //res = ImpUtils.IsPersonLine_Konovalov("1.2. Ivan", out pid); // now false-positive
            //Assert.AreEqual(null, pid, "[i1]");

            //res = ImpUtils.IsPersonLine_Konovalov("1.1.1. Ivan", out pid); // now false-positive
            //Assert.AreEqual(null, pid, "[i2]");

            pid = ImportUtils.IsPersonLine_Konovalov("11-21/. Ivan");
            Assert.AreEqual(null, pid);

            pid = ImportUtils.IsPersonLine_Konovalov("11-21-31. Ivan");
            Assert.AreEqual(null, pid);

            pid = ImportUtils.IsPersonLine_Konovalov("11-21-31 (. Ivan");
            Assert.AreEqual(null, pid);

            pid = ImportUtils.IsPersonLine_Konovalov("11-21-31 (test) Ivan");
            Assert.AreEqual(null, pid);



            pid = ImportUtils.IsPersonLine_DAboville("-1. Ivan");
            Assert.AreEqual(null, pid, "[i2-1]");

            pid = ImportUtils.IsPersonLine_DAboville("1-1. Ivan");
            Assert.AreEqual(null, pid, "[i2-2]");

            pid = ImportUtils.IsPersonLine_DAboville(".1. Ivan");
            Assert.AreEqual(null, pid, "[i2-3]");

            pid = ImportUtils.IsPersonLine_DAboville("1710 (80), 1727 (80).");
            Assert.AreEqual(null, pid, "[i2-4]");



            var slRet = ImportUtils.ParseSpouseLine("Жена Ivanova");

            Assert.IsNull(slRet, "[i3-1]");

            slRet = ImportUtils.ParseSpouseLine("Ж2 Ivanova");
            Assert.IsNull(slRet, "[i3-2]");

            slRet = ImportUtils.ParseSpouseLine("Ж Ivanova");
            Assert.IsNull(slRet, "[i3-3]");

            slRet = ImportUtils.ParseSpouseLine("Ж3 (test2 - Ivanova");
            Assert.IsNull(slRet, "[i3-4]");
        }