public LexiconSense AddSense() { LexiconSense sense = null; bool lexemeAdded = false; using (m_lexicon.ActivationContext.Activate()) { NonUndoableUnitOfWorkHelper.Do(m_lexicon.Cache.ActionHandlerAccessor, () => { IWfiWordform wordform; if (!m_lexicon.TryGetWordform(m_key.LexicalForm, out wordform)) { wordform = m_lexicon.CreateWordform(m_key.LexicalForm); lexemeAdded = true; } // For wordforms, our "senses" could be new meanings of an analysis for the word // or it could be a brand new analysis. Because we have no idea what the user actually // wanted, we just assume the worst (they want to create a new analysis for the word // with a new meaning). IWfiAnalysis analysis = m_lexicon.Cache.ServiceLocator.GetInstance <IWfiAnalysisFactory>().Create(); wordform.AnalysesOC.Add(analysis); analysis.ApprovalStatusIcon = (int)Opinions.approves; // Assume the analysis from the external application is user approved IMoStemAllomorph morph = m_lexicon.Cache.ServiceLocator.GetInstance <IMoStemAllomorphRepository>().AllInstances().FirstOrDefault(allo => { ITsString tss = allo.Form.StringOrNull(m_lexicon.DefaultVernWs); if (tss != null) { return(tss.Text == LexicalForm.Normalize(NormalizationForm.FormD)); } return(false); }); if (morph != null) { IWfiMorphBundle mb = m_lexicon.Cache.ServiceLocator.GetInstance <IWfiMorphBundleFactory>().Create(); analysis.MorphBundlesOS.Add(mb); mb.MorphRA = morph; var entry = morph.OwnerOfClass <ILexEntry>(); mb.SenseRA = entry.SensesOS[0]; mb.MsaRA = entry.SensesOS[0].MorphoSyntaxAnalysisRA; } IWfiGloss gloss = m_lexicon.Cache.ServiceLocator.GetInstance <IWfiGlossFactory>().Create(); analysis.MeaningsOC.Add(gloss); sense = new WfiGlossLexiconSense(m_lexicon, m_key, gloss); }); } if (lexemeAdded) { m_lexicon.OnLexemeAdded(this); } m_lexicon.OnLexiconSenseAdded(this, sense); return(sense); }
public string GetSimpleFormForLogging() { string formForLogging; try { formForLogging = LexicalForm.GetFirstAlternative(); } catch (Exception) { formForLogging = "(unknown)"; } return(formForLogging); }
public LanguageForm GetHeadWord(string writingSystemId) { if (string.IsNullOrEmpty(writingSystemId)) { throw new ArgumentException("writingSystemId"); } MultiText citationMT = GetProperty <MultiText>(WellKnownProperties.Citation); LanguageForm headWord; if (citationMT == null || (headWord = citationMT.Find(writingSystemId)) == null) { headWord = LexicalForm.Find(writingSystemId); } return(headWord); }
public override int GetHashCode() { return((LexicalForm?.GetHashCode() ?? 0) + (Datatype?.GetHashCode() ?? 0) + (LanguageTag?.GetHashCode() ?? 0)); }