Пример #1
0
        public TwitterCheck()
        {
            var settings = ConfigurationManager.AppSettings;

            var blackWords = new List<string>();
            var whiteWords = new List<string>();
            for (int i = 1; i <= SettingMax; i++)
            {
                string black = settings["twitter.blackwords." + i];
                if (black == null) continue;
                foreach (var elem in black.Split(','))
                {
                    blackWords.Add(elem);
                }
                string white = settings["twitter.whitewords." + i];
                if (white == null) continue;
                foreach (var elem in white.Split(','))
                {
                    whiteWords.Add(elem);
                }
            }
            BlackWords = blackWords.AsReadOnly();
            WhiteWords = whiteWords.AsReadOnly();
            Log.Trace.TraceEvent(TraceEventType.Information, 0,
                "{0} black words loaded", BlackWords.Count);
            Log.Trace.TraceEvent(TraceEventType.Information, 0,
               "{0} white words loaded", WhiteWords.Count);

            var replaceList = new List<KeyValuePair<string, string>>();
            for (int i = 1; i <= SettingMax; i++)
            {
                string str = settings["twitter.replace." + i];
                if (str == null) continue;
                foreach (var pair in str.Split(','))
                {
                    string[] kv = pair.Split('=');
                    replaceList.Add(new KeyValuePair<string, string>(kv[0], kv[1]));
                }
            }
            ReplaceList = replaceList.AsReadOnly();
            Log.Trace.TraceEvent(TraceEventType.Information, 0,
                "{0} replace entries loaded", ReplaceList.Count);

            try
            {
                dlNetwork = DollsLib.Learning.DataManager.LoadDeepLearning(
                    SettingManager.Settings.Twitter.DlNetTrainError);
            }
            catch (Exception)
            {
                Log.Trace.TraceEvent(TraceEventType.Warning, 0,
                "DlNwtwork {0} load failed", SettingManager.Settings.Twitter.DlNetTrainError);
            }
        }