public void AddAlias(AliasType a, string city, string street, string pna)
        {
            if (!Aliasses.Contains(a))
            {
                this.Aliasses.Add(a);
            }



            List <string> nl = new List <string>();

            nl.Add(a.Alias + ";" + city + ";" + street + ";" + pna);

            File.AppendAllLines("wrdaliases.csv", nl.ToArray());
        }
        /// <summary>
        /// plik csv o kolumnach : Miejscowosc,Ulica,PNA, -rozdzielany ;
        /// </summary>
        /// <param name="dictPath"></param>
        public void Load(string dictPath, string AliastPath)
        {
            List <string> dictLines = File.ReadAllLines(dictPath).ToList();

            Dict = new List <DictType>();
            foreach (var line in dictLines)
            {
                NeedDecision = new List <RecognitionResulType.ResulDecisionType>();
                NoMatched    = new List <string>();

                List <string> Words = line.Split(';').ToList();

                DictType o = new DictType();
                o.City   = Words[0];
                o.Street = Words[1];
                o.PNA    = RemoveAllSpecialCharacters(Words[2], true, true, true, true);


                Dict.Add(o);
            }

            List <string> aliasLineas = File.ReadAllLines(AliastPath).ToList();

            Aliasses = new List <AliasType>();
            foreach (var line in aliasLineas)
            {
                List <string> Words = line.Split(';').ToList();

                AliasType o = new AliasType();
                o.Alias  = Words[0];
                o.City   = Words[1];
                o.Street = Words[2];
                o.PNA    = RemoveAllSpecialCharacters(Words[3], true, true, true, true);


                Aliasses.Add(o);
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            WordRecognizerType Recognizer = new WordRecognizerType();

            Recognizer.Load("wrdDict.csv", "wrdaliases.csv");


            //Recognizer.UseMatchFrasesPNA = false;
            //Recognizer.UseMatchFrases = false;
            //Recognizer.UseContainsFrases = false;

            Console.Clear();
            Recognizer.NoMatched.Clear();
            Recognizer.NeedDecision.Clear();
            int Nomatch = 0;

            List <string> Examples = File.ReadAllLines("example.txt").ToList();

            foreach (var frase in Examples)
            {
                string city   = WordRecognizerType.RemoveAllSpecialCharacters(frase.Split(';')[0], true, true, true, false);
                string street = WordRecognizerType.RemoveAllSpecialCharacters(frase.Split(';')[1], true, true, true, false);
                string pna    = frase.Split(';')[2];



                bool ok = false;
                foreach (var r in Recognizer.Match(city, street, pna))
                {
                    Console.WriteLine(r.Input + "^" + r.Method + "^" + r.ResultDict.City + "^" + r.ResultDict.Street + "^" + r.ResultDict.PNA + "^" + r.MatchPercentage + "%");
                    ok = true;
                }

                if (ok == false)
                {
                    Console.WriteLine(frase);
                    Nomatch += 1;
                }
            }
            double nom = Nomatch;
            double all = Examples.Count;

            double per = double.Parse("100") - ((nom / all) * 100);

            Console.WriteLine("All:" + Examples.Count + " NoMatch:" + Nomatch + " Percentage:" + per + "%");


            //aliasy
            foreach (var n in Recognizer.NoMatched.Distinct())
            {
                string nn = n.Replace("_", " ");
                string acity;
                string astreet;
                string apna;
                Console.WriteLine("Miejscowosc dla:" + nn);
                acity = Console.ReadLine();
                Console.WriteLine("Ulica dla:" + nn);
                astreet = Console.ReadLine();
                Console.WriteLine("PNA dla:" + nn);
                apna = Console.ReadLine();

                AliasType o = new AliasType();
                o.Alias  = nn;
                o.City   = acity;
                o.Street = astreet;
                o.PNA    = apna;
                Recognizer.Aliasses.Add(o);

                List <string> nl = new List <string>();
                nl.Add(o.Alias + ";" + o.City + ";" + o.Street + ";" + o.PNA);

                File.AppendAllLines("wrdaliases.csv", nl.ToArray());
            }
        }