public bool TryAdd(RootEntry entry) { if (Roots.ById.ContainsKey(entry.Id)) { return false; } Add(entry); return true; }
public bool TryAdd(RootEntry entry) { if (Roots.ById.ContainsKey(entry.Id)) { return(false); } Add(entry); return(true); }
private void Add(RootEntry entry) { var rules = Orthography.GetRules(entry.Rules); var root = new Root(entry.Pos, entry.Lex, entry.Surfaces, entry.Labels, rules); Roots.ById.Add(entry.Id, root); foreach (string surface in entry.Surfaces) { Roots.BySurface.Add(surface, root); } }
public void Test() { var tr = LanguageFactory.Create(LanguageType.Turkish); var newTr = MutableLanguage.CopyFrom(tr); var entry = new RootEntry( lex: "başa gel", pos: "FIIL", surfaces: new[] {"başa gel"}, labels: new[] {"cverb"}, rules: Enumerable.Empty<string>()); Assert.True(newTr.TryAdd(entry)); var solutions = tr.Analyze("başa gelen"); Assert.AreEqual(0, solutions.Count); var solutionsExtendedTr = newTr.Analyze("başa gelen"); Assert.AreEqual(1, solutionsExtendedTr.Count); Assert.AreEqual("başa gel/FIIL FIILIMSI_SIFAT_(y)An", solutionsExtendedTr[0].Analysis); }