private static IComboHandler MakeCombo(IHelpTopicProvider helpTopicProvider, int tagComboIcon, SandboxBase sandbox, int hvoMorph, SelLevInfo[] rgvsli, int hvoSelObject) { IVwRootBox rootb = sandbox.RootBox; int hvoSbWord = sandbox.RootWordHvo; InterlinComboHandler handler = null; CachePair caches = sandbox.Caches; switch (tagComboIcon) { case ktagMorphFormIcon: handler = new IhMorphForm(); break; case ktagMorphEntryIcon: handler = new IhMorphEntry(helpTopicProvider); break; case ktagWordPosIcon: handler = new IhWordPos(); break; case ktagAnalysisIcon: ComboListBox clb2 = new ComboListBox(); clb2.StyleSheet = sandbox.StyleSheet; ChooseAnalysisHandler caHandler = new ChooseAnalysisHandler( caches.MainCache, hvoSbWord, sandbox.Analysis, clb2); caHandler.Owner = sandbox; caHandler.AnalysisChosen += new EventHandler( sandbox.Handle_AnalysisChosen); caHandler.SetupCombo(); return caHandler; case ktagWordGlossIcon: // line 6, word gloss. if (sandbox.ShouldAddWordGlossToLexicon) { if (hvoMorph == 0) { // setup the first hvoMorph hvoMorph = caches.DataAccess.get_VecItem(kSbWord, ktagSbWordMorphs, 0); } handler = new IhLexWordGloss(helpTopicProvider); } else { handler = new IhWordGloss(); } break; default: return null; } // Use the base class handler for most handlers. Override where needed. if (!(handler is IhWordPos)) { ComboListBox clb = new ComboListBox(); handler.m_comboList = clb; clb.SelectedIndexChanged += new EventHandler( handler.HandleComboSelChange); clb.SameItemSelected += new EventHandler( handler.HandleComboSelSame); // Since we may initialize with TsStrings, need to set WSF. handler.m_comboList.WritingSystemFactory = caches.MainCache.LanguageWritingSystemFactoryAccessor; } else { // REVIEW: Do we need to handle wsf for word POS combo? } handler.m_caches = caches; handler.m_hvoSelObject = hvoSelObject; handler.m_hvoSbWord = hvoSbWord; handler.m_hvoMorph = hvoMorph; handler.m_rgvsli = rgvsli; handler.m_rootb = rootb; handler.m_wsVern = sandbox.RawWordformWs; handler.m_wsAnal = caches.MainCache.DefaultAnalWs; handler.m_wsUser = caches.MainCache.DefaultUserWs; handler.m_sandbox = sandbox; handler.m_fUnderConstruction = true; handler.SetupCombo(); if (handler.m_comboList != null) handler.m_comboList.StyleSheet = sandbox.StyleSheet; handler.m_fUnderConstruction = false; return handler; }
private bool SbWordGlossMatchesSenseGloss(IhMorphEntry.MorphItem morphItem) { if (morphItem.m_hvoSense <= 0) return false; // compare our gloss information. List<int> wordGlossWss = m_choices.WritingSystemsForFlid(InterlinLineChoices.kflidWordGloss); foreach (int wsId in wordGlossWss) { if (!IsMlSame(m_hvoSbWord, ktagSbWordGloss, wsId, morphItem.m_hvoSense, LexSenseTags.kflidGloss)) { // the sandbox word gloss differs from the sense gloss, so go to the next morphItem. return false; } } return true; }
/// <summary> /// see if the MainPossibilities match for the given morphItem and /// the Word Part of Speech in the sandbox /// </summary> /// <param name="morphItem"></param> /// <returns></returns> private bool SbWordMainPosMatchesSenseMsaMainPos(IhMorphEntry.MorphItem morphItem) { var targetPos = m_caches.RealObject(m_sda.get_ObjectProp(m_hvoSbWord, ktagSbWordPos)) as IPartOfSpeech; int hvoMainPosCandidate = 0; int hvoMainPosTarget = 0; // currently only support MoStemMsa, since that is what a WordPos expects to match against. // (but -- see FWR-3475 part 2 -- the user can pathologically analyze a whole word as an affix // in which case we MIGHT see another kind here, so use the root repository and 'as'. IPartOfSpeech posCandidate = null; if (morphItem.m_hvoMsa != 0) { var msa = m_caches.MainCache.ServiceLocator.GetInstance<IMoMorphSynAnalysisRepository>().GetObject(morphItem.m_hvoMsa) as IMoStemMsa; if (msa != null && msa.PartOfSpeechRA != null) { posCandidate = msa.PartOfSpeechRA; ICmPossibility mainPosCandidate = posCandidate.MainPossibility; if (mainPosCandidate != null) hvoMainPosCandidate = mainPosCandidate.Hvo; } } if (targetPos != null) { if (targetPos != null) { ICmPossibility mainPosTarget = targetPos.MainPossibility; if (mainPosTarget != null) hvoMainPosTarget = mainPosTarget.Hvo; } } return hvoMainPosCandidate == hvoMainPosTarget; }
private bool SbWordPosMatchesSenseMsaPos(IhMorphEntry.MorphItem morphItem) { var pos = m_caches.RealObject(m_sda.get_ObjectProp(m_hvoSbWord, ktagSbWordPos)) as IPartOfSpeech; // currently only support MoStemMsa, since that is what a WordPos expects to match against. // (but -- see FWR-3475 part 2 -- the user can pathologically analyze a whole word as an affix // in which case we MIGHT see another kind here, so use the root repository and 'as'. if (morphItem.m_hvoMsa != 0) { IMoStemMsa msa = m_caches.MainCache.ServiceLocator.GetInstance<IMoMorphSynAnalysisRepository>().GetObject( morphItem.m_hvoMsa) as IMoStemMsa; return msa != null && msa.PartOfSpeechRA == pos; } return pos == null; }
/// <summary> /// see if the MainPossibilities match for the given morphItem and /// the Word Part of Speech in the sandbox /// </summary> /// <param name="morphItem"></param> /// <returns></returns> private bool SbWordMainPosMatchesSenseMsaMainPos(IhMorphEntry.MorphItem morphItem) { int hvoWordPos = m_caches.RealHvo(m_sda.get_ObjectProp(m_hvoSbWord, ktagSbWordPos)); int hvoMainPosCandidate = 0; int hvoMainPosTarget = 0; // currently only support MoStemMsa, since that is what a WordPos expects to match against. IPartOfSpeech posCandidate = null; if (morphItem.m_hvoMsa != 0) { IMoStemMsa msa = CmObject.CreateFromDBObject(m_caches.MainCache, morphItem.m_hvoMsa) as IMoStemMsa; if (msa != null && msa.PartOfSpeechRA != null) { posCandidate = msa.PartOfSpeechRA; ICmPossibility mainPosCandidate = posCandidate.MainPossibility; if (mainPosCandidate != null) hvoMainPosCandidate = mainPosCandidate.Hvo; } } if (hvoWordPos != 0) { IPartOfSpeech targetPos = PartOfSpeech.CreateFromDBObject(m_caches.MainCache, hvoWordPos); if (targetPos != null) { ICmPossibility mainPosTarget = targetPos.MainPossibility; if (mainPosTarget != null) hvoMainPosTarget = mainPosTarget.Hvo; } } return hvoMainPosCandidate == hvoMainPosTarget; }
private bool SbWordPosMatchesSenseMsaPos(IhMorphEntry.MorphItem morphItem) { int hvoWordPos = m_caches.RealHvo(m_sda.get_ObjectProp(m_hvoSbWord, ktagSbWordPos)); // currently only support MoStemMsa, since that is what a WordPos expects to match against. if (morphItem.m_hvoMsa != 0) { IMoStemMsa msa = CmObject.CreateFromDBObject(m_caches.MainCache, morphItem.m_hvoMsa) as IMoStemMsa; return msa != null && msa.PartOfSpeechRAHvo == hvoWordPos; } return hvoWordPos == 0; }