Esempio n. 1
0
 public void RemoveLexeme(Lexeme lexeme)
 {
     if (lexeme.Type == LexemeType.Word)
     {
         IWfiWordform wordform;
         if (TryGetWordform(lexeme.LexicalForm, out wordform))
         {
             NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor, () => wordform.Delete());
         }
     }
     else
     {
         var       entryLexeme = (FdoLexEntryLexeme)lexeme;
         ILexEntry entry;
         if (TryGetEntry(entryLexeme.Key, out entry))
         {
             var key = new LexemeKey(lexeme.Type, lexeme.LexicalForm);
             SortedSet <ILexEntry> entries = m_entryIndex[key];
             entries.Remove(entry);
             UpdatingEntries = true;
             try
             {
                 NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor, () => entry.Delete());
             }
             finally
             {
                 UpdatingEntries = false;
             }
         }
     }
 }
Esempio n. 2
0
        private void CreateEntryIndexIfNeeded()
        {
            if (m_entryIndex != null)
            {
                return;
            }

            m_entryIndex = new Dictionary <LexemeKey, SortedSet <ILexEntry> >();
            foreach (ILexEntry entry in m_cache.ServiceLocator.GetInstance <ILexEntryRepository>().AllInstances())
            {
                LexemeType type = GetLexemeTypeForMorphType(entry.PrimaryMorphType);
                string     form = entry.LexemeFormOA == null ? string.Empty : entry.LexemeFormOA.Form.VernacularDefaultWritingSystem.Text ?? string.Empty;
                var        key  = new LexemeKey(type, form.Normalize());

                SortedSet <ILexEntry> entries;
                if (!m_entryIndex.TryGetValue(key, out entries))
                {
                    entries           = new SortedSet <ILexEntry>(m_entryComparer);
                    m_entryIndex[key] = entries;
                }

                HomographNumber hn = m_homographNumbers.GetOrCreateValue(entry);
                if (hn.Number == 0)
                {
                    int num = 1;
                    foreach (ILexEntry e in entries)
                    {
                        if (m_homographNumbers.GetOrCreateValue(e).Number != num)
                        {
                            break;
                        }
                        num++;
                    }
                    hn.Number = num;
                }

                entries.Add(entry);
            }
        }
Esempio n. 3
0
        internal ILexEntry CreateEntry(LexemeKey key)
        {
            CreateEntryIndexIfNeeded();

            ITsString tss = TsStringUtils.MakeString(key.LexicalForm.Normalize(NormalizationForm.FormD), DefaultVernWs);
            var       msa = new SandboxGenericMSA {
                MsaType = (key.Type == LexemeType.Stem) ? MsaType.kStem : MsaType.kUnclassified
            };
            ILexEntry entry = m_cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create(GetMorphTypeForLexemeType(key.Type), tss, (ITsString)null, msa);

            m_homographNumbers.GetOrCreateValue(entry).Number = key.Homograph;

            var homographKey = new LexemeKey(key.Type, key.LexicalForm);
            SortedSet <ILexEntry> entries;

            if (!m_entryIndex.TryGetValue(homographKey, out entries))
            {
                entries = new SortedSet <ILexEntry>(m_entryComparer);
                m_entryIndex[homographKey] = entries;
            }
            entries.Add(entry);

            return(entry);
        }
Esempio n. 4
0
        private bool TryGetLexeme(LexemeKey key, out Lexeme lexeme)
        {
            if (key.Type == LexemeType.Word)
            {
                IWfiWordform wf;
                if (TryGetWordform(key.LexicalForm, out wf))
                {
                    lexeme = new FdoWordformLexeme(this, key);
                    return(true);
                }
            }
            else
            {
                ILexEntry entry;
                if (TryGetEntry(key, out entry))
                {
                    lexeme = new FdoLexEntryLexeme(this, key);
                    return(true);
                }
            }

            lexeme = null;
            return(false);
        }
Esempio n. 5
0
			public LexSenseLexiconSense(FdoLexicon lexicon, LexemeKey lexemeKey, ILexSense lexSense)
			{
				m_lexicon = lexicon;
				m_lexemeKey = lexemeKey;
				m_lexSense = lexSense;
			}
Esempio n. 6
0
		public FdoLexEntryLexeme(FdoLexicon lexicon, LexemeKey key)
		{
			m_lexicon = lexicon;
			m_key = key;
		}
Esempio n. 7
0
 public LexSenseLexiconSense(FdoLexicon lexicon, LexemeKey lexemeKey, ILexSense lexSense)
 {
     m_lexicon   = lexicon;
     m_lexemeKey = lexemeKey;
     m_lexSense  = lexSense;
 }
Esempio n. 8
0
 public FdoLexEntryLexeme(FdoLexicon lexicon, LexemeKey key)
 {
     m_lexicon = lexicon;
     m_key     = key;
 }
Esempio n. 9
0
 public FdoWordformLexeme(FdoLexicon lexicon, LexemeKey key)
 {
     m_lexicon = lexicon;
     m_key     = key;
 }
Esempio n. 10
0
 public WfiGlossLexiconSense(FdoLexicon lexicon, LexemeKey lexemeKey, IWfiGloss gloss)
 {
     m_lexicon   = lexicon;
     m_lexemeKey = lexemeKey;
     m_gloss     = gloss;
 }
Esempio n. 11
0
 internal bool TryGetEntry(LexemeKey key, out ILexEntry entry)
 {
     entry = GetMatchingEntries(key.Type, key.LexicalForm).FirstOrDefault(e => m_homographNumbers.GetOrCreateValue(e).Number == key.Homograph);
     return(entry != null);
 }
Esempio n. 12
0
		public FdoWordformLexeme(FdoLexicon lexicon, LexemeKey key)
		{
			m_lexicon = lexicon;
			m_key = key;
		}
Esempio n. 13
0
			public WfiGlossLexiconSense(FdoLexicon lexicon, LexemeKey lexemeKey, IWfiGloss gloss)
			{
				m_lexicon = lexicon;
				m_lexemeKey = lexemeKey;
				m_gloss = gloss;
			}