public IGlossaryEntry Get(string ID) { IGlossaryEntry result = (from entry in glossary where entry.ID == ID select entry).FirstOrDefault(); return(result); }
public IGlossaryEntry FindWord(string word) { IGlossaryEntry result = (from entry in glossary where entry.Word == word select entry).FirstOrDefault(); return(result); }
public void DelEntry(string ID) { IGlossaryEntry entry = Get(ID); if (entry != null) { glossary.Remove(entry); } }
private void CheckForDuplicate(string ID, string word) { IGlossaryEntry entry = Get(ID); if (entry == null) { entry = FindWord(word); } if (entry != null) { throw new DuplicateEntryException(String.Format("Found duplicate - ID: {0}, word: {1}", entry.ID, entry.Word)); } }
private SynSet FindSynset(IGlossaryEntry entry, WordNetEngine wordnet) { // TODO: find POS, use only nouns for now int? minDistance = null; SynSet result = null; foreach (SynSet synset in wordnet.GetSynSets(entry.Word, WordNetEngine.POS.Noun)) { int distance = LevenshteinDistance.Compute(entry.Definition, synset.Gloss); if (minDistance == null || minDistance > distance) { result = synset; } } return(result); }
protected override SynSet SelectSynset(string word, POS pos) { SynSet result = base.SelectSynset(word, pos); // temporary WordNetEngine.POS wordnetPos = pos.ForWordnet(); if (wordnetPos != WordNetEngine.POS.None) { IGlossaryEntry glossEntry = glossary.FindWord(word); if (glossEntry == null) { Set <SynSet> synsets = wordnet.GetSynSets(word, wordnetPos); foreach (SynSet synset in synsets) { // great algorythms will be added here } } else { result = glossEntry.Synset; } } return(result); }
public void DelEntry(IGlossaryEntry entry) { glossary.Remove(entry); }
public void Add(IGlossaryEntry entry) { CheckForDuplicate(entry.ID, entry.Word); glossary.Add(entry); }