コード例 #1
0
 long GetNextEmbedInx(EmbedDictDbSet embed)
 {
     if (!_curEmbedInx.HasValue)
     {
         _curEmbedInx = embed.SelectInxMax();
         if (!_curEmbedInx.HasValue)
         {
             _curEmbedInx = -1;
         }
     }
     _curEmbedInx = _curEmbedInx.Value + 1;
     return(_curEmbedInx.Value);
 }
コード例 #2
0
        long GetOrAddEmbed(EmbedDictDbSet embed
                           , long?dict_id, DictDbSet.DictKind dict_kind, string word, LangLabel lang)
        {
            long?inx = null;

            if (dict_id.HasValue)
            {
                inx = embed.FindInxById(dict_id.Value, dict_kind);
            }

            if (inx.HasValue)
            {
                var item = new ExistingItem {
                    FreqAdd = 0
                };
                lock (SetOfDirtyLock)
                {
                    if (SetOfDirty.ContainsKey(inx.Value))
                    {
                        item = SetOfDirty[inx.Value];
                    }
                    item.FreqAdd++;
                    SetOfDirty[inx.Value] = item;
                }
            }
            else
            {
                var item = new NewItem {
                    DictKind = dict_kind, DictId = dict_id, Freq = 0
                };
                lock (SetOfNewLock)
                {
                    var set_of_new = GetSetOfNew(lang);
                    if (set_of_new.ContainsKey(word))
                    {
                        item = set_of_new[word];
                    }
                    else
                    {
                        item.Inx = GetNextEmbedInx(embed);
                    }
                    inx = item.Inx;
                    item.Freq++;
                    set_of_new[word] = item;
                }
            }
            return(inx.Value);
        }
コード例 #3
0
        long WordToInx(string word, DictDbSet dict, DictDbSet dict_addins, EmbedDictDbSet embed)
        {
            long embed_inx;
            long?cur_id = dict.FindIdByWord(word);

            if (cur_id.HasValue)
            {
                embed_inx = GetOrAddEmbed(embed, cur_id, DictDbSet.DictKind.Main, word);
            }
            else
            {
                cur_id    = dict_addins.FindIdByWord(word);
                embed_inx = GetOrAddEmbed(embed, cur_id, DictDbSet.DictKind.Addin, word);
            }
            return(embed_inx);
        }