Ejemplo n.º 1
0
        public IGlossaryEntry Get(string ID)
        {
            IGlossaryEntry result = (from entry in glossary
                                     where entry.ID == ID
                                     select entry).FirstOrDefault();

            return(result);
        }
Ejemplo n.º 2
0
        public IGlossaryEntry FindWord(string word)
        {
            IGlossaryEntry result = (from entry in glossary
                                     where entry.Word == word
                                     select entry).FirstOrDefault();

            return(result);
        }
Ejemplo n.º 3
0
        public void DelEntry(string ID)
        {
            IGlossaryEntry entry = Get(ID);

            if (entry != null)
            {
                glossary.Remove(entry);
            }
        }
Ejemplo n.º 4
0
        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));
            }
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 public void DelEntry(IGlossaryEntry entry)
 {
     glossary.Remove(entry);
 }
Ejemplo n.º 8
0
 public void Add(IGlossaryEntry entry)
 {
     CheckForDuplicate(entry.ID, entry.Word);
     glossary.Add(entry);
 }