Example #1
0
		private void AddFreeTranslations(List<int> segsMissingFreeTrans)
		{
			// since this is not connected to a user action, we don't want this to be undoable.
			BaseFreeformAdder bffa = new BaseFreeformAdder(Cache);
			using (new SuppressSubTasks(Cache, true))
			{
				foreach (int hvoSeg in segsMissingFreeTrans)
				{
					bffa.AddFreeformAnnotation(hvoSeg, m_vc.FtSegmentDefn);
				}
			}
		}
			/// <summary>
			/// </summary>
			/// <param name="iSegment"></param>
			/// <param name="guidFreeformAnnotation"></param>
			/// <param name="comment"></param>
			/// <returns></returns>
			internal virtual int SetDefaultFreeformAnnotation(int iSegment, string guidFreeformAnnotation,
				out ITsString tssComment)
			{
				int segDefn = m_cache.GetIdFromGuid(guidFreeformAnnotation);
				BaseFreeformAdder ffAdder = new BaseFreeformAdder(m_cache);
				// add the indirect annotation
				int hvoSegmentActual = GetSegment(iSegment);
				ITsString tssSegment = GetBaselineText(hvoSegmentActual);
				ICmIndirectAnnotation indirectAnn = ffAdder.AddFreeformAnnotation(hvoSegmentActual, segDefn);
				string comment = String.Format("{0}.Type({1}).{2}", iSegment, segDefn, tssSegment.Text);
				indirectAnn.Comment.SetAlternative(comment, m_cache.DefaultAnalWs);
				tssComment = indirectAnn.Comment.AnalysisDefaultWritingSystem.UnderlyingTsString;
				return indirectAnn.Hvo;
			}
		public void SparseSegmentAnalyses_FreeformAnnotations_LT7318()
		{
			// Make some analyses linked to the same LexSense.
			//<!--xxxpus xxxyalola xxxnihimbilira. xxxnihimbilira xxxpus xxxyalola. xxxhesyla xxxnihimbilira.-->
			ParagraphBuilder pb = new ParagraphBuilder(m_textsDefn, m_text1, (int)Text1ParaIndex.SimpleSegmentPara);
			List<int> segments = (pb.ActualParagraph as StTxtPara).Segments;
			Assert.AreEqual(3, segments.Count, "Unexpected number of senses.");

			// Verify that each of these segments are dummy
			Assert.IsTrue(Cache.IsDummyObject(segments[0]), "Expected dummy segment.");
			Assert.IsTrue(Cache.IsDummyObject(segments[1]), "Expected dummy segment.");
			Assert.IsTrue(Cache.IsDummyObject(segments[2]), "Expected dummy segment.");

			// Load free form annotations for segments. shouldn't have any.
			Set<int> analWsIds = new Set<int>(Cache.LangProject.AnalysisWssRC.HvoArray);
			StTxtPara.LoadSegmentFreeformAnnotationData(Cache, new Set<int>(segments), analWsIds);
			int tagSegFF = StTxtPara.SegmentFreeformAnnotationsFlid(Cache);
			int[] segFFs = Cache.GetVectorProperty(segments[0], tagSegFF, true);
			Assert.AreEqual(0, segFFs.Length, "Segment 0 should not have any freeform annotations.");
			StTxtPara.LoadSegmentFreeformAnnotationData(Cache, pb.ActualParagraph.Hvo, analWsIds);
			segFFs = Cache.GetVectorProperty(segments[1], tagSegFF, true);
			Assert.AreEqual(0, segFFs.Length, "Segment 1 should not have any freeform annotations.");
			segFFs = Cache.GetVectorProperty(segments[2], tagSegFF, true);
			Assert.AreEqual(0, segFFs.Length, "Segment 2 should not have any freeform annotations.");

			// convert the third segment to a real, in preparation for adding the annotation.
			ICmBaseAnnotation cbaReal = CmBaseAnnotation.ConvertBaseAnnotationToReal(m_fdoCache, segments[2]);
			segments = (pb.ActualParagraph as StTxtPara).Segments;
			Assert.IsTrue(!Cache.IsDummyObject(segments[2]), "Expected real segment.");

			// Try adding some freeform translations to third segment.
			int segDefn_literalTranslation = Cache.GetIdFromGuid(LangProject.kguidAnnLiteralTranslation);
			int segDefn_freeTranslation = Cache.GetIdFromGuid(LangProject.kguidAnnFreeTranslation);
			BaseFreeformAdder ffAdder = new BaseFreeformAdder(Cache);
			ICmIndirectAnnotation freeTrans0 = ffAdder.AddFreeformAnnotation(segments[2], segDefn_freeTranslation);
			freeTrans0.Comment.SetAlternative("Segment2: Freeform translation.", Cache.DefaultAnalWs);
			ICmIndirectAnnotation literalTrans0 = ffAdder.AddFreeformAnnotation(segments[2], segDefn_literalTranslation);
			literalTrans0.Comment.SetAlternative("Segment2: Literal translation.", Cache.DefaultAnalWs);

			// see if we can load this into the cache.
			StTxtPara.LoadSegmentFreeformAnnotationData(Cache, new Set<int>(segments), analWsIds);
			segFFs = Cache.GetVectorProperty(segments[2], tagSegFF, true);
			Assert.AreEqual(2, segFFs.Length, "Segment 2 should have freeform annotations.");
			Assert.AreEqual(segFFs[0], freeTrans0.Hvo, "Segment 2 Freeform translation id.");
			Assert.AreEqual(segFFs[1], literalTrans0.Hvo, "Segment 2 Literal translation id.");
			// make sure the other segments don't have freeform annotations.
			segFFs = Cache.GetVectorProperty(segments[0], tagSegFF, true);
			Assert.AreEqual(0, segFFs.Length, "Segment 0 should not have any freeform annotations.");
			StTxtPara.LoadSegmentFreeformAnnotationData(Cache, pb.ActualParagraph.Hvo, analWsIds);
			segFFs = Cache.GetVectorProperty(segments[1], tagSegFF, true);
			Assert.AreEqual(0, segFFs.Length, "Segment 1 should not have any freeform annotations.");

			// reparse the paragraph and make sure nothing changed.
			ParagraphAnnotatorForParagraphBuilder tapb = new ParagraphAnnotatorForParagraphBuilder(pb);
			tapb.ReparseParagraph();
			segments = (pb.ActualParagraph as StTxtPara).Segments;

			StTxtPara.LoadSegmentFreeformAnnotationData(Cache, new Set<int>(segments), analWsIds);
			segFFs = Cache.GetVectorProperty(segments[2], tagSegFF, true);
			Assert.AreEqual(2, segFFs.Length, "Segment 2 should have freeform annotations.");
			Assert.AreEqual(segFFs[0], freeTrans0.Hvo, "Segment 2 Freeform translation id.");
			Assert.AreEqual(segFFs[1], literalTrans0.Hvo, "Segment 2 Literal translation id.");
			// make sure the other segments don't have freeform annotations.
			segFFs = Cache.GetVectorProperty(segments[0], tagSegFF, true);
			Assert.AreEqual(0, segFFs.Length, "Segment 0 should not have any freeform annotations.");
			StTxtPara.LoadSegmentFreeformAnnotationData(Cache, pb.ActualParagraph.Hvo, analWsIds);
			segFFs = Cache.GetVectorProperty(segments[1], tagSegFF, true);
			Assert.AreEqual(0, segFFs.Length, "Segment 1 should not have any freeform annotations.");
		}
		public void FindExampleSentences()
		{
			// Make some analyses linked to the same LexSense.
			ParagraphBuilder pb = new ParagraphBuilder(m_textsDefn, m_text1, (int)Text1ParaIndex.SimpleSegmentPara);
			ParagraphAnnotatorForParagraphBuilder tapb = new ParagraphAnnotatorForParagraphBuilder(pb);
			// Create a new lexical entry and sense.
			int clsidForm;
			string formLexEntry = "xnihimbilira";
			ITsString tssLexEntryForm = StringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs);
			ILexEntry xnihimbilira_Entry = LexEntry.CreateEntry(Cache,
				MoMorphType.FindMorphType(Cache, new MoMorphTypeCollection(Cache), ref formLexEntry, out clsidForm), tssLexEntryForm,
				"xnihimbilira.sense1", null);

			ILexSense xnihimbilira_Sense1 = xnihimbilira_Entry.SensesOS[0];
			ILexSense xnihimbilira_Sense2 = LexSense.CreateSense(xnihimbilira_Entry, null, "xnihimbilira.sense2");
			//<!--xxxpus xxxyalola xxxnihimbilira. xxxnihimbilira xxxpus xxxyalola. xxxhesyla xxxnihimbilira.-->
			ArrayList moForms = new ArrayList();
			moForms.Add("xx");
			moForms.Add(xnihimbilira_Entry.LexemeFormOA);
			// 1. Establish first analysis with Sense1
			IWfiAnalysis wfiAnalysis1 = tapb.BreakIntoMorphs(1, 0, moForms);
			tapb.SetMorphSense(1, 0, 1, xnihimbilira_Sense1);
			List<int> instancesInTwfics_Sense1 = (xnihimbilira_Sense1 as LexSense).InstancesInTwfics;
			List<int> instancesInTwfics_Sense2 = (xnihimbilira_Sense2 as LexSense).InstancesInTwfics;
			Assert.AreEqual(1, instancesInTwfics_Sense1.Count,
				String.Format("Unexpected number of instances of sense '{0}'", xnihimbilira_Sense1.Gloss.AnalysisDefaultWritingSystem));
			Assert.AreEqual(0, instancesInTwfics_Sense2.Count,
				String.Format("Unexpected number of instances of sense '{0}'", xnihimbilira_Sense2.Gloss.AnalysisDefaultWritingSystem));
			StTxtPara.TwficInfo infoCba1_0 = new StTxtPara.TwficInfo(Cache, instancesInTwfics_Sense1[0]);
			Assert.AreEqual(pb.ActualParagraph.Hvo, infoCba1_0.Object.BeginObjectRAHvo);
			Assert.AreEqual(1, infoCba1_0.SegmentIndex,
				String.Format("Unexpected index of segment '{0}'", infoCba1_0.SegmentHvo));

			WfiAnalysis waCba1_0 = infoCba1_0.Object.InstanceOfRA as WfiAnalysis;
			Assert.IsNotNull(waCba1_0,
				String.Format("Unexpected class({0}) of InstanceOf({1}) for cba0.", infoCba1_0.Object.InstanceOfRA.ClassID, infoCba1_0.Object.InstanceOfRAHvo));
			Assert.AreEqual(xnihimbilira_Sense1.Hvo, waCba1_0.MorphBundlesOS[1].SenseRAHvo);

			// get the segment information for the twfics.
			List<int> segments_Sense1 = StTxtPara.TwficSegments(Cache, instancesInTwfics_Sense1);
			Assert.AreEqual(1, segments_Sense1.Count, "Unexpected number of senses for twfics.");
			Assert.AreEqual(infoCba1_0.SegmentHvo, segments_Sense1[0], "Unexpected segment hvo.");

			// 2. Establish word gloss on the existing analysis.
			string wordGloss1;
			tapb.SetDefaultWordGloss(2, 1, wfiAnalysis1, out wordGloss1);
			instancesInTwfics_Sense1 = (xnihimbilira_Sense1 as LexSense).InstancesInTwfics;
			Assert.AreEqual(2, instancesInTwfics_Sense1.Count,
				String.Format("Unexpected number of instances of sense '{0}'", xnihimbilira_Sense1.Gloss.AnalysisDefaultWritingSystem));

			infoCba1_0 = new StTxtPara.TwficInfo(Cache, instancesInTwfics_Sense1[0]);
			Assert.AreEqual(pb.ActualParagraph.Hvo, infoCba1_0.Object.BeginObjectRAHvo);
			Assert.AreEqual(1, infoCba1_0.SegmentIndex,
				String.Format("Unexpected index of segment '{0}'", infoCba1_0.SegmentHvo));

			StTxtPara.TwficInfo infoCba2_1 = new StTxtPara.TwficInfo(Cache, instancesInTwfics_Sense1[1]);
			Assert.AreEqual(pb.ActualParagraph.Hvo, infoCba2_1.Object.BeginObjectRAHvo);
			Assert.AreEqual(2, infoCba2_1.SegmentIndex,
				String.Format("Unexpected index of segment '{0}'", infoCba2_1.SegmentHvo));

			waCba1_0 = infoCba1_0.Object.InstanceOfRA as WfiAnalysis;
			Assert.IsNotNull(waCba1_0,
				String.Format("Unexpected class({0}) of InstanceOf({1}) for cba0.", infoCba1_0.Object.InstanceOfRA.ClassID, infoCba1_0.Object.InstanceOfRAHvo));
			Assert.AreEqual(xnihimbilira_Sense1.Hvo, waCba1_0.MorphBundlesOS[1].SenseRAHvo);

			WfiGloss wgCba2_1 = infoCba2_1.Object.InstanceOfRA as WfiGloss;
			Assert.IsNotNull(wgCba2_1,
				String.Format("Unexpected class({0}) of InstanceOf({1}) for cba1.", infoCba2_1.Object.InstanceOfRA.ClassID, infoCba2_1.Object.InstanceOfRAHvo));
			WfiAnalysis waCba2_1 = WfiAnalysis.CreateFromDBObject(Cache, wgCba2_1.OwnerHVO) as WfiAnalysis;
			Assert.AreEqual(xnihimbilira_Sense1.Hvo, waCba2_1.MorphBundlesOS[1].SenseRAHvo);

			segments_Sense1 = StTxtPara.TwficSegments(Cache, instancesInTwfics_Sense1);
			Assert.AreEqual(2, segments_Sense1.Count, "Unexpected number of senses for twfics.");
			Assert.AreEqual(infoCba1_0.SegmentHvo, segments_Sense1[0], "Unexpected segment hvo.");
			Assert.AreEqual(infoCba2_1.SegmentHvo, segments_Sense1[1], "Unexpected segment hvo.");

			// 3. establish a new analysis with Sense1.
			IWfiAnalysis wfiAnalysis2 = tapb.BreakIntoMorphs(0, 2, moForms); // xxxnihimbilira (first occurrence)
			tapb.SetMorphSense(0, 2, 1, xnihimbilira_Sense1);
			instancesInTwfics_Sense1 = (xnihimbilira_Sense1 as LexSense).InstancesInTwfics;
			Assert.AreEqual(3, instancesInTwfics_Sense1.Count,
				String.Format("Unexpected number of instances of sense '{0}'", xnihimbilira_Sense1.Gloss.AnalysisDefaultWritingSystem));

			StTxtPara.TwficInfo infoCba0_2 = new StTxtPara.TwficInfo(Cache, instancesInTwfics_Sense1[0]);
			Assert.AreEqual(pb.ActualParagraph.Hvo, infoCba0_2.Object.BeginObjectRAHvo);
			Assert.AreEqual(0, infoCba0_2.SegmentIndex,
				String.Format("Unexpected index of segment '{0}'", infoCba0_2.SegmentHvo));

			WfiAnalysis waCba0_2 = infoCba0_2.Object.InstanceOfRA as WfiAnalysis;
			Assert.IsNotNull(waCba0_2,
				String.Format("Unexpected class({0}) of InstanceOf({1}) for cba0.", infoCba0_2.Object.InstanceOfRA.ClassID, infoCba0_2.Object.InstanceOfRAHvo));
			Assert.AreEqual(xnihimbilira_Sense1.Hvo, waCba0_2.MorphBundlesOS[1].SenseRAHvo);

			segments_Sense1 = StTxtPara.TwficSegments(Cache, instancesInTwfics_Sense1);
			Assert.AreEqual(3, segments_Sense1.Count, "Unexpected number of senses for twfics.");
			Assert.AreEqual(infoCba0_2.SegmentHvo, segments_Sense1[0], "Unexpected segment hvo.");
			Assert.AreEqual(infoCba1_0.SegmentHvo, segments_Sense1[1], "Unexpected segment hvo.");
			Assert.AreEqual(infoCba2_1.SegmentHvo, segments_Sense1[2], "Unexpected segment hvo.");

			// 4. change an existing sense to sense2.
			tapb.SetMorphSense(0, 2, 1, xnihimbilira_Sense2);
			instancesInTwfics_Sense1 = (xnihimbilira_Sense1 as LexSense).InstancesInTwfics;
			Assert.AreEqual(2, instancesInTwfics_Sense1.Count,
				String.Format("Unexpected number of instances of sense '{0}'", xnihimbilira_Sense1.Gloss.AnalysisDefaultWritingSystem));
			instancesInTwfics_Sense2 = (xnihimbilira_Sense2 as LexSense).InstancesInTwfics;
			Assert.AreEqual(1, instancesInTwfics_Sense2.Count,
				String.Format("Unexpected number of instances of sense '{0}'", xnihimbilira_Sense2.Gloss.AnalysisDefaultWritingSystem));

			infoCba0_2 = new StTxtPara.TwficInfo(Cache, instancesInTwfics_Sense2[0]);
			Assert.AreEqual(pb.ActualParagraph.Hvo, infoCba0_2.Object.BeginObjectRAHvo);
			Assert.AreEqual(0, infoCba0_2.SegmentIndex,
				String.Format("Unexpected index of segment '{0}'", infoCba0_2.SegmentHvo));

			waCba0_2 = infoCba0_2.Object.InstanceOfRA as WfiAnalysis;
			Assert.IsNotNull(waCba0_2,
				String.Format("Unexpected class({0}) of InstanceOf({1}) for cba0.", infoCba0_2.Object.InstanceOfRA.ClassID, infoCba0_2.Object.InstanceOfRAHvo));
			Assert.AreEqual(xnihimbilira_Sense2.Hvo, waCba0_2.MorphBundlesOS[1].SenseRAHvo);

			// do multiple occurrences of the same sense in the same segment.
			IWfiAnalysis wfiAnalysis3 = tapb.BreakIntoMorphs(0, 0, moForms); // break xxxpus into xx xnihimbilira (for fun).
			tapb.SetMorphSense(0, 0, 1, xnihimbilira_Sense2);
			instancesInTwfics_Sense2 = (xnihimbilira_Sense2 as LexSense).InstancesInTwfics;
			Assert.AreEqual(2, instancesInTwfics_Sense2.Count,
				String.Format("Unexpected number of instances of sense '{0}'", xnihimbilira_Sense2.Gloss.AnalysisDefaultWritingSystem));
			StTxtPara.TwficInfo infoCba0_0 = new StTxtPara.TwficInfo(Cache, instancesInTwfics_Sense2[0]);

			// reparse paragraph to convert all segments with real analyses to real ones.
			tapb.ReparseParagraph();
			infoCba0_0.ReloadInfo();
			infoCba0_2.ReloadInfo();
			infoCba1_0.ReloadInfo();
			infoCba2_1.ReloadInfo();

			List<int> segments_Sense2 = StTxtPara.TwficSegments(Cache, instancesInTwfics_Sense2);
			Assert.AreEqual(2, segments_Sense2.Count, "Unexpected number of senses for twfics.");
			Assert.AreEqual(infoCba0_0.SegmentHvo, segments_Sense2[0], "Unexpected segment hvo.");
			Assert.AreEqual(infoCba0_2.SegmentHvo, segments_Sense2[1], "Unexpected segment hvo.");

			// Load free form annotations for segments Sense 2.
			Set<int> analWsIds = new Set<int>(Cache.LangProject.AnalysisWssRC.HvoArray);
			StTxtPara.LoadSegmentFreeformAnnotationData(Cache, new Set<int>(segments_Sense2), analWsIds);
			int tagSegFF = StTxtPara.SegmentFreeformAnnotationsFlid(Cache);
			int[] segFFs = Cache.GetVectorProperty(infoCba0_0.SegmentHvo, tagSegFF, true);
			Assert.AreEqual(0, segFFs.Length, "Segment 0 should not have any freeform annotations.");
			StTxtPara.LoadSegmentFreeformAnnotationData(Cache, pb.ActualParagraph.Hvo, analWsIds);
			segFFs = Cache.GetVectorProperty(infoCba0_0.SegmentHvo, tagSegFF, true);
			Assert.AreEqual(0, segFFs.Length, "Segment 0 should not have any freeform annotations.");
			segFFs = Cache.GetVectorProperty(infoCba1_0.SegmentHvo, tagSegFF, true);
			Assert.AreEqual(0, segFFs.Length, "Segment 1 should not have any freeform annotations.");
			segFFs = Cache.GetVectorProperty(infoCba2_1.SegmentHvo, tagSegFF, true);
			Assert.AreEqual(0, segFFs.Length, "Segment 2 should not have any freeform annotations.");

			// Try adding some freeform translations
			int segDefn_literalTranslation = Cache.GetIdFromGuid(LangProject.kguidAnnLiteralTranslation);
			int segDefn_freeTranslation = Cache.GetIdFromGuid(LangProject.kguidAnnFreeTranslation);
			BaseFreeformAdder ffAdder = new BaseFreeformAdder(Cache);
			ICmIndirectAnnotation freeTrans0 = ffAdder.AddFreeformAnnotation(infoCba0_0.SegmentHvo, segDefn_freeTranslation);
			freeTrans0.Comment.SetAlternative("Segment0: Freeform translation.", Cache.DefaultAnalWs);
			ICmIndirectAnnotation literalTrans0 = ffAdder.AddFreeformAnnotation(infoCba0_0.SegmentHvo, segDefn_literalTranslation);
			literalTrans0.Comment.SetAlternative("Segment0: Literal translation.", Cache.DefaultAnalWs);

			// see if we can load this into the cache.
			StTxtPara.LoadSegmentFreeformAnnotationData(Cache, new Set<int>(segments_Sense2), analWsIds);
			segFFs = Cache.GetVectorProperty(infoCba0_0.SegmentHvo, tagSegFF, true);
			Assert.AreEqual(2, segFFs.Length, "Segment 0 should have freeform annotations.");
			Assert.AreEqual(segFFs[0], freeTrans0.Hvo, "Segment 0 Freeform translation id.");
			Assert.AreEqual(segFFs[1], literalTrans0.Hvo, "Segment 0 Literal translation id.");

			StTxtPara.LoadSegmentFreeformAnnotationData(Cache, pb.ActualParagraph.Hvo, analWsIds);
			segFFs = Cache.GetVectorProperty(infoCba0_0.SegmentHvo, tagSegFF, true);
			Assert.AreEqual(2, segFFs.Length, "Segment 0 should have freeform annotations.");
			Assert.AreEqual(segFFs[0], freeTrans0.Hvo, "Segment 0 Freeform translation id.");
			Assert.AreEqual(segFFs[1], literalTrans0.Hvo, "Segment 0 Literal translation id.");
			segFFs = Cache.GetVectorProperty(infoCba1_0.SegmentHvo, tagSegFF, true);
			Assert.AreEqual(0, segFFs.Length, "Segment 1 should not have any freeform annotations.");
			segFFs = Cache.GetVectorProperty(infoCba2_1.SegmentHvo, tagSegFF, true);
			Assert.AreEqual(0, segFFs.Length, "Segment 2 should not have any freeform annotations.");
		}
		void SetupTexts()
		{
			// First make a regular text.
			using (new UndoRedoTaskHelper(Cache, "ConcordanceControlTests - SetupTexts()", "ConcordanceControlTests - SetupTexts()"))
			{
				m_text1 = Cache.LangProject.TextsOC.Add(new Text());
				m_text1.ContentsOA = new StText();
				StTxtPara para0 = new StTxtPara();
				StTxtPara para1 = new StTxtPara();
				m_text1.ContentsOA.ParagraphsOS.Append(para0);
				m_text1.ContentsOA.ParagraphsOS.Append(para1);
				ITsStrFactory tsf = TsStrFactoryClass.Create();
				//           1         2         3         4         5         6
				// 0123456789012345678901234567890123456789012345678901234567890123456789
				// XXXXsecrecyZZZ; XXXsentenceZZZ!!
				// XXXlocoZZZ, XXXsegmentZZZ?? ZZZamazingXXX wonderfulXXXzzzcounselor!!
				para0.Contents.UnderlyingTsString = tsf.MakeString("XXXXsecrecyZZZ; XXXsentenceZZZ!!", Cache.DefaultVernWs);
				para1.Contents.UnderlyingTsString = tsf.MakeString("XXXlocoZZZ, XXXsegmentZZZ?? ZZZamazingXXX wonderfulXXXzzzcounselor!!", Cache.DefaultVernWs);

				// add scripture
				m_newBook1 = new ScrBook();
				Cache.LangProject.TranslatedScriptureOA.ScriptureBooksOS.Append(m_newBook1);
				m_newBook1.TitleOA = new StText();
				m_newBook1.TitleOA.ParagraphsOS.Append(new StTxtPara());
				(m_newBook1.TitleOA.ParagraphsOS[0] as StTxtPara).Contents.UnderlyingTsString = tsf.MakeString("XXXnewBook1zzz.Title", Cache.DefaultVernWs);
				IScrSection newSection1_0 = m_newBook1.SectionsOS.Append(new ScrSection());
				newSection1_0.ContentOA = new StText();
				StTxtPara paraSection1_0 = new StTxtPara();
				(newSection1_0.ContentOA as StText).ParagraphsOS.Append(paraSection1_0);
				paraSection1_0.Contents.UnderlyingTsString = tsf.MakeString("ZZZnewBook1.Section0.Introduction1XXX", Cache.DefaultVernWs);
				IScrSection newSection1_1 = m_newBook1.SectionsOS.Append(new ScrSection());
				newSection1_1.ContentOA = new StText();
				StTxtPara paraSection1_1 = new StTxtPara();
				(newSection1_1.ContentOA as StText).ParagraphsOS.Append(paraSection1_1);
				paraSection1_1.Contents.UnderlyingTsString = tsf.MakeString("XXXnewBook1.Section1.1:1-1:20ZZZ", Cache.DefaultVernWs);
				// section.VerseRefEnd = book.CanonicalNum * 1000000 + 1 * 1000 + (introSection ? 0 : 1);
				newSection1_1.VerseRefEnd = 70 * 1000000 + 1 * 1000 + 1;


				// setup some basic analyses for the texts.
				string formLexEntry = "XXXlexEntry1";
				ITsString tssLexEntryForm = StringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs);
				int clsidForm;
				StringUtils.ReassignTss(ref tssLexEntryForm, StringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs));
				ILexEntry lexEntry1_Entry = LexEntry.CreateEntry(Cache,
					MoMorphType.FindMorphType(Cache, new MoMorphTypeCollection(Cache), ref formLexEntry, out clsidForm), tssLexEntryForm,
					"XXXlexEntry1.sense1", null);
				ILexSense lexEntry1_Sense1 = lexEntry1_Entry.SensesOS[0];
				ILexSense lexEntry1_Sense2 = LexSense.CreateSense(lexEntry1_Entry, null, "XXXlexEntry1.sense2");
				ParagraphAnnotator tapara0 = new ParagraphAnnotator(para0);
				ParagraphAnnotator tapara1 = new ParagraphAnnotator(para1);
				ParagraphAnnotator taSection1_0 = new ParagraphAnnotator(paraSection1_0);
				ParagraphAnnotator taSection1_1 = new ParagraphAnnotator(paraSection1_1);

				// currently setup mono-morphemic search
				ArrayList morphForms = new ArrayList();
				formLexEntry = "XXXXsecrecyZZZ";
				StringUtils.ReassignTss(ref tssLexEntryForm, StringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs));
				ILexEntry lexEntry2_Entry = LexEntry.CreateEntry(Cache,
					MoMorphType.FindMorphType(Cache, new MoMorphTypeCollection(Cache), ref formLexEntry, out clsidForm), tssLexEntryForm,
					"XXXlexEntry2.sense1", null);
				morphForms.Add(lexEntry2_Entry.LexemeFormOA);
				IWfiAnalysis wfiAnalysis = tapara0.BreakIntoMorphs(0, 0, morphForms);
				m_wfXXXXsecrecyZZZ = (wfiAnalysis as WfiAnalysis).Owner as IWfiWordform;
				ILexSense lexEntry2_Sense1 = lexEntry2_Entry.SensesOS[0];
				tapara0.SetMorphSense(0, 0, 0, lexEntry2_Sense1);

				formLexEntry = "XXXsegmentZZZ";
				StringUtils.ReassignTss(ref tssLexEntryForm, StringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs));
				ILexEntry lexEntry3_Entry = LexEntry.CreateEntry(Cache,
					MoMorphType.FindMorphType(Cache, new MoMorphTypeCollection(Cache), ref formLexEntry, out clsidForm), tssLexEntryForm,
					"XXXlexEntry3.sense1", null);
				morphForms[0] = lexEntry3_Entry.LexemeFormOA;
				tapara1.BreakIntoMorphs(0, 2, morphForms);
				ILexSense lexEntry3_Sense1 = lexEntry3_Entry.SensesOS[0];
				tapara1.SetMorphSense(0, 2, 0, lexEntry3_Sense1);

				formLexEntry = "ZZZamazingXXX";
				StringUtils.ReassignTss(ref tssLexEntryForm, StringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs));
				ILexEntry lexEntry4_Entry = LexEntry.CreateEntry(Cache,
					MoMorphType.FindMorphType(Cache, new MoMorphTypeCollection(Cache), ref formLexEntry, out clsidForm), tssLexEntryForm,
					"XXXlexEntry4.sense1", null);
				morphForms[0] = lexEntry4_Entry.LexemeFormOA;
				tapara1.BreakIntoMorphs(1, 0, morphForms);
				ILexSense lexEntry4_Sense1 = lexEntry4_Entry.SensesOS[0];
				tapara1.SetMorphSense(1, 0, 0, lexEntry4_Sense1);

				//XXXlocoZZZ
				morphForms[0] = "XXXlocoZZZ";
				tapara1.BreakIntoMorphs(0, 0, morphForms);
				tapara1.SetMorphSense(0, 0, 0, lexEntry1_Sense2);

				formLexEntry = paraSection1_0.Contents.Text;
				StringUtils.ReassignTss(ref tssLexEntryForm, StringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs));
				ILexEntry lexEntry5_Entry = LexEntry.CreateEntry(Cache,
					MoMorphType.FindMorphType(Cache, new MoMorphTypeCollection(Cache), ref formLexEntry, out clsidForm), tssLexEntryForm,
					"XXXlexEntry5.sense1", null);
				morphForms[0] = lexEntry5_Entry.LexemeFormOA;
				taSection1_0.BreakIntoMorphs(0, 0, morphForms);
				ILexSense lexEntry5_Sense1 = lexEntry5_Entry.SensesOS[0];
				taSection1_0.SetMorphSense(0, 0, 0, lexEntry5_Sense1);

				morphForms[0] = paraSection1_1.Contents.Text;
				taSection1_1.BreakIntoMorphs(0, 0, morphForms);		// won't match on LexEntry
				taSection1_1.SetMorphSense(0, 0, 0, lexEntry1_Sense2);	// will match on LexGloss

				string gloss;
				tapara0.SetDefaultWordGloss(0, 0, out gloss);
				tapara1.SetDefaultWordGloss(0, 2, out gloss);
				tapara1.SetDefaultWordGloss(1, 0, out gloss);
				taSection1_1.SetDefaultWordGloss(0, 0, out gloss);

				StTxtPara.TwficInfo infoCba0_0_0 = new StTxtPara.TwficInfo(Cache, tapara0.GetSegmentForm(0, 0));
				StTxtPara.TwficInfo infoCba1_0_2 = new StTxtPara.TwficInfo(Cache, tapara1.GetSegmentForm(0, 2));
				StTxtPara.TwficInfo infoCbaScr_0_0 = new StTxtPara.TwficInfo(Cache, taSection1_1.GetSegmentForm(0, 0));

				int segDefn_literalTranslation = Cache.GetIdFromGuid(LangProject.kguidAnnLiteralTranslation);
				int segDefn_freeTranslation = Cache.GetIdFromGuid(LangProject.kguidAnnFreeTranslation);
				int segDefn_note = Cache.GetIdFromGuid(LangProject.kguidAnnNote);
				BaseFreeformAdder ffAdder = new BaseFreeformAdder(Cache);
				ICmIndirectAnnotation freeTrans0 = ffAdder.AddFreeformAnnotation(infoCba0_0_0.SegmentHvo, segDefn_freeTranslation);
				freeTrans0.Comment.SetAlternative("Para0.Segment0: XXXFreeform translation.", Cache.DefaultAnalWs);
				ICmIndirectAnnotation literalTrans0 = ffAdder.AddFreeformAnnotation(infoCba0_0_0.SegmentHvo, segDefn_literalTranslation);
				literalTrans0.Comment.SetAlternative("Para0.Segment0: XXXLiteral translation.", Cache.DefaultAnalWs);
				ICmIndirectAnnotation note0 = ffAdder.AddFreeformAnnotation(infoCba0_0_0.SegmentHvo, segDefn_note);
				note0.Comment.SetAlternative("Para0.Segment0: XXXNote.", Cache.DefaultAnalWs);

				ICmIndirectAnnotation freeTrans1 = ffAdder.AddFreeformAnnotation(infoCba1_0_2.SegmentHvo, segDefn_freeTranslation);
				freeTrans1.Comment.SetAlternative("Para1.Segment0: XXXFreeform translation.", Cache.DefaultAnalWs);
				ICmIndirectAnnotation literalTrans1 = ffAdder.AddFreeformAnnotation(infoCba1_0_2.SegmentHvo, segDefn_literalTranslation);
				literalTrans1.Comment.SetAlternative("Para1.Segment0: XXXLiteral translation.", Cache.DefaultAnalWs);
				ICmIndirectAnnotation note1 = ffAdder.AddFreeformAnnotation(infoCba1_0_2.SegmentHvo, segDefn_note);
				note1.Comment.SetAlternative("Para1.Segment0: XXXNote.", Cache.DefaultAnalWs);

				// Scripture
				ICmIndirectAnnotation freeTransScr1 = ffAdder.AddFreeformAnnotation(infoCbaScr_0_0.SegmentHvo, segDefn_freeTranslation);
				freeTransScr1.Comment.SetAlternative("Scr1.Para0.Segment0: XXXFreeform translation.", Cache.DefaultAnalWs);
				ICmIndirectAnnotation literalTransScr1 = ffAdder.AddFreeformAnnotation(infoCbaScr_0_0.SegmentHvo, segDefn_literalTranslation);
				literalTransScr1.Comment.SetAlternative("Scr1.Para0.Segment0: XXXLiteral translation.", Cache.DefaultAnalWs);
				ICmIndirectAnnotation noteScr1 = ffAdder.AddFreeformAnnotation(infoCbaScr_0_0.SegmentHvo, segDefn_note);
				noteScr1.Comment.SetAlternative("Scr1.Para0.Segment0: XXXNote.", Cache.DefaultAnalWs);
			}
		}