Ejemplo n.º 1
0
        public MH2O(char[] magic, byte[] size, byte[] content) : base(magic, size)
        {
            using (BinaryReader reader = new BinaryReader(new MemoryStream(content)))
            {
                for (int x = 0; x < 256; x++)
                {
                    MH2O_Header hdr = new MH2O_Header();
                    hdr.Offset_attributes = reader.ReadUInt32();
                    hdr.Layer_count       = reader.ReadUInt32();
                    hdr.Offset_instances  = reader.ReadUInt32();

                    mH2O_Headers.Add(hdr);

                    if (hdr.Layer_count > 0)
                    {
                        entriesWithLiquid++;
                    }
                }

                for (int x = 0; x < entriesWithLiquid; x++)
                {
                    data1 data = new data1();
                    data.Flags   = reader.ReadUInt16();
                    data.Type    = reader.ReadUInt16();
                    data.Height1 = reader.ReadSingle();
                    data.Height2 = reader.ReadSingle();
                    data.Xoff    = reader.ReadByte();
                    data.Yoff    = reader.ReadByte();
                    data.W       = reader.ReadByte();
                    data.H       = reader.ReadByte();
                    data.Of2a    = reader.ReadUInt32();
                    data.Of2b    = reader.ReadUInt32();

                    data1s.Add(data);
                }

                for (int x = 0; x < entriesWithLiquid; x++)
                {
                    data2 data = new data2();
                    data.A = reader.ReadBytes(8);
                    data.B = reader.ReadBytes(8);

                    data2s.Add(data);
                }

                while (reader.BaseStream.Position < reader.BaseStream.Length)
                {
                    rest.Add(reader.ReadByte()); //The remaining bytes we just leave bytes. I don't understand them and don't have to change them, lul.
                }
            }
        }
Ejemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string Mispath  = @"F:\BaiduNetdiskDownload\misspell.txt";
            string Dictpath = @"F:\BaiduNetdiskDownload\dict.txt";
            string Corrpath = @"F:\BaiduNetdiskDownload\correct.txt";

            Data(Mispath);
            Data(Dictpath);
            Data(Corrpath);

            data Misspell   = list[0];
            data Dictionary = list[1];
            data Correct    = list[2];
            GED  ged        = new GED();

            double[] distances = new double[Dictionary.strs.Length];
            int      num       = 0;

            int[] No = new int[Dictionary.strs.Length + 1];


            for (int i = 0; i < Misspell.strs.Length; i++)
            {
                data2 temp = new data2();

                for (int j = 0; j < Dictionary.strs.Length; j++)
                {
                    distances[j] = ged.getStringDistance(Misspell.strs[i], Dictionary.strs[j]);
                }
                getMin(distances, ref No);
                for (int j = 0; j < No.Length && No[j] != -1; j++)
                {
                    temp.strs.Add(Dictionary.strs[No[j]]);
                }
                pd.Add(temp);
            }

            num = 0;

            for (int i = 0; i < Correct.strs.Length; i++)
            {
                if (Correct.strs[i] != pd[i].strs[0])
                {
                    num++;
                }
            }
            double Accuracy = 1 - num / Correct.strs.Length;

            num = 0;
            int count = 0;

            for (int i = 0; i < pd.Count; i++)
            {
                for (int j = 0; j < pd[i].strs.Count; j++)
                {
                    if (Correct.strs[i] != pd[i].strs[j])
                    {
                        num++;
                    }
                    count++;
                }
            }
            double Precision = 1 - num / count;

            num = 0;
            for (int i = 0; i < pd.Count; i++)
            {
                for (int j = 0; j < pd[i].strs.Count; j++)
                {
                    if (Correct.strs[i] == pd[i].strs[j])
                    {
                        num++;
                    }
                }
            }
            double Recall = 1 - num / Correct.strs.Length;

            Result.Text += ("Accuracy:" + Accuracy + "\n");
            Result.Text += ("Precision:" + Precision + "\n");
            Result.Text += ("Recall:" + Recall + "\n");
        }