示例#1
0
        /// <summary>
        /// </summary>
        public static void StartMemoryWorkers()
        {
            StopMemoryWorkers();
            var id = SettingsView.View.PIDSelect.Text == string.Empty
                         ? GetProcessID()
                         : Constants.ProcessModel.ProcessID;

            Constants.IsOpen = true;
            if (id < 0)
            {
                Constants.IsOpen = false;
                return;
            }

            MemoryHandler.Instance.ExceptionEvent       += MemoryHandler_ExceptionEvent;
            MemoryHandler.Instance.SignaturesFoundEvent += MemoryHandler_SignaturesFoundEvent;

            MemoryHandler.Instance.SetProcess(Constants.ProcessModel, Settings.Default.GameLanguage, "latest", Settings.Default.UseLocalMemoryJSONDataCache);

            _chatLogWorker = new ChatLogWorker();
            _chatLogWorker.StartScanning();
            _actorWorker = new ActorWorker();
            _actorWorker.StartScanning();
            _playerInfoWorker = new PlayerInfoWorker();
            _playerInfoWorker.StartScanning();
            _targetWorker = new TargetWorker();
            _targetWorker.StartScanning();
            _partyInfoWorker = new PartyInfoWorker();
            _partyInfoWorker.StartScanning();
            _inventoryWorker = new InventoryWorker();
            _inventoryWorker.StartScanning();
            _hotBarRecastWorker = new HotBarRecastWorker();
            _hotBarRecastWorker.StartScanning();
        }
示例#2
0
        /// <summary>
        /// </summary>
        public static void StartMemoryWorkers()
        {
            StopMemoryWorkers();
            var id = SettingsView.View.PIDSelect.Text == "" ? GetProcessID() : Constants.ProcessID;

            Constants.IsOpen = true;
            if (id < 0)
            {
                Constants.IsOpen = false;
                return;
            }
            var process = Process.GetProcessById(id);

            MemoryHandler.Instance.SetProcess(process);
            MemoryHandler.Instance.SigScanner.LoadOffsets(AppViewModel.Instance.Signatures);
            _chatLogWorker = new ChatLogWorker();
            _chatLogWorker.StartScanning();
            //_actionWorker = new ActionWorker();
            //_actionWorker.StartScanning();
            _actorWorker = new ActorWorker();
            _actorWorker.StartScanning();
            _monsterWorker = new MonsterWorker();
            _monsterWorker.StartScanning();
            _playerInfoWorker = new PlayerInfoWorker();
            _playerInfoWorker.StartScanning();
            _targetWorker = new TargetWorker();
            _targetWorker.StartScanning();
            _partyInfoWorker = new PartyInfoWorker();
            _partyInfoWorker.StartScanning();
            _inventoryWorker = new InventoryWorker();
            _inventoryWorker.StartScanning();
        }
示例#3
0
        /// <summary>
        /// </summary>
        public static void StartMemoryWorkers()
        {
            StopMemoryWorkers();
            var id = SettingsView.View.PIDSelect.Text == "" ? GetProcessID() : Constants.ProcessModel.ProcessID;

            Constants.IsOpen = true;
            if (id < 0)
            {
                Constants.IsOpen = false;
                return;
            }
            MemoryHandler.Instance.SetProcess(Constants.ProcessModel, Settings.Default.GameLanguage);
            _chatLogWorker = new ChatLogWorker();
            _chatLogWorker.StartScanning();
            _actorWorker = new ActorWorker();
            _actorWorker.StartScanning();
            _playerInfoWorker = new PlayerInfoWorker();
            _playerInfoWorker.StartScanning();
            _targetWorker = new TargetWorker();
            _targetWorker.StartScanning();
            _partyInfoWorker = new PartyInfoWorker();
            _partyInfoWorker.StartScanning();
            _inventoryWorker = new InventoryWorker();
            _inventoryWorker.StartScanning();
        }
示例#4
0
        static private void initializeEkmanAsTarget(Corpus corpus, int startIndex, int endIndex, IList <Sentence> sentences, ref IList <TargetWorker> targetWorkerList)
        {
            string[] data = File.ReadAllLines(corpus + "/EkmanData" + startIndex + "-" + endIndex + ".csv");
            foreach (string row in data)
            {
                string[]     labels = row.Split(',');
                TargetWorker worker = new TargetWorker(labels[0]);
                if (!targetWorkerList.Contains(worker))//重复的人不再添加
                {
                    targetWorkerList.Add(worker);
                }
                else
                {
                    worker = targetWorkerList.First(x => x.Equals(worker));
                }
                IList <Label> trueLabels = new List <Label>();
                for (int i = 1; i <= (endIndex - startIndex + 1) * (Constant.EkmanLabelArray.Length + 1); ++i)
                {
                    switch (labels[i])
                    {
                    case "Anger":
                        trueLabels.Add(Label.Anger);
                        break;

                    case "Sadness":
                        trueLabels.Add(Label.Sadness);
                        break;

                    case "Joy":
                        trueLabels.Add(Label.Joy);
                        break;

                    case "Disgust":
                        trueLabels.Add(Label.Disgust);
                        break;

                    case "Surprise":
                        trueLabels.Add(Label.Surprise);
                        break;

                    case "Fear":
                        trueLabels.Add(Label.Fear);
                        break;
                    }
                    if (i % (Constant.EkmanLabelArray.Length + 1) == 0)
                    {
                        //取出SentenceList里的一个Sentence
                        Sentence         sentence         = sentences[startIndex + (i - 1) / (Constant.EkmanLabelArray.Length + 1)];
                        TargetAnnotation targetAnnotation = new TargetAnnotation(trueLabels.ToArray());
                        trueLabels.Clear();
                        worker.SentenceTargetAnnotationDic.Add(sentence, targetAnnotation);
                        sentence.TargetWorkerTargetAnnotationDic.Add(worker, targetAnnotation);
                    }
                }
            }
        }
示例#5
0
        public void Start()
        {
            try
            {
                foreach (var currentServer in ServerName)
                {
                    TargetWorker worker = new TargetWorker()
                    {
                        ServerName            = currentServer,
                        SessionName           = SessionName,
                        UserName              = UserName,
                        Password              = Password,
                        DatabaseName          = DatabaseName,
                        FailOnProcessingError = FailOnProcessingError
                    };

                    foreach (Response r in Responses)
                    {
                        Response pr = (Response)r.Clone();
                        worker.Responses.Add(pr);
                    }

                    foreach (Response r in worker.Responses)
                    {
                        Debug.Print(ServerName + " " + r.GetType().Name + " " + r.Tokens.Count);
                        r.Tokens.Add("ServerName", worker.ServerName);
                    }

                    allTasks.Add(new Task(() => worker.Process()));
                }
                foreach (var t in allTasks)
                {
                    t.Start();
                }
                foreach (var t in allTasks)
                {
                    t.Wait();
                }
            }
            catch (Exception e)
            {
                logger.Error(e);
                throw;
            }
            logger.Info("Quitting");
        }
示例#6
0
        public void StartMemoryWorkers()
        {
            this.StopMemoryWorkers();

            this.ActionWorker        = new ActionWorker(this._memoryHandler);
            this.ActorWorker         = new ActorWorker(this._memoryHandler);
            this.ChatLogWorker       = new ChatLogWorker(this._memoryHandler);
            this.CurrentPlayerWorker = new CurrentPlayerWorker(this._memoryHandler);
            this.InventoryWorker     = new InventoryWorker(this._memoryHandler);
            this.JobResourceWorker   = new JobResourceWorker(this._memoryHandler);
            this.PartyWorker         = new PartyWorker(this._memoryHandler);
            this.TargetWorker        = new TargetWorker(this._memoryHandler);

            this.ActionWorker.StartScanning();
            this.ActorWorker.StartScanning();
            this.ChatLogWorker.StartScanning();
            this.CurrentPlayerWorker.StartScanning();
            this.InventoryWorker.StartScanning();
            this.JobResourceWorker.StartScanning();
            this.PartyWorker.StartScanning();
            this.TargetWorker.StartScanning();
        }
示例#7
0
 /// <summary>
 /// 只过滤标注Nakamura的worker,不管Train还是NotTrain,Source还是Target
 /// </summary>
 static public void FilterTargetWorker()
 {
     if (Constant.SourceTaxonomy.Name == TaxonomyType.Nakamura)
     {
         foreach (Sentence sentence in TrainConstant.SentenceList)
         {
             for (int i = sentence.SourceWorkerSourceAnnotationDic.Count - 1; i >= 30; --i)//用.Count就不用管sentence被标了40次还是41次
             {
                 SourceWorker sourceWorker = sentence.SourceWorkerSourceAnnotationDic.ElementAt(i).Key;
                 sentence.SourceWorkerSourceAnnotationDic.Remove(sourceWorker);
                 sourceWorker.SentenceSourceAnnotationDic.Remove(sentence);
             }
         }
         foreach (SourceWorker sourceWorker in TrainConstant.SourceWorkerList.ToArray())
         {
             if (sourceWorker.SentenceSourceAnnotationDic.Count == 0)
             {
                 TrainConstant.SourceWorkerList.Remove(sourceWorker);
             }
         }
         foreach (Sentence sentence in NotTrainConstant.SentenceList)
         {
             for (int i = sentence.SourceWorkerSourceAnnotationDic.Count - 1; i >= 30; --i)//用.Count就不用管sentence被标了40次还是41次
             {
                 SourceWorker sourceWorker = sentence.SourceWorkerSourceAnnotationDic.ElementAt(i).Key;
                 sentence.SourceWorkerSourceAnnotationDic.Remove(sourceWorker);
                 sourceWorker.SentenceSourceAnnotationDic.Remove(sentence);
             }
         }
         foreach (SourceWorker sourceWorker in NotTrainConstant.SourceWorkerList.ToArray())
         {
             if (sourceWorker.SentenceSourceAnnotationDic.Count == 0)
             {
                 NotTrainConstant.SourceWorkerList.Remove(sourceWorker);
             }
         }
     }
     else if (Constant.TargetTaxonomy.Name == TaxonomyType.Nakamura)
     {
         foreach (Sentence sentence in TrainConstant.SentenceList)
         {
             for (int i = sentence.TargetWorkerTargetAnnotationDic.Count - 1; i >= 30; --i)
             {
                 TargetWorker targetWorker = sentence.TargetWorkerTargetAnnotationDic.ElementAt(i).Key;
                 sentence.TargetWorkerTargetAnnotationDic.Remove(targetWorker);
                 targetWorker.SentenceTargetAnnotationDic.Remove(sentence);
             }
         }
         foreach (TargetWorker targetWorker in TrainConstant.TargetWorkerList.ToArray())
         {
             if (targetWorker.SentenceTargetAnnotationDic.Count == 0)
             {
                 TrainConstant.TargetWorkerList.Remove(targetWorker);
             }
         }
         foreach (Sentence sentence in NotTrainConstant.SentenceList)
         {
             for (int i = sentence.TargetWorkerTargetAnnotationDic.Count - 1; i >= 30; --i)
             {
                 TargetWorker targetWorker = sentence.TargetWorkerTargetAnnotationDic.ElementAt(i).Key;
                 sentence.TargetWorkerTargetAnnotationDic.Remove(targetWorker);
                 targetWorker.SentenceTargetAnnotationDic.Remove(sentence);
             }
         }
         foreach (TargetWorker targetWorker in NotTrainConstant.TargetWorkerList.ToArray())
         {
             if (targetWorker.SentenceTargetAnnotationDic.Count == 0)
             {
                 NotTrainConstant.TargetWorkerList.Remove(targetWorker);
             }
         }
     }
 }
示例#8
0
        static private void initializeNakaAsTarget(Corpus corpus, int startIndex, int endIndex, IList <Sentence> sentences, ref IList <TargetWorker> targetWorkerList)
        {
            string[] data = File.ReadAllLines(corpus + "/NakaData" + startIndex + "-" + endIndex + ".csv");//不需要单独做一个data-sample,因为sentence-sample以外的sentence在下面的for循环里遍历不到。
            foreach (string row in data)
            {
                string[]     labels = row.Split(',');   //labels[0]是用户名
                TargetWorker worker = new TargetWorker(labels[0]);
                if (!targetWorkerList.Contains(worker)) //重复的人不再添加
                {
                    targetWorkerList.Add(worker);
                }
                else
                {
                    worker = targetWorkerList.First(x => x.Equals(worker));
                }
                IList <Label> trueLabels = new List <Label>();
                for (int i = 1; i <= (endIndex - startIndex + 1) * (Constant.NakaLabelArray.Length + 1); ++i)
                {
                    switch (labels[i])
                    {
                    case "happiness":
                        trueLabels.Add(Label.喜Joy);
                        break;

                    case "fondness":
                        trueLabels.Add(Label.好Fondness);
                        break;

                    case "relief":
                        trueLabels.Add(Label.安Relief);
                        break;

                    case "anger":
                        trueLabels.Add(Label.怒Anger);
                        break;

                    case "sadness":
                        trueLabels.Add(Label.哀Sadness);
                        break;

                    case "fear":
                        trueLabels.Add(Label.怖Fear);
                        break;

                    case "shame":
                        trueLabels.Add(Label.恥Shame);
                        break;

                    case "disgust":
                        trueLabels.Add(Label.厭Disgust);
                        break;

                    case "excitement":
                        trueLabels.Add(Label.昂Excitement);
                        break;

                    case "surprise":
                        trueLabels.Add(Label.驚Surprise);
                        break;
                    }
                    if (i % (Constant.NakaLabelArray.Length + 1) == 0)
                    {
                        //取出SentenceList里的一个Sentence
                        Sentence         sentence         = sentences[startIndex + (i - 1) / (Constant.NakaLabelArray.Length + 1)];
                        TargetAnnotation targetAnnotation = new TargetAnnotation(trueLabels.ToArray());
                        trueLabels.Clear();
                        worker.SentenceTargetAnnotationDic.Add(sentence, targetAnnotation);
                        sentence.TargetWorkerTargetAnnotationDic.Add(worker, targetAnnotation);
                    }
                }
            }
        }