/// ------------------------------------------------------------------------------------ /// <summary> /// Finds the ChkRefs in the new list that correspond to the given ChkRef in the old /// list. /// </summary> /// <param name="possibilty">A CmPossibility whose SubPossibilities are key terms /// in the new list.</param> /// <param name="chkRefOld">The old ChkRef.</param> /// <returns>A list of IChkRef containing the items corresponding to the given ChkRef /// </returns> /// ------------------------------------------------------------------------------------ public static List <IChkRef> FindCorrespondingChkRefs(ICmPossibility possibilty, IChkRef chkRefOld) { // TODO (TE-2901): This current implementation is specific to the translition from // the old-style list to the new one (see TE-6216). This needs to be carefully // enhanced to allow for conversion between different versions that use the new // approach (with IDs that should provide for easier correlation). List <IChkRef> list = new List <IChkRef>(); string sTargetWord = chkRefOld.KeyWord.Text.Normalize(NormalizationForm.FormC); foreach (IChkTerm term in possibilty.SubPossibilitiesOS) { foreach (IChkRef chkRef in term.OccurrencesOS) { string chkRefKeyWord = chkRef.KeyWord.Text.Normalize(NormalizationForm.FormC); if (chkRef.Ref == chkRefOld.Ref && Transliterate(chkRefKeyWord) == sTargetWord) { list.Add(chkRef); } } if (term.SubPossibilitiesOS.Count > 0) { list.AddRange(FindCorrespondingChkRefs(term, chkRefOld)); } } return(list); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:KeyTermRef"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public KeyTermRef(IChkRef chkRef) { m_chkRef = chkRef; if (chkRef != null) { m_cache = chkRef.Cache; m_scr = m_cache.LanguageProject.TranslatedScriptureOA; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a ChkRef object /// </summary> /// <param name="term">The ChkTerm that will own the ChkRef</param> /// <param name="hvoWs">The HVO of the original-language writing system.</param> /// <param name="keyword">The specific Greek or Hebrew word(s) in the original text, /// though not necessarily the surface (i.e., inflected) form.</param> /// <param name="reference">Scripture reference in BBCCCVVV format</param> /// <param name="location">The 1-based index of the word in the verse in the original /// language</param> /// ------------------------------------------------------------------------------------ private void CreateChkRef(IChkTerm term, int hvoWs, string keyword, int reference, int location) { IChkRef newRef = m_servLoc.GetInstance <IChkRefFactory>().Create(); term.OccurrencesOS.Add(newRef); newRef.Ref = reference; newRef.KeyWord = m_scr.Cache.TsStrFactory.MakeString(keyword, hvoWs); newRef.Location = location; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="XmlTermRendering"/> class based on /// the given term occurrence/rendering. /// </summary> /// <param name="termOccurence">Object representing a single occurrence of a biblical /// term that has a vernacular rendering or is explicitly unrendered.</param> /// ------------------------------------------------------------------------------------ public XmlTermRendering(IChkRef termOccurence) : this() { if (termOccurence.Status == KeyTermRenderingStatus.AutoAssigned || termOccurence.Status == KeyTermRenderingStatus.Unassigned) throw new ArgumentException("Only occurrences with explicit renderings or explicitly unrendered terms are permitted."); Location = termOccurence.Location; Reference = termOccurence.Ref; if (termOccurence.Status != KeyTermRenderingStatus.Ignored) VernRendering = termOccurence.RenderingRA.Form.VernacularDefaultWritingSystem.Text; }
private KeyTermRef CreateCheckRef(int scrRef) { IChkTerm chkTerm = Cache.ServiceLocator.GetInstance <IChkTermFactory>().Create(); Cache.LanguageProject.KeyTermsList.PossibilitiesOS.Add(chkTerm); IChkRef chkRef = Cache.ServiceLocator.GetInstance <IChkRefFactory>().Create(); chkTerm.OccurrencesOS.Add(chkRef); chkRef.Ref = scrRef; return(new KeyTermRef(chkRef)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="XmlTermRendering"/> class based on /// the given term occurrence/rendering. /// </summary> /// <param name="termOccurence">Object representing a single occurrence of a biblical /// term that has a vernacular rendering or is explicitly unrendered.</param> /// ------------------------------------------------------------------------------------ public XmlTermRendering(IChkRef termOccurence) : this() { if (termOccurence.Status == KeyTermRenderingStatus.AutoAssigned || termOccurence.Status == KeyTermRenderingStatus.Unassigned) { throw new ArgumentException("Only occurrences with explicit renderings or explicitly unrendered terms are permitted."); } Location = termOccurence.Location; Reference = termOccurence.Ref; if (termOccurence.Status != KeyTermRenderingStatus.Ignored) { VernRendering = termOccurence.RenderingRA.Form.VernacularDefaultWritingSystem.Text; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Writes this rendering to the specified cache. /// </summary> /// <param name="term">The term to which this rendering belongs.</param> /// <param name="ResolveConflict">The delegate to call to resolve a conflict when a /// different rendering already exists.</param> /// ------------------------------------------------------------------------------------ internal void WriteToCache(IChkTerm term, Func <IChkRef, string, string, bool> ResolveConflict) { IChkRef occ = term.OccurrencesOS.FirstOrDefault(o => o.Ref == Reference && o.Location == Location); if (occ == null) { MessageBox.Show(string.Format("Couldn't find occurrence {0} in {1} for imported rendering of term: {2}.", Location, (new BCVRef(Reference)), term.Name.AnalysisDefaultWritingSystem), "Unable to Import"); return; } if (string.IsNullOrEmpty(VernRendering)) { if (occ.Status != KeyTermRenderingStatus.Ignored) { occ.Status = KeyTermRenderingStatus.Ignored; occ.RenderingRA = null; } return; } string existingRendering = occ.RenderingRA == null ? null : occ.RenderingRA.Form.VernacularDefaultWritingSystem.Text; if (existingRendering == VernRendering) { return; // already set. Nothing to do. } if (!string.IsNullOrEmpty(existingRendering)) { if (!ResolveConflict(occ, existingRendering, VernRendering)) { return; // Leave existing rendering } } // See if the word form already exists IWfiWordform wordForm = WfiWordformServices.FindOrCreateWordform(term.Cache, VernRendering, term.Services.WritingSystems.DefaultVernacularWritingSystem); KeyTermRef ktRef = new KeyTermRef(occ); // Change the reference's status and attach the word form to the ChkRef ktRef.AssignRendering(wordForm); }
public ResolveKeyTermRenderingImportConflictDlg(IWin32Window owner, IChkRef occurrence, string existingRendering, string importedRendering, IVwStylesheet ss) : this() { FdoCache cache = occurrence.Cache; IScripture scr = cache.LangProject.TranslatedScriptureOA; ScrReference scrRef = (new ScrReference(occurrence.Ref, scr.Versification)); m_owner = owner; m_lblAnalysis.Text = occurrence.OwnerOfClass <IChkTerm>().Name.AnalysisDefaultWritingSystem.Text; m_lblOriginal.Text = occurrence.KeyWord.Text; m_lblScrReference.Text = scrRef.ToString(); m_btnExisting.Text = String.Format(m_btnExisting.Text, existingRendering); m_btnImported.Text = String.Format(m_btnImported.Text, importedRendering); // We do this outside the designer-controlled code because it does funny things // to FwMultiParaTextBox, owing to the need for a writing system factory, and some // properties it should not persist but I can't persuade it not to. // IStText text = new NonEditableMultiTss(TeEditingHelper.GetVerseText(cache.LangProject.TranslatedScriptureOA, scrRef).ToString(true, " ")); //m_verseTextLabel = new FwMultiParaTextBox(text, ss); m_verseTextLabel = new FwLabel(); m_verseTextLabel.WritingSystemFactory = cache.WritingSystemFactory; // set ASAP. m_verseTextLabel.WritingSystemCode = cache.DefaultVernWs; m_verseTextLabel.StyleSheet = ss; // before setting text, otherwise it gets confused about height needed. m_verseTextLabel.Location = new Point(0, 0); m_verseTextLabel.Name = "m_textBox"; m_verseTextLabel.Dock = DockStyle.Fill; m_verseTextLabel.TabIndex = 0; m_verseTextLabel.TextAlign = ContentAlignment.TopLeft; //m_verseTextLabel.BorderStyle = BorderStyle.None; //m_textBox.SuppressEnter = true; m_pnlActualVerseText.Controls.Add(m_verseTextLabel); // ENHANCE: Figure out how to get each part (paragraph) of the verse onm its own line. Using newlines or hard line breaks doesn't work. ITsIncStrBldr bldr = TsIncStrBldrClass.Create(); foreach (TeEditingHelper.VerseTextSubstring verseTextSubstring in TeEditingHelper.GetVerseText(cache.LangProject.TranslatedScriptureOA, scrRef)) { bldr.AppendTsString(verseTextSubstring.Tss); bldr.Append(StringUtils.kChHardLB.ToString()); } m_verseTextLabel.Tss = bldr.GetString(); //m_verseTextLabel.Tss = TeEditingHelper.GetVerseText(cache.LangProject.TranslatedScriptureOA, scrRef).ToString(true, StringUtils.kChHardLB.ToString()); }
public ResolveKeyTermRenderingImportConflictDlg(IWin32Window owner, IChkRef occurrence, string existingRendering, string importedRendering, IVwStylesheet ss) : this() { FdoCache cache = occurrence.Cache; IScripture scr = cache.LangProject.TranslatedScriptureOA; ScrReference scrRef = (new ScrReference(occurrence.Ref, scr.Versification)); m_owner = owner; m_lblAnalysis.Text = occurrence.OwnerOfClass<IChkTerm>().Name.AnalysisDefaultWritingSystem.Text; m_lblOriginal.Text = occurrence.KeyWord.Text; m_lblScrReference.Text = scrRef.ToString(); m_btnExisting.Text = String.Format(m_btnExisting.Text, existingRendering); m_btnImported.Text = String.Format(m_btnImported.Text, importedRendering); // We do this outside the designer-controlled code because it does funny things // to FwMultiParaTextBox, owing to the need for a writing system factory, and some // properties it should not persist but I can't persuade it not to. // IStText text = new NonEditableMultiTss(TeEditingHelper.GetVerseText(cache.LangProject.TranslatedScriptureOA, scrRef).ToString(true, " ")); //m_verseTextLabel = new FwMultiParaTextBox(text, ss); m_verseTextLabel = new FwLabel(); m_verseTextLabel.WritingSystemFactory = cache.WritingSystemFactory; // set ASAP. m_verseTextLabel.WritingSystemCode = cache.DefaultVernWs; m_verseTextLabel.StyleSheet = ss; // before setting text, otherwise it gets confused about height needed. m_verseTextLabel.Location = new Point(0, 0); m_verseTextLabel.Name = "m_textBox"; m_verseTextLabel.Dock = DockStyle.Fill; m_verseTextLabel.TabIndex = 0; m_verseTextLabel.TextAlign = ContentAlignment.TopLeft; //m_verseTextLabel.BorderStyle = BorderStyle.None; //m_textBox.SuppressEnter = true; m_pnlActualVerseText.Controls.Add(m_verseTextLabel); // ENHANCE: Figure out how to get each part (paragraph) of the verse onm its own line. Using newlines or hard line breaks doesn't work. ITsIncStrBldr bldr = TsIncStrBldrClass.Create(); foreach (TeEditingHelper.VerseTextSubstring verseTextSubstring in TeEditingHelper.GetVerseText(cache.LangProject.TranslatedScriptureOA, scrRef)) { bldr.AppendTsString(verseTextSubstring.Tss); bldr.Append(StringUtils.kChHardLB.ToString()); } m_verseTextLabel.Tss = bldr.GetString(); //m_verseTextLabel.Tss = TeEditingHelper.GetVerseText(cache.LangProject.TranslatedScriptureOA, scrRef).ToString(true, StringUtils.kChHardLB.ToString()); }
private static void CheckRenderingAndStatus(string expectedRendering, KeyTermRenderingStatus expectedStatus, IChkRef chkRef) { IWfiWordform wordform = chkRef.RenderingRA; if (expectedRendering == null) Assert.AreEqual(null, wordform); else { Assert.IsNotNull(wordform); Assert.AreEqual(expectedRendering, wordform.Form.VernacularDefaultWritingSystem); } Assert.AreEqual(expectedStatus, chkRef.Status); }
public void FindCorrespondingChkRef() { // First, create a possibility list with the old key terms and set some ChkRefs to // have renderings. IWfiWordform abc = Cache.ServiceLocator.GetInstance <IWfiWordformFactory>().Create(); abc.Form.SetVernacularDefaultWritingSystem("abc"); IWfiWordform def = Cache.ServiceLocator.GetInstance <IWfiWordformFactory>().Create(); abc.Form.SetVernacularDefaultWritingSystem("def"); IWfiWordform ghi = Cache.ServiceLocator.GetInstance <IWfiWordformFactory>().Create(); abc.Form.SetVernacularDefaultWritingSystem("ghi"); IWfiWordform jkl = Cache.ServiceLocator.GetInstance <IWfiWordformFactory>().Create(); abc.Form.SetVernacularDefaultWritingSystem("jkl"); IWfiWordform mno = Cache.ServiceLocator.GetInstance <IWfiWordformFactory>().Create(); abc.Form.SetVernacularDefaultWritingSystem("mno"); ICmPossibilityList oldKeyTermsList = Cache.ServiceLocator.GetInstance <ICmPossibilityListFactory>().Create(); m_lp.CheckListsOC.Add(oldKeyTermsList); IChkTerm term = Cache.ServiceLocator.GetInstance <IChkTermFactory>().Create(); oldKeyTermsList.PossibilitiesOS.Add(term); term.Name.set_String(m_wsEn, "Adultery"); IChkTerm subsense = Cache.ServiceLocator.GetInstance <IChkTermFactory>().Create(); term.SubPossibilitiesOS.Add(subsense); subsense.Name.set_String(m_wsEn, "The act of sexual unfaithfulness"); IChkRef chkrefMoicheuw040005027 = AddOccurrenceToOldStyleSense(subsense, 040005027, abc, "moicheuw"); IChkRef chkrefMoicheuw040005028 = AddOccurrenceToOldStyleSense(subsense, 040005028, abc, "moicheuw"); IChkRef chkrefMoichaomai040005032 = AddOccurrenceToOldStyleSense(subsense, 040005032, def, "moichaomai"); IChkRef chkrefMoicheia040015019 = AddOccurrenceToOldStyleSense(subsense, 040015019, ghi, "moicheia"); IChkRef chkrefMoichaomai040019009 = AddOccurrenceToOldStyleSense(subsense, 040019009, def, "moichaomai"); subsense = Cache.ServiceLocator.GetInstance <IChkTermFactory>().Create(); term.SubPossibilitiesOS.Add(subsense); subsense.Name.set_String(m_wsEn, "One who sexually violates marriage vows"); IChkTerm subsubsense = Cache.ServiceLocator.GetInstance <IChkTermFactory>().Create(); subsense.SubPossibilitiesOS.Add(subsubsense); subsubsense.Name.set_String(m_wsEn, "Masculine offenders"); IChkRef chkrefMoichos042018011 = AddOccurrenceToOldStyleSense(subsubsense, 042018011, jkl, "moichos"); IChkRef chkrefMoichos046006009 = AddOccurrenceToOldStyleSense(subsubsense, 046006009, jkl, "moichos"); IChkRef chkrefMoichos058013004 = AddOccurrenceToOldStyleSense(subsubsense, 058013004, jkl, "moichos"); subsubsense = Cache.ServiceLocator.GetInstance <IChkTermFactory>().Create(); subsense.SubPossibilitiesOS.Add(subsubsense); subsubsense.Name.set_String(m_wsEn, "Feminine offenders"); IChkRef chkrefMoichalis045007003 = AddOccurrenceToOldStyleSense(subsubsense, 045007003, mno, "moichalis"); IChkRef chkrefMoichalis061002014 = AddOccurrenceToOldStyleSense(subsubsense, 061002014, mno, "moichalis"); // Next, load the new list of Biblicalk terms BiblicalTermsList terms = new BiblicalTermsList(); terms.Version = Guid.NewGuid(); terms.KeyTerms = new List <Term>(); terms.KeyTerms.Add(new Term(3, "KT", "\u03b1\u03b2\u03b2\u03b1", "Greek", "abba; father", null, null, 4101403603, 4500801516, 4800400618)); string sGrkMoichaomai = "\u03BC\u03BF\u03B9\u03C7\u1F71\u03BF\u03BC\u03B1\u03B9"; terms.KeyTerms.Add(new Term(1139, "KT", "\u03BC\u03BF\u03B9\u03C7\u1F71\u03BF\u03BC\u03B1\u03B9-1", "Greek", "commit adultery", sGrkMoichaomai, "\u03BC\u03BF\u03B9\u03C7\u03B5\u1F77\u03B1, \u03BC\u03BF\u03B9\u03C7\u03B5\u1F7B\u03C9, \u03BC\u03BF\u03B9\u03C7\u03B1\u03BB\u1F77\u03C2, \u03BC\u03BF\u03B9\u03C7\u1F79\u03C2", 04000503223, 04001900917, 04101001123, 04101001210)); string sGrkMoicheia = "\u03BC\u03BF\u03B9\u03C7\u03B5\u1F77\u03B1"; terms.KeyTerms.Add(new Term(1140, "KT", "\u03BC\u03BF\u03B9\u03C7\u1F71\u03BF\u03BC\u03B1\u03B9-2", "Greek", "adultery", sGrkMoicheia, "\u03BC\u03BF\u03B9\u03C7\u03B5\u1F77\u03B1, \u03BC\u03BF\u03B9\u03C7\u03B5\u1F7B\u03C9, \u03BC\u03BF\u03B9\u03C7\u03B1\u03BB\u1F77\u03C2, \u03BC\u03BF\u03B9\u03C7\u1F79\u03C2", 04001501909, 04300800310)); string sGrkMoicheuw = "\u03BC\u03BF\u03B9\u03C7\u03B5\u1F7B\u03C9"; terms.KeyTerms.Add(new Term(1141, "KT", "\u03BC\u03BF\u03B9\u03C7\u1F71\u03BF\u03BC\u03B1\u03B9-3", "Greek", "commit adultery", sGrkMoicheuw, "\u03BC\u03BF\u03B9\u03C7\u03B5\u1F77\u03B1, \u03BC\u03BF\u03B9\u03C7\u03B5\u1F7B\u03C9, \u03BC\u03BF\u03B9\u03C7\u03B1\u03BB\u1F77\u03C2, \u03BC\u03BF\u03B9\u03C7\u1F79\u03C2", 04000502705, 04000502708, 04000502815, 04001901812, 04101001907, 04201601810, 04201601817, 04201802005, 04300800410, 04500202204, 04500202205, 04501300904, 05900201105, 05900201113, 06600202208)); string sGrkMoichalis = "\u03BC\u03BF\u03B9\u03C7\u03B1\u03BB\u1F77\u03C2"; terms.KeyTerms.Add(new Term(1142, "KT", "\u03BC\u03BF\u03B9\u03C7\u1F71\u03BF\u03BC\u03B1\u03B9-4", "Greek", "adulterous; adulteress", sGrkMoichalis, "\u03BC\u03BF\u03B9\u03C7\u03B5\u1F77\u03B1, \u03BC\u03BF\u03B9\u03C7\u03B5\u1F7B\u03C9, \u03BC\u03BF\u03B9\u03C7\u03B1\u03BB\u1F77\u03C2, \u03BC\u03BF\u03B9\u03C7\u1F79\u03C2", 04001203909, 04001600404, 04100803815, 04500700306, 04500700326, 05900400401, 06100201404)); string sGrkMoichos = "\u03BC\u03BF\u03B9\u03C7\u1F79\u03C2"; terms.KeyTerms.Add(new Term(1143, "KT", "\u03BC\u03BF\u03B9\u03C7\u1F71\u03BF\u03BC\u03B1\u03B9-5", "Greek", "adulterer", sGrkMoichos, "\u03BC\u03BF\u03B9\u03C7\u03B5\u1F77\u03B1, \u03BC\u03BF\u03B9\u03C7\u03B5\u1F7B\u03C9, \u03BC\u03BF\u03B9\u03C7\u03B1\u03BB\u1F77\u03C2, \u03BC\u03BF\u03B9\u03C7\u1F79\u03C2", 04201801122, 04600600917)); List <BiblicalTermsLocalization> localizations = new List <BiblicalTermsLocalization>(1); ICmPossibilityList newBiblicalTermsList = Cache.ServiceLocator.GetInstance <ICmPossibilityListFactory>().Create(); m_lp.CheckListsOC.Add(newBiblicalTermsList); DummyTeKeyTermsInit.CallLoadKeyTerms(newBiblicalTermsList, terms, localizations); ICmPossibility newKtList = null; foreach (ICmPossibility category in newBiblicalTermsList.PossibilitiesOS) { if (category.Abbreviation.get_String(m_wsEn).Text == "KT") { newKtList = category; } } Assert.IsNotNull(newKtList); // Now check to make sure FindCorrespondingChkRefs works List <IChkRef> chkRefs = ChkRefMatcher.FindCorrespondingChkRefs(newKtList, chkrefMoichalis045007003); Assert.AreEqual(2, chkRefs.Count); Assert.AreEqual(sGrkMoichalis.Normalize(NormalizationForm.FormD), chkRefs[0].KeyWord.Text); Assert.AreEqual(045007003, chkRefs[0].Ref); Assert.AreEqual(6, chkRefs[0].Location); Assert.AreEqual(sGrkMoichalis.Normalize(NormalizationForm.FormD), chkRefs[1].KeyWord.Text); Assert.AreEqual(045007003, chkRefs[1].Ref); Assert.AreEqual(26, chkRefs[1].Location); chkRefs = ChkRefMatcher.FindCorrespondingChkRefs(newKtList, chkrefMoichalis061002014); Assert.AreEqual(1, chkRefs.Count); Assert.AreEqual(sGrkMoichalis.Normalize(NormalizationForm.FormD), chkRefs[0].KeyWord.Text); Assert.AreEqual(061002014, chkRefs[0].Ref); Assert.AreEqual(4, chkRefs[0].Location); chkRefs = ChkRefMatcher.FindCorrespondingChkRefs(newKtList, chkrefMoichaomai040005032); Assert.AreEqual(1, chkRefs.Count); Assert.AreEqual(sGrkMoichaomai.Normalize(NormalizationForm.FormD), chkRefs[0].KeyWord.Text); Assert.AreEqual(040005032, chkRefs[0].Ref); Assert.AreEqual(23, chkRefs[0].Location); chkRefs = ChkRefMatcher.FindCorrespondingChkRefs(newKtList, chkrefMoichaomai040019009); Assert.AreEqual(1, chkRefs.Count); Assert.AreEqual(sGrkMoichaomai.Normalize(NormalizationForm.FormD), chkRefs[0].KeyWord.Text); Assert.AreEqual(040019009, chkRefs[0].Ref); Assert.AreEqual(17, chkRefs[0].Location); chkRefs = ChkRefMatcher.FindCorrespondingChkRefs(newKtList, chkrefMoicheia040015019); Assert.AreEqual(1, chkRefs.Count); Assert.AreEqual(sGrkMoicheia.Normalize(NormalizationForm.FormD), chkRefs[0].KeyWord.Text); Assert.AreEqual(040015019, chkRefs[0].Ref); Assert.AreEqual(9, chkRefs[0].Location); chkRefs = ChkRefMatcher.FindCorrespondingChkRefs(newKtList, chkrefMoicheuw040005027); Assert.AreEqual(2, chkRefs.Count); Assert.AreEqual(sGrkMoicheuw.Normalize(NormalizationForm.FormD), chkRefs[0].KeyWord.Text); Assert.AreEqual(040005027, chkRefs[0].Ref); Assert.AreEqual(5, chkRefs[0].Location); Assert.AreEqual(sGrkMoicheuw.Normalize(NormalizationForm.FormD), chkRefs[1].KeyWord.Text); Assert.AreEqual(040005027, chkRefs[1].Ref); Assert.AreEqual(8, chkRefs[1].Location); chkRefs = ChkRefMatcher.FindCorrespondingChkRefs(newKtList, chkrefMoicheuw040005028); Assert.AreEqual(1, chkRefs.Count); Assert.AreEqual(sGrkMoicheuw.Normalize(NormalizationForm.FormD), chkRefs[0].KeyWord.Text); Assert.AreEqual(040005028, chkRefs[0].Ref); Assert.AreEqual(15, chkRefs[0].Location); chkRefs = ChkRefMatcher.FindCorrespondingChkRefs(newKtList, chkrefMoichos042018011); Assert.AreEqual(1, chkRefs.Count); Assert.AreEqual(sGrkMoichos.Normalize(NormalizationForm.FormD), chkRefs[0].KeyWord.Text); Assert.AreEqual(042018011, chkRefs[0].Ref); Assert.AreEqual(22, chkRefs[0].Location); chkRefs = ChkRefMatcher.FindCorrespondingChkRefs(newKtList, chkrefMoichos046006009); Assert.AreEqual(1, chkRefs.Count); Assert.AreEqual(sGrkMoichos.Normalize(NormalizationForm.FormD), chkRefs[0].KeyWord.Text); Assert.AreEqual(046006009, chkRefs[0].Ref); Assert.AreEqual(17, chkRefs[0].Location); chkRefs = ChkRefMatcher.FindCorrespondingChkRefs(newKtList, chkrefMoichos058013004); Assert.AreEqual(0, chkRefs.Count, "We removed this reference from the new list to test the case where no match is found"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Finds the ChkRefs in the new list that correspond to the given ChkRef in the old /// list. /// </summary> /// <param name="possibilty">A CmPossibility whose SubPossibilities are key terms /// in the new list.</param> /// <param name="chkRefOld">The old ChkRef.</param> /// <returns>A list of IChkRef containing the items corresponding to the given ChkRef /// </returns> /// ------------------------------------------------------------------------------------ public static List<IChkRef> FindCorrespondingChkRefs(ICmPossibility possibilty, IChkRef chkRefOld) { // TODO (TE-2901): This current implementation is specific to the translition from // the old-style list to the new one (see TE-6216). This needs to be carefully // enhanced to allow for conversion between different versions that use the new // approach (with IDs that should provide for easier correlation). List<IChkRef> list = new List<IChkRef>(); string sTargetWord = chkRefOld.KeyWord.Text.Normalize(NormalizationForm.FormC); foreach (IChkTerm term in possibilty.SubPossibilitiesOS) { foreach (IChkRef chkRef in term.OccurrencesOS) { string chkRefKeyWord = chkRef.KeyWord.Text.Normalize(NormalizationForm.FormC); if (chkRef.Ref == chkRefOld.Ref && Transliterate(chkRefKeyWord) == sTargetWord) { list.Add(chkRef); } } if (term.SubPossibilitiesOS.Count > 0) { list.AddRange(FindCorrespondingChkRefs(term, chkRefOld)); } } return list; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Check all of the sibling references for a key term to see if any of the verses /// have the same word form that was assigned. If they do, then the status will /// be set to auto-assigned. /// </summary> /// <param name="assignedRef">ChkRef that was explicitly assigned</param> /// <param name="wordForm">word for that was assigned to the ChkRef item</param> /// ------------------------------------------------------------------------------------ private void AutoAssignVernacularEquivalents(IChkRef assignedRef, IWfiWordform wordForm) { int iDummy; ChkTerm parent = new ChkTerm(m_cache, assignedRef.OwnerHVO); foreach (KeyTermRef autoAssignRef in parent.OccurrencesOS) { if (autoAssignRef.RenderingStatus != KeyTermRenderingStatus.Unassigned) continue; if (TeEditingHelper.FindTextInVerse(m_scr, wordForm.Form.GetAlternativeTss(wordForm.Cache.DefaultVernWs), autoAssignRef.RefInCurrVersification, true, out iDummy, out iDummy, out iDummy, out iDummy)) { // TODO: update the local view constructor cache autoAssignRef.RenderingStatus = KeyTermRenderingStatus.AutoAssigned; autoAssignRef.RenderingRA = wordForm; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Check all of the sibling references for a key term to see if any of the verses /// have the same word form that was assigned. If they do, then the status will /// be set to auto-assigned. /// </summary> /// <param name="assignedRef">ChkRef that was explicitly assigned</param> /// <param name="wordForm">word for that was assigned to the ChkRef item</param> /// ------------------------------------------------------------------------------------ private void AutoAssignVernacularEquivalents(IChkRef assignedRef, IWfiWordform wordForm) { int iDummy; IChkTerm parent = (IChkTerm)assignedRef.Owner; foreach (IChkRef autoAssignRef in parent.OccurrencesOS) { KeyTermRef ktRef = new KeyTermRef(autoAssignRef); if (ktRef.RenderingStatus != KeyTermRenderingStatus.Unassigned) continue; if (TeEditingHelper.FindTextInVerse(m_scr, wordForm.Form.get_String(wordForm.Cache.DefaultVernWs), ktRef.RefInCurrVersification, true, out iDummy, out iDummy, out iDummy, out iDummy)) { // TODO: update the local view constructor cache ktRef.RenderingStatus = KeyTermRenderingStatus.AutoAssigned; ktRef.ChkRef.RenderingRA = wordForm; } } }