private void AddLine(string line, Source quelle) { var begriffe = line.Split('|').ToList(); if (begriffe.Count <= 1) { throw new FormatException("Die Zeile ist ungültig: " + line); } var newGroup = new SynonymGroup(begriffe, quelle); foreach (var begriff in begriffe) { if (dictionary.TryGetValue(begriff.ToLower(), out var synonymGroups)) { var existing = synonymGroups.FirstOrDefault(g => g.HasSameEntriesAs(newGroup)); if (existing != null) { if (!existing.Sources.Contains(quelle)) { existing.Sources.Add(quelle); } } else { synonymGroups.Add(newGroup); } } else { var groupList = new List <SynonymGroup>(1); groupList.Add(newGroup); dictionary.Add(begriff.ToLower(), groupList); } } }
public bool HasSameEntriesAs(SynonymGroup other) { return(Entries.Intersect(other.Entries).Count() == Entries.Count); }