示例#1
0
        static void Main(string[] args)
        {
            /// C:\Users\k1601808\Source\Repos\MariaShulgina19\DictClean\Data\
            string myfilepath  = @"C:\Users\k1601808\Source\Repos\MariaShulgina19\DictClean\Data\";
            string myfilename  = "parole_frek_Fi_1339787_to_normalize.csv";
            string myfullpath  = "";
            string myseparator = " ";

            IDictionary <int, string> myWordList = new Dictionary <int, string>();

            MyDictionary xm = new MyDictionary();

            //test advice
            myfullpath = myfilepath + myfilename;
            Console.WriteLine("Loading dictionaryfile: {0}", myfullpath);

            myWordList = xm.LoadDictionary(myfullpath, myseparator);

            // test load printing few lines

            for (int i = 1; i < 100; i++)
            {
                int jumper = 10000 * i;
                Console.Write("\n {0}) {1}{2}", myWordList.Keys.ElementAt(jumper), myWordList.Values.ElementAt(jumper), ";");
            }

            Console.WriteLine("");
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();
            // End loading test

            // Testing IDictionary sorting
            Console.WriteLine("Reodering the dictionary by value.");
            myWordList = xm.OrderDictionary(myWordList);
            Console.WriteLine("Press enter to continue.");
            Console.ReadLine();
            // End sorting test

            // testing file writing of the wordlist to csv file
            Console.WriteLine("Writing {0} words of dictionary to a csv file.", myWordList.Count);

            myseparator = ";";
            string mynewfilename = "dict_fi_ordered_asc_01.csv";

            myfullpath = myfilepath + mynewfilename;
            xm.SaveDictionary(myfullpath, myseparator, myWordList);

            Console.WriteLine("Saved {0} words in a csv file (separated by \"{1}\" at: {2}.", myWordList.Count, myseparator, myfullpath);

            Console.WriteLine("");
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();
            // End saving to csv file test
        }
示例#2
0
        static void Main(string[] args)
        {
            /* TESTER! set the current filepath of the test files under the "Data" directory
             * of  your fork. Rigth click on the file name (in the Solution explorer) and choose
             * properties (Alt+Enter) to find the filepath.
             *
             * example: string myfilepath = @"M:\MichelangeloMarchesi\_CodeDevelopment\source\repos\DictClean\Data\";
             */

            string myfilepath = @"C:\Users\Oma\source\repos\Markesi\DictClean\Data"; //just for testing

            /* this is the right way when the application is delivered as exe file
             * string myfilepath = Directory.GetCurrentDirectory() + @"\data\";
             * string myfilepath = @"\Data\";
             */

            string    myfilename = "parole_frek_Fi_1339787_to_normalize.csv";
            MycsvName fn         = new MycsvName();


            string myfullpath  = fn.GetcsvPath(myfilepath, myfilename);
            string myseparator = " ";



            IDictionary <int, string> myWordList = new Dictionary <int, string>();
            // reversed version of the dictionary
            IDictionary <string, int> myWordListsi = new Dictionary <string, int>();


            MyDictionary xm = new MyDictionary();

            //test advice

            Console.WriteLine("Loading dictionaryfile: {0}", myfullpath);

            myWordList = xm.LoadDictionary(myfullpath, myseparator);

            // test load printing few lines

            for (int i = 1; i < 100; i++)
            {
                int jumper = 10000 * i;
                Console.Write(" {0}) {1}{2}", myWordList.Keys.ElementAt(jumper), myWordList.Values.ElementAt(jumper), ";");
            }

            Console.WriteLine("");
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();
            // End loading test

            // Testing IDictionary sorting
            Console.WriteLine("Reodering the dictionary by value.");
            myWordList = xm.OrderDictionary(myWordList);
            Console.WriteLine("Press enter to continue.");
            Console.ReadLine();
            // End sorting test


            Console.WriteLine("\n Reversing and cleaning from duplicates");
            myWordListsi = xm.ReverseUniqueDict(myWordList);

            // testing file writing of the wordlist to csv file
            Console.WriteLine("Writing {0} words of dictionary to a csv file.", myWordListsi.Count);

            myseparator = ";";
            string mynewfilename = "dict_fi_ordered_asc_uniques_01.csv";

            myfullpath = myfilepath + "\\" + mynewfilename;
            xm.SaveDictionarysi(myfullpath, myseparator, myWordListsi);

            Console.WriteLine("Saved {0} words in a csv file (separated by \"{1}\" at: {2}.", myWordListsi.Count, myseparator, myfullpath);

            Console.WriteLine("");
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();
            // End saving to csv file test
        }