public static Dawg <FormInterpretations> CreateDAWG(MRDFileReader mrdFile) { DateTime start = DateTime.Now; Console.WriteLine("Inserting forms in DAWG... Please wait..."); DawgSharp.DawgBuilder <FormInterpretations> dawgBuilder = new DawgBuilder <FormInterpretations>(); UInt64 cntForms = 0; foreach (WordForm f in mrdFile.AllForms) { string word = f.Prefix + f.Flexia.Prefix + f.Lemma.Base + f.Flexia.Flexion; FormInterpretations payload = null; dawgBuilder.TryGetValue(word, out payload); if (payload == null) { payload = new FormInterpretations(); dawgBuilder.Insert(word, payload); } payload.Add(f); cntForms++; } Console.WriteLine("All forms count: " + cntForms); Console.WriteLine("Building... please wait..."); Dawg <FormInterpretations> dawg = dawgBuilder.BuildDawg(); Console.WriteLine("DAWG create time: {0}", DateTime.Now - start); return(dawg); }
public void EmptyKey() { var db = new DawgBuilder <int>(); Assert.False(db.TryGetValue("", out int n)); Assert.AreEqual(0, n); }
private static void Increment(DawgBuilder <int> db, string key) { int n; db.TryGetValue(key, out n); db.Insert(key, n + 1); }
public void EmptyKey() { var db = new DawgBuilder<int>(); int n; Assert.AreEqual(true, db.TryGetValue("", out n)); Assert.AreEqual(0, n); }
public void TryGetValueOnPartialKey() { var builder = new DawgBuilder <bool>(); builder.Insert("dates", true); bool b = builder.TryGetValue("date", out var v); Assert.False(v); Assert.False(b); }
/// <summary> /// Добавляет новую лексему к модели. /// </summary> /// <param name="lexem">Лексема.</param> public void AddLexem(WordForm lexem) { ulong tagOut = (ulong)Tag.NoWord; ulong tag = (ulong)lexem.Tag; if (builder.TryGetValue(lexem.Word, out tagOut)) { tag |= tagOut; } builder.Insert(lexem.Word, tag); }
public void TryGetValueUnexpectedBehaviour() { var builder = new DawgBuilder <string>(); builder.Insert("dates", "dates"); bool b = builder.TryGetValue("date", out var v); Assert.True(b); Assert.Null(v); }
public void IncrementValue() { var db = new DawgBuilder<int>(); Increment(db, "test"); Increment(db, "test"); Increment(db, "test"); int n; Assert.AreEqual(true, db.TryGetValue("test", out n)); Assert.AreEqual(3, n); }
public void IncrementValue() { var db = new DawgBuilder <int>(); Increment(db, "test"); Increment(db, "test"); Increment(db, "test"); int n; Assert.AreEqual(true, db.TryGetValue("test", out n)); Assert.AreEqual(3, n); }
public void IndexTerm(DocumentId id, string word, int position) { builder.TryGetValue(word, out var blockList); if (blockList == null) { blockList = new RangePostingsList(); builder.Insert(word, blockList); } blockList.Add(id); allDocuments.Add(id); }
private static void Increment(DawgBuilder<int> db, string key) { int n; db.TryGetValue(key, out n); db.Insert(key, n + 1); }