long InsertDict(FastTextProcessDB dbx, Dict w2v, DictDbSet.DictKind kind) { var w2v_tbl = dbx.Dict(DictDbSet.DictKind.Main); w2v_tbl.Insert(w2v); return(w2v.Id); }
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); }
public long?FindInxById(long id, DictDbSet.DictKind dict_kind) { object res = null; if (dict_kind == DictDbSet.DictKind.Main) { CmdFindInxByDictId.Parameters[EmbedDict.FldnDictId].Value = id; res = CmdFindInxByDictId.ExecuteScalar(); } else if (dict_kind == DictDbSet.DictKind.Addin) { CmdFindInxByDictAddinsId.Parameters[EmbedDict.FldnDictAddinsId].Value = id; res = CmdFindInxByDictAddinsId.ExecuteScalar(); } else { throw new NotSupportedException($"{dict_kind} not supported"); } return(res == null || DBNull.Value.Equals(res) ? (long?)null : Convert.ToInt64(res)); }
public DictDbSet Dict(DictDbSet.DictKind db_kind) => new DictDbSet(this, db_kind);