Exemplo n.º 1
0
        public void AddInputPromptWordCite(string txt)
        {
            if (txt.xIsNullOrEmptyOrSpace())
            {
                return;
            }

            if (_prompDict.ContainsKey(txt))
            {
                var prompt = _prompDict.xTryGetValue(txt, null);
                if (prompt != null)
                {
                    prompt.UpdateLatestUse(txt);
                }
            }
            else
            {
                var wdDict     = WordSpliter.Split(txt, true);
                int wordsCount = wdDict.Values.Sum(k => k.Count);
                if (wordsCount > 0)
                {
                    var prompt = InputPromptString.Create(txt, wordsCount, wdDict, null);
                    if (_prompDict.TryAdd(txt, prompt))
                    {
                        foreach (var w in wdDict)
                        {
                            GetInputPromptWordCite(w.Key).Add(prompt);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static InputPromptString Create(string text, int wordsCount, Dictionary <string, List <int> > wordDict, object tag)
        {
            var prompt = new InputPromptString
            {
                Text = text,
                Tag  = tag,
                IsShortcutOrRuleAnswer = true,
                UseCount   = 2,
                LatestUse  = BatTime.Now.Date.AddDays(-1.0),
                WordsCount = wordsCount
            };

            prompt.AddOrUpdateWordCount(wordDict);
            return(prompt);
        }
Exemplo n.º 3
0
        public void AddOrUpdateInputPromptWordCite(ShortcutEntity shortcut)
        {
            if (shortcut == null || (string.IsNullOrEmpty(shortcut.Title) && string.IsNullOrEmpty(shortcut.Text)))
            {
                return;
            }
            var text = string.Concat(shortcut.Code, " ", shortcut.Title, " ", shortcut.Text);

            text = text.Trim().ToLower();
            var key = shortcut.Text.xToBanJiaoAndRemoveCharThatAsciiValueLessThan32AndToLower();

            if (_prompDict.ContainsKey(key))
            {
                var prompt = _prompDict.xTryGetValue(key, null);
                if (prompt != null)
                {
                    prompt.AddUseCount(1);
                }
            }
            else
            {
                var wdDict    = WordSpliter.Split(text, true);
                int wordCount = wdDict.Values.Sum(k => k.Count);
                if (wordCount > 0)
                {
                    var prompt = InputPromptString.Create(text, wordCount, wdDict, shortcut);
                    if (_prompDict.TryAdd(key, prompt))
                    {
                        foreach (var w in wdDict)
                        {
                            GetInputPromptWordCiteData(w.Key).Add(prompt);
                        }
                    }
                }
            }
        }