コード例 #1
0
ファイル: Program.cs プロジェクト: hefangshi/dolmap-data
 static void Main(string[] args)
 {
     var now = DateTime.Now;
     QuestDM dm = new QuestDM();
     SimDM simDM = new SimDM();
     var questList = dm.Load();
     var nowCount = 0;
     questList.All(quest =>
     {
         nowCount++;
         if (quest.RouteForSim.Count != 0)
         {
             var sw = new Stopwatch();
             sw.Start();
             var count = 0;
             quest.RouteForSim.All(route =>
             {
                 if (route.Count < 2)
                     return true;
                 var simList = Compare(quest, route.ToArray(), questList);
                 simDM.Save(simList);
                 count += simList.Count();
                 return true;
             });
             Console.Out.WriteLine("[" + nowCount + "/" + questList.Count + "]   Name:" + quest.Name + "," + "  Time:" + sw.ElapsedMilliseconds + " 匹配任务:" + count);
             sw.Restart();
         }
         return true;
     });
     Console.Out.WriteLine("处理完成,总耗时"+(DateTime.Now-now).TotalMinutes+"min");
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: hefangshi/dolmap-data
        static void Main(string[] args)
        {
            var stream = new StreamReader(@"D:\Code\dolspider\QuestTransFix\bin\x86\Debug\haha.csv", Encoding.Default);
            var line = stream.ReadLine();
            using (MySqlConnection conn = new MySqlConnection("server = localhost; user id = root; password = ; database = test"))
            {
                conn.Open();
                var cmd = conn.CreateCommand();
                cmd.CommandText = "set character set 'utf8'";
                cmd.ExecuteNonQuery();
                QuestDM dm=new QuestDM();
                var list = dm.Load();
                foreach(Quest quest in list)
                {
                    var namePY = pinyin.GetAllFirstPinyin(quest.Name);
                    var id = quest.ID;
                    Trace.WriteLine(namePY + ":" + quest.Name);
                    var query = "update test.quest set for_short=?forshort where id=?id";
                    cmd = conn.CreateCommand();
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("?id", id);
                    cmd.Parameters.AddWithValue("?forshort", namePY);
                    cmd.ExecuteNonQuery();
                }
            }
            return;

            //var stream = new StreamReader(@"D:\Code\dolspider\QuestTransFix\bin\x86\Debug\haha.csv",Encoding.Default);
            //var line = stream.ReadLine();
            //using (MySqlConnection conn = new MySqlConnection("server = localhost; user id = root; password = ; database = test"))
            //{
            //    conn.Open();
            //    var cmd = conn.CreateCommand();
            //    cmd.CommandText = "set character set 'utf8'";
            //    cmd.ExecuteNonQuery();
            //    while (line != null)
            //    {
            //        var split = line.Split(',');
            //        var id = split[0];
            //        var toName = split[2];
            //        var oldName = split[1];
            //        var namePY = pinyin.GetAllFirstPinyin(toName);
            //        var query = "update test.quest set name=?name,for_short=?forshort where oldname=?oldName";
            //        cmd = conn.CreateCommand();
            //        cmd.CommandText = query;
            //        cmd.Parameters.AddWithValue("?oldName", oldName);
            //        cmd.Parameters.AddWithValue("?name", toName);
            //        cmd.Parameters.AddWithValue("?forshort", namePY);
            //        cmd.ExecuteNonQuery();
            //        line = stream.ReadLine();
            //    }
            //}

            //QuestDM dm = new QuestDM();
            //QuestEnDM en_dm = new QuestEnDM();
            //var questList = dm.Load();
            //var questEnList = en_dm.Load().Where(x => !x.Name.StartsWith("发送") && x.Name != "野狗的地图" && x.Name != "星花的地图").ToList();
            //SimQuestFinder finder = new SimQuestFinder();
            //int found = 0;
            //int notfound = 0;
            //int noneed = 0;
            //int wrongFound = 0;
            //Dictionary<string, string> translate = new Dictionary<string, string>();
            //questList.All(quest =>
            //{
            //    var foundQuestList = finder.FindSim(quest, questEnList).OrderBy(x => x.Key);
            //    if (foundQuestList.Count() == 0)
            //    {
            //        notfound++;
            //        return true;
            //    }
            //    foreach (KeyValuePair<int, Quest> toQuest in foundQuestList)
            //    {
            //        var sim = toQuest.Key;
            //        var toName = toQuest.Value.Name;
            //        var fromName = quest.Name;
            //        if (sim < -1000)
            //            noneed++;
            //        else
            //        {
            //            if (sim < 2000)
            //            {
            //                if ((translate.ContainsKey(fromName) == false || translate[fromName] != toName) && translate.ContainsValue(toName) == true)
            //                    continue;
            //                if (translate.ContainsKey(fromName) == false)
            //                    translate.Add(fromName, toName);
            //                if (toName.EndsWith("地图") && sim > 6)
            //                    sim += 30;
            //                found++;
            //                Console.Out.WriteLine(String.Format("{3},{0},{1},{2}", fromName, toName, sim, found));
            //            }
            //            else
            //            {
            //                wrongFound++;
            //            }
            //        }
            //        break;
            //    }
            //    return true;
            //});
            //Console.Out.WriteLine(String.Format("{0}置信翻译,{1}不确定翻译,{2}未寻找到翻译,{3}无需翻译", found, wrongFound, notfound, noneed));
            //Console.ReadLine();
        }