Пример #1
0
        static void Main()
        {
            KSvc.Service serv = new KSvc.Service();

            //don't show metadata
            serv.ShowMetaData = false;

            //starting service
            PointLoadObserver plso   = new PointLoadObserver();
            ThreadStart       tStart = delegate { serv.Run(plso); };
            Thread            t      = new Thread(tStart);

            t.Start();

            //starting mirror GUI
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //get characters
            List <Character> characterdatabase =
                UPXReader.ParseUPXFile(
                    File.Open("C:\\Diplom\\kanjiteacher\\data\\exampleFormat.upx", FileMode.Open));


            //initialise viewing area
            MirrorArea ma = new MirrorArea(plso);

            //go through all the strokes in the database
            //fill viewing area
            foreach (Character c in characterdatabase)
            {
                foreach (Stroke dbStroke in c.StrokeList)
                {
                    plso.ReveivePoints(dbStroke.AllPoints);
                }
            }

            //show viewing area
            ma.ShowDialog();
            ma.Hide();
            ma.Close();
            ma.Dispose();
            t.Abort();

//            Application.Run(new MirrorArea(plso));
        }
Пример #2
0
        private static void RunConverter()
        {
            //Converter.ConvertInputToFinalFormat(new FileStream("C:\\Diplom\\kanjiteacher\\data\\strokes.txt", FileMode.Open));
            //Converter.ConvertInputToFinalFormat(new FileStream("C:\\Diplom\\kanjiteacher\\data\\char00255.notQuite.inkml", FileMode.Open));
            //Converter.ConvertInputToFinalFormat(new FileStream("C:\\Diplom\\kanjiteacher\\data\\strokes2.txt", FileMode.Open));

            List <Character> cList =
                UPXReader.ParseUPXFile(
                    new FileStream("C:\\Diplom\\kanjiteacher\\data\\exampleFormat.upx", FileMode.Open));

            DirectoryInfo di = Directory.CreateDirectory("C:\\Diplom\\kanjiteacher\\data");

            foreach (Character c in cList)
            {
                XmlDocument doc      = UPXReader.CreateXMLDocumentFromCharacter(c);
                string      filename = "char" + c.SHKK + ".INOUT.inkml";
                UPXReader.WriteXMLDocumentToFile(doc, Path.Combine(di.FullName, filename));
            }
        }
Пример #3
0
        /// <summary>
        /// Tests the hash table.
        /// </summary>
        private static void TestHashTable()
        {
            /* Concept:
             * The "database" dictionary holds all the strokes from the DB (once)
             * stored under the name of their md5-hash
             *
             * The "inputlist" List<Stroke> contains all the
             * strokes that come in from the user.
             *
             * The value is a dictionary with keys: md5hash of input
             * and value: input stroke
             *
             * Open question:
             * where are the real strokes stored?
             * proposal: in a second dictionary
             * Dictionary<byte[], Stroke> database = new Dictionary<byte[], Stroke>();
             */

            Dictionary <byte[], Dictionary <byte[], double> > matchingscores =
                new Dictionary <byte[], Dictionary <byte[], double> >();

            List <Character> characterdatabase =
                UPXReader.ParseUPXFile(
                    File.Open("C:\\Diplom\\kanjiteacher\\data\\exampleFormat.upx", FileMode.Open));

            //Dictionary<byte[], Stroke> database = new Dictionary<byte[], Stroke>();

            List <Stroke> inputlist = null;

            //take random strokes as inputlist
            inputlist = new List <Stroke>()
            {
                GetAlmostRandomStroke(0), GetAlmostRandomStroke(1)
            };
            //takes strokes of the same character from inputlist
            inputlist = InkMLReader.ReadInkMLFile("char00255.inkml");

            ////fill the stroke database with the strokes from all the characters
            ////stored under their hash codes
            //foreach (Character c in characterdatabase)
            //    foreach (Stroke s in c.StrokeList)
            //        database.Add(s.Hash(false), s);

            //go through all the strokes in the database
            foreach (Character c in characterdatabase)
            {
                //go through all the strokes in the list of input strokes
                foreach (Stroke s in inputlist)
                {
                    foreach (Stroke dbStroke in c.StrokeList)
                    {
                        //calculate the matching score
                        double score = dbStroke.MatchingScore(s, new TWStrokeMatcher());

                        //store the score in big matrix of stroke match values
                        if (!matchingscores.Keys.Contains(dbStroke.Hash()))
                        {
                            //add the score under the correct key in a new dictionary
                            //under the current strokes key
                            matchingscores.Add(
                                dbStroke.Hash(),
                                new Dictionary <byte[], double>()
                            {
                                { s.Hash(false), score }
                            });
                        }
                        else
                        {
                            //add new score for the input stroke to the
                            //existing matching dict at the entry of the current database stroke
                            matchingscores[dbStroke.Hash()].Add(s.Hash(), score);
                        }
                    }
                }
            }

            MatrixPrinter m = new MatrixPrinter(matchingscores);

            Console.WriteLine(m.print());

            Console.WriteLine(
                "Now find total minimum of these scores" +
                "i.e. go ahead and do some matrix operation in order to find" +
                "the minimum of each row." +
                "if stroke number is identical, consider position within matrix" +
                "each row can only have one best matching column" +
                "each column can only have one best matching row" +
                "find total minimum and return it"
                );
        }