예제 #1
0
        public static void GenerateDataSet(int level)
        {
            ArrayList all = new ArrayList();

            DictionaryService dictionaryService = new DictionaryService();

            for (int i = 1; i <= level; i++)
            {
                ArrayList words = dictionaryService.GetAllWords(i);
                all.AddRange(words);
            }

            ArrayList chars = new ArrayList();

            foreach (Word w in all)
            {
                foreach (Char c in w.Character)
                {
                    if (!chars.Contains(c))
                    {
                        chars.Add(c);

                        var Projection = ProjectionService.GenerateProjectionfromFontChar(c, new Size(32, 32), 28, "DengXian", FontStyle.Regular);
                        var sequence   = ToZerosOnesSequence(c, Projection.Bitmap);
                        FileWriter.AddLine(sequence, datasetPath);
                    }
                }
            }

            foreach (Word w in all)
            {
                foreach (Char c in w.Character)
                {
                    if (!chars.Contains(c))
                    {
                        chars.Add(c);

                        var    Projection = ProjectionService.GenerateProjectionfromFontChar(c, new Size(32, 32), 28, "DengXian Light", FontStyle.Regular);
                        var    sequence   = ToZerosOnesSequence(c, Projection.Bitmap);
                        string path       = @"C:\Users\dlorente\Desktop\RecogZi\dataset.csv";
                        FileWriter.AddLine(sequence, path);
                    }
                }
            }

            foreach (Word w in all)
            {
                foreach (Char c in w.Character)
                {
                    if (!chars.Contains(c))
                    {
                        chars.Add(c);

                        var Projection = ProjectionService.GenerateProjectionfromFontChar(c, new Size(32, 32), 28, "DengXian", FontStyle.Italic);
                        var sequence   = ToZerosOnesSequence(c, Projection.Bitmap);
                        FileWriter.AddLine(sequence, datasetPath);
                    }
                }
            }

            foreach (Word w in all)
            {
                foreach (Char c in w.Character)
                {
                    if (!chars.Contains(c))
                    {
                        chars.Add(c);

                        var Projection = ProjectionService.GenerateProjectionfromFontChar(c, new Size(32, 32), 28, "DengXian Light", FontStyle.Italic);
                        var sequence   = ToZerosOnesSequence(c, Projection.Bitmap);

                        FileWriter.AddLine(sequence, datasetPath);
                    }
                }
            }
        }