protected override void MonitorAction()
        {
            if (m_cache.GetIdFromGuid(LangProject.kguidAnnPunctuationInContext) == 0)
            {
                return;                 // Testing, can't do conversion.
            }
            BtConverter converter = new BtConverter(m_objectToMonitor.Owner as StTxtPara);

            converter.ConvertCmTransToInterlin(m_ws);
        }
Beispiel #2
0
		public void SingleSegment()
		{
			string paraContents = "Das buch ist rot";
			string trans = "The book is red";
			m_para.Contents.UnderlyingTsString = m_tsf.MakeString(paraContents, m_wsVern);
			m_trans.Translation.SetAlternative(trans, m_wsTrans);
			BtConverter converter = new BtConverter(m_para);
			converter.ConvertCmTransToInterlin(m_wsTrans);
			int cseg = Cache.GetVectorSize(m_para.Hvo, kflidSegments);
			Assert.AreEqual(1, cseg, "Para with no EOS or verse should have one segment");
			VerifyFt(0, trans, "whole translation should be transferred to single ft.");
		}
Beispiel #3
0
		public void EmptyPara()
		{
			string paraContents = "";
			string trans = "";
			m_para.Contents.UnderlyingTsString = m_tsf.MakeString(paraContents, m_wsVern);
			m_trans.Translation.SetAlternative(trans, m_wsTrans);
			BtConverter converter = new BtConverter(m_para);
			converter.ConvertCmTransToInterlin(m_wsTrans);
			int cseg = Cache.GetVectorSize(m_para.Hvo, kflidSegments);
			Assert.AreEqual(0, cseg, "Empty para should have no segments");
		}
Beispiel #4
0
		public void SmartResync()
		{
			// Here we end up with four segments in the second group. After building it once, we make a change that merges
			// the middle two BT segments. We hope the fourth stays aligned.
			string pc1 = "Das buch ist rot. ";
			string pc2 = "Das Madchen ist shon.";
			string verse1 = "9";
			string pc3 = "Der Herr ist gross.";
			string pc4 = "Ich spreche nicht viel Deutsch.";
			string pc5 = "Was is das?";
			string pc6 = "Wie gehts?";

			ITsStrBldr bldr = m_tsf.MakeString(pc1 + pc2 + verse1 + pc3 + pc4 + pc5 + pc6, m_wsVern).GetBldr();
			bldr.SetStrPropValue(pc1.Length + pc2.Length, pc1.Length + pc2.Length + verse1.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			m_para.Contents.UnderlyingTsString = bldr.GetString();
			string trans1 = "The book is red.";
			//string trans2 = "The girl is beautiful";
			string trans3 = "The man is big.";
			string trans4 = "I don't speak much German.";
			string trans5 = "What is that?";
			string trans6 = "How's it going?";
			bldr = m_tsf.MakeString(trans1 + verse1 + trans3 + trans4 + trans5 + trans6, m_wsTrans).GetBldr();
			bldr.SetStrPropValue(trans1.Length, trans1.Length + verse1.Length,
				(int)FwTextPropType.ktptNamedStyle, ScrStyleNames.VerseNumber);
			m_trans.Translation.SetAlternative(bldr.GetString(), m_wsTrans);

			BtConverter converter = new BtConverter(m_para);
			converter.ConvertCmTransToInterlin(m_wsTrans);
			int cseg = Cache.GetVectorSize(m_para.Hvo, kflidSegments);
			Assert.AreEqual(7, cseg, "parsing para should produce seven segs.");
			VerifyFt(0, trans1, "first leading seg should have proper trans");
			VerifyFt(1, null, "2nd leading seg should have nothing");
			//VerifyFt(2, null, "no trans of verse number");
			VerifyFt(3, trans3, "4th seg should get normal stuff");
			VerifyFt(4, trans4, "5th seg gets trans in seqyence");
			VerifyFt(5, trans5, "6th seg gets trans in seq");
			VerifyFt(6, trans6, "last seg gets trans in seq");

			// Now, the real test!

			int ichDot = trans1.Length + verse1.Length + trans3.Length + trans4.Length - 1;
			bldr = m_trans.Translation.GetAlternative(m_wsTrans).UnderlyingTsString.GetBldr();
			bldr.ReplaceTsString(ichDot, ichDot + 1, null);
			m_trans.Translation.SetAlternative(bldr.GetString(), m_wsTrans);
			converter = new BtConverter(m_para);
			converter.ConvertCmTransToInterlin(m_wsTrans);

			cseg = Cache.GetVectorSize(m_para.Hvo, kflidSegments);
			Assert.AreEqual(7, cseg, "reparsing para should produce seven segs.");
			VerifyFt(0, trans1, "first leading seg should (still) have proper trans");
			VerifyFt(1, null, "2nd leading seg should (still) have nothing");
			//VerifyFt(2, null, "no trans of verse number");
			VerifyFt(3, trans3, "4th seg should get normal stuff");
			VerifyFt(4, trans4.Substring(0, trans4.Length - 1) + trans5, "4th seg gets blended translations");
			VerifyFt(5, null, "skip 6th seg to keep sixth unchanged");
			VerifyFt(6, trans6, "6th seg is not changed.");
		}
Beispiel #5
0
		public void ChapterAndWhiteSpace()
		{
			// Here we have chapter number as well as verse number, and white space that could throw things off.
			//string pc1 = "Das buch ist rot. ";
			//string pc2 = "Das Madchen ist shon.";
			string chap1 = "1";
			string verse1 = "9";
			string pc3 = "Der Herr ist gross.";
			string pc4 = "Ich spreche nicht viel Deutsch.";
			string verse2 = "10";
			string pc5 = "Was is das?";
			string pc6 = "Wie gehts?";

			ITsStrBldr bldr = m_tsf.MakeString(" " + chap1 + " " + verse1 + pc3 + pc4 + verse2 + pc5 + pc6, m_wsVern).GetBldr();
			bldr.SetStrPropValue(1, chap1.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.ChapterNumber);
			bldr.SetStrPropValue(1 + chap1.Length + 1, 1 + chap1.Length + 1 + verse1.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			int ichEndV1 = 1 + chap1.Length + 1 + verse1.Length + pc3.Length + pc4.Length;
			bldr.SetStrPropValue(ichEndV1, ichEndV1 + verse2.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			m_para.Contents.UnderlyingTsString = bldr.GetString();
			//string trans1 = "The book is red.";
			//string trans2 = "The girl is beautiful";
			string trans3 = "The man is big.";
			//string trans4 = "I don't speak much German.";
			string trans5 = "What is that?";
			string trans6 = "How's it going?";
			bldr = m_tsf.MakeString(chap1 + verse1 + " " + trans3 + verse2 + " " + trans5 + trans6, m_wsTrans).GetBldr();
			bldr.SetStrPropValue(0, chap1.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.ChapterNumber);
			bldr.SetStrPropValue(chap1.Length, chap1.Length + verse1.Length,
				(int)FwTextPropType.ktptNamedStyle, ScrStyleNames.VerseNumber);
			int ichEndTransV1 = chap1.Length + verse1.Length + 1 + trans3.Length;
			bldr.SetStrPropValue(ichEndTransV1, ichEndTransV1 + verse2.Length, (int)FwTextPropType.ktptNamedStyle,
				ScrStyleNames.VerseNumber);
			m_trans.Translation.SetAlternative(bldr.GetString(), m_wsTrans);

			BtConverter converter = new BtConverter(m_para);
			converter.ConvertCmTransToInterlin(m_wsTrans);
			int cseg = Cache.GetVectorSize(m_para.Hvo, kflidSegments);
			Assert.AreEqual(6, cseg, "parsing para should produce six segs.");
			VerifyLabel(0, "chap/verse number identified as label");
			VerifyFt(1, trans3, "2nd seg should have corresponding BT");
			VerifyFt(2, null, "3rd seg should have no BT");
			VerifyLabel(3, "verse number identified as label");
			VerifyFt(4, trans5, "5th seg should get third BT");
			VerifyFt(5, trans6, "last seg gets appropriate BT");
		}
Beispiel #6
0
		public void BothStartWithVerse()
		{
			// Here there is extra material in the BT before the first verse number, but not in the paragraph.
			//string pc1 = "Das buch ist rot. ";
			//string pc2 = "Das Madchen ist shon.";
			string verse1 = "9";
			string pc3 = "Der Herr ist gross.";
			string pc4 = "Ich spreche nicht viel Deutsch.";
			string verse2 = "10";
			string pc5 = "Was is das?";
			string pc6 = "Wie gehts?";

			ITsStrBldr bldr = m_tsf.MakeString(verse1 + pc3 + pc4 + verse2 + pc5 + pc6, m_wsVern).GetBldr();
			bldr.SetStrPropValue(0, verse1.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			int ichEndV1 = verse1.Length + pc3.Length + pc4.Length;
			bldr.SetStrPropValue(ichEndV1, ichEndV1 + verse2.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			m_para.Contents.UnderlyingTsString = bldr.GetString();
			//string trans1 = "The book is red.";
			//string trans2 = "The girl is beautiful";
			string trans3 = "The man is big.";
			string trans4 = "I don't speak much German.";
			string trans5 = "What is that?";
			string trans6 = "How's it going?";
			bldr = m_tsf.MakeString(verse1 + trans3 + trans4 + verse2 + trans5 + trans6, m_wsTrans).GetBldr();
			bldr.SetStrPropValue(0, verse1.Length,
				(int)FwTextPropType.ktptNamedStyle, ScrStyleNames.VerseNumber);
			int ichEndTransV1 = verse1.Length + trans3.Length + trans4.Length;
			bldr.SetStrPropValue(ichEndTransV1, ichEndTransV1 + verse2.Length, (int)FwTextPropType.ktptNamedStyle,
				ScrStyleNames.VerseNumber);
			m_trans.Translation.SetAlternative(bldr.GetString(), m_wsTrans);

			BtConverter converter = new BtConverter(m_para);
			converter.ConvertCmTransToInterlin(m_wsTrans);
			int cseg = Cache.GetVectorSize(m_para.Hvo, kflidSegments);
			Assert.AreEqual(6, cseg, "parsing para should produce six segs.");
			//VerifyFt(0, null, "no trans of verse number");
			VerifyFt(1, trans3, "3rd seg should have corresponding BT");
			VerifyFt(2, trans4, "4th seg should have corresponding BT");
			//VerifyFt(3, null, "no trans of verse number");
			VerifyFt(4, trans5, "5th seg should get third BT");
			VerifyFt(5, trans6, "last seg gets appropriate BT");
		}
Beispiel #7
0
		public void MissingBtVerse()
		{
			// Here for some reason the BT is out of order: has verse 10 before verse 9. The program still assigns
			// sequentially the segments that follow matching verse numbers.
			string pc1 = "Das buch ist rot. ";
			string pc2 = "Das Madchen ist shon.";
			string verse1 = "9";
			string pc3 = "Der Herr ist gross.";
			string pc4 = "Ich spreche nicht viel Deutsch.";
			string verse2 = "10";
			string pc5 = "Was is das?";
			string pc6 = "Wie gehts?";

			ITsStrBldr bldr = m_tsf.MakeString(pc1 + pc2 + verse1 + pc3 + pc4 + verse2 + pc5 + pc6, m_wsVern).GetBldr();
			bldr.SetStrPropValue(pc1.Length + pc2.Length, pc1.Length + pc2.Length + verse1.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			int ichEndV1 = pc1.Length + pc2.Length + verse1.Length + pc3.Length + pc4.Length;
			bldr.SetStrPropValue(ichEndV1, ichEndV1 + verse2.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			m_para.Contents.UnderlyingTsString = bldr.GetString();
			string trans1 = "The book is red.";
			string trans2 = "The girl is beautiful";
			//string trans3 = "The man is big.";
			//string trans4 = "I don't speak much German.";
			string trans5 = "What is that?";
			string trans6 = "How's it going?";
			bldr = m_tsf.MakeString(trans1 + trans2 + verse2 + trans5 + trans6, m_wsTrans).GetBldr();
			int ichEndTransV1 = trans1.Length + trans2.Length;
			bldr.SetStrPropValue(ichEndTransV1, ichEndTransV1 + verse2.Length, (int)FwTextPropType.ktptNamedStyle,
				ScrStyleNames.VerseNumber);
			m_trans.Translation.SetAlternative(bldr.GetString(), m_wsTrans);

			BtConverter converter = new BtConverter(m_para);
			converter.ConvertCmTransToInterlin(m_wsTrans);
			int cseg = Cache.GetVectorSize(m_para.Hvo, kflidSegments);
			Assert.AreEqual(8, cseg, "parsing para should produce eight segs.");
			VerifyFt(0, trans1, "first seg");
			VerifyFt(1, trans2, "2nd seg assigned sequentially");
			//VerifyFt(2, null, "no trans of verse number");
			VerifyFt(3, null, "3rd seg should get no BT, all BTs belong to some other verse");
			VerifyFt(4, null, "4th seg should get no BT, all BTs belong to some other verse");
			//VerifyFt(5, null, "no trans of verse number");
			VerifyFt(6, trans5, "5th seg should get third BT");
			VerifyFt(7, trans6, "last seg gets appropriate BT");
		}
Beispiel #8
0
		public void ExtraSegsInBtWithDiffNumberSystem()
		{
			// Make a paragraph where para contents has three verses with one seg each, BT has two segs per verse.
			string pc1 = "Das buch ist rot. ";
			//string pc2 = "Das Madchen ist shon.";
			string verse1 = "9";
			string pc3 = "Der Herr ist gross.";
			//string pc4 = "Ich spreche nicht viel Deutsch.";
			string verse2 = "10";
			string pc5 = "Was is das?";
			//string pc6 = "Wie gehts?";
			Cache.LangProject.TranslatedScriptureOA.UseScriptDigits = true;
			int oldDigitZero = Cache.LangProject.TranslatedScriptureOA.ScriptDigitZero;
			try
			{
				int charOffset = 2534 - '0';
				Cache.LangProject.TranslatedScriptureOA.ScriptDigitZero = 2534; // Bengali
				StringBuilder bldrV = new StringBuilder();
				bldrV.Append((char)('9' + charOffset));
				string verse1V = bldrV.ToString();
				bldrV = new StringBuilder();
				bldrV.Append((char)('1' + charOffset));
				bldrV.Append((char)('0' + charOffset));
				string verse2V = bldrV.ToString();
				ITsStrBldr bldr = m_tsf.MakeString(pc1 + verse1V + pc3 + verse2V + pc5, m_wsVern).GetBldr();
				bldr.SetStrPropValue(pc1.Length, pc1.Length + verse1V.Length, (int) FwTextPropType.ktptNamedStyle,
									 ScrStyleNames.VerseNumber);
				int ichEndV1 = pc1.Length + verse1V.Length + pc3.Length;
				bldr.SetStrPropValue(ichEndV1, ichEndV1 + verse2V.Length, (int) FwTextPropType.ktptNamedStyle,
									 ScrStyleNames.VerseNumber);
				m_para.Contents.UnderlyingTsString = bldr.GetString();
				string trans1 = "The book is red.";
				string trans2 = "The girl is beautiful";
				string trans3 = "The main is big.";
				string trans4 = "I don't speak much German.";
				string trans5 = "What is that?";
				string trans6 = "How's it going?";
				bldr =
					m_tsf.MakeString(trans1 + trans2 + verse1 + trans3 + trans4 + verse2 + trans5 + trans6, m_wsTrans).
						GetBldr();
				bldr.SetStrPropValue(trans1.Length + trans2.Length, trans1.Length + trans2.Length + verse1.Length,
									 (int) FwTextPropType.ktptNamedStyle, ScrStyleNames.VerseNumber);
				int ichEndTransV1 = trans1.Length + trans2.Length + verse1.Length + trans3.Length + trans4.Length;
				bldr.SetStrPropValue(ichEndTransV1, ichEndTransV1 + verse2.Length, (int) FwTextPropType.ktptNamedStyle,
									 ScrStyleNames.VerseNumber);
				m_trans.Translation.SetAlternative(bldr.GetString(), m_wsTrans);

				BtConverter converter = new BtConverter(m_para);
				converter.ConvertCmTransToInterlin(m_wsTrans);
				int cseg = Cache.GetVectorSize(m_para.Hvo, kflidSegments);
				Assert.AreEqual(5, cseg, "parsing para should produce five segs.");
				VerifyFt(0, trans1 + " " + trans2, "first seg should have first TWO translations");
				//VerifyFt(1, null, "no trans of verse number");
				VerifyFt(2, trans3 + " " + trans4, "3rd seg should get next TWO BTs");
				//VerifyFt(3, null, "no trans of verse number");
				VerifyFt(4, trans5 + " " + trans6, "5th seg should get fifth and sixth BTs");

			}
			finally
			{
				Cache.LangProject.TranslatedScriptureOA.UseScriptDigits = false;
				Cache.LangProject.TranslatedScriptureOA.ScriptDigitZero = oldDigitZero;
			}
		}
Beispiel #9
0
		public void ExtraSegsInParaVerseNotMatching()
		{
			// Make a paragraph where para contents has three verses with one seg each, BT has two segs per verse.
			string pc1 = "Das buch ist rot. ";
			//string pc2 = "Das Madchen ist shon.";
			string verse1 = "9";
			string pc3 = "Der Herr ist gross.";
			//string pc4 = "Ich spreche nicht viel Deutsch.";
			string verse2 = "10";
			string pc5 = "Was is das?";
			//string pc6 = "Wie gehts?";
			string verse3 = "11";

			ITsStrBldr bldr = m_tsf.MakeString(pc1 + verse1 + pc3 + verse2 + pc5, m_wsVern).GetBldr();
			bldr.SetStrPropValue(pc1.Length, pc1.Length + verse1.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			int ichEndV1 = pc1.Length + verse1.Length + pc3.Length;
			bldr.SetStrPropValue(ichEndV1, ichEndV1 + verse2.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			m_para.Contents.UnderlyingTsString = bldr.GetString();
			string trans1 = "The book is red.";
			string trans2 = "The girl is beautiful";
			string trans3 = "The man is big.";
			string trans4 = "I don't speak much German.";
			string trans5 = "What is that?";
			string trans6 = "How's it going?";
			bldr = m_tsf.MakeString(trans1 + trans2 + verse1 + trans3 + trans4 + verse3 + trans5 + trans6, m_wsTrans).GetBldr();
			bldr.SetStrPropValue(trans1.Length + trans2.Length, trans1.Length + trans2.Length + verse1.Length,
				(int)FwTextPropType.ktptNamedStyle, ScrStyleNames.VerseNumber);
			int ichEndTransV1 = trans1.Length + trans2.Length + verse1.Length + trans3.Length + trans4.Length;
			bldr.SetStrPropValue(ichEndTransV1, ichEndTransV1 + verse3.Length, (int)FwTextPropType.ktptNamedStyle,
				ScrStyleNames.VerseNumber);
			m_trans.Translation.SetAlternative(bldr.GetString(), m_wsTrans);

			BtConverter converter = new BtConverter(m_para);
			converter.ConvertCmTransToInterlin(m_wsTrans);
			int cseg = Cache.GetVectorSize(m_para.Hvo, kflidSegments);
			Assert.AreEqual(5, cseg, "parsing para should produce five segs.");
			VerifyFt(0, trans1 + " " + trans2, "first seg should have first TWO translations");
			//VerifyFt(1, null, "no trans of verse number");
			VerifyFt(2, trans3, "3rd seg should get next BTs");
			//VerifyFt(3, null, "no trans of verse number");
			VerifyFt(4, trans4 + " " + trans5 + " " + trans6, "5th seg should get last three BTs");
		}
Beispiel #10
0
		public void ExtraSegsInBtVerseNotMatching()
		{
			// Like ExtraSegsInBt, but second verse number does not match in BT.
			string pc1 = "Das buch ist rot. ";
			string pc2 = "Das Madchen ist shon.";
			string verse1 = "9";
			string pc3 = "Der Herr ist gross.";
			string pc4 = "Ich spreche nicht viel Deutsch.";
			string verse2 = "10";
			string pc5 = "Was is das?";
			string pc6 = "Wie gehts?";
			string verse3 = "11";

			ITsStrBldr bldr = m_tsf.MakeString(pc1 + pc2 + verse1 + pc3 + pc4 + verse2 + pc5 + pc6, m_wsVern).GetBldr();
			bldr.SetStrPropValue(pc1.Length + pc2.Length, pc1.Length + pc2.Length + verse1.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			int ichEndV1 = pc1.Length + pc2.Length + verse1.Length + pc3.Length + pc4.Length;
			bldr.SetStrPropValue(ichEndV1, ichEndV1 + verse2.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			m_para.Contents.UnderlyingTsString = bldr.GetString();
			string trans1 = "The book is red.";
			//string trans2 = "The girl is beautiful";
			string trans3 = "The man is big.";
			// string trans4 = "I don't speak much German.";
			string trans5 = "What is that?";
			// string trans6 = "How's it going?";
			bldr = m_tsf.MakeString(trans1 + verse1 + trans3 + verse3 + trans5, m_wsTrans).GetBldr();
			bldr.SetStrPropValue(trans1.Length, trans1.Length + verse1.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			int ichEndTransV1 = trans1.Length + verse1.Length + trans3.Length;
			bldr.SetStrPropValue(ichEndTransV1, ichEndTransV1 + verse3.Length, (int)FwTextPropType.ktptNamedStyle,
				ScrStyleNames.VerseNumber);
			m_trans.Translation.SetAlternative(bldr.GetString(), m_wsTrans);

			BtConverter converter = new BtConverter(m_para);
			converter.ConvertCmTransToInterlin(m_wsTrans);
			int cseg = Cache.GetVectorSize(m_para.Hvo, kflidSegments);
			Assert.AreEqual(8, cseg, "parsing para should produce eight segs.");
			VerifyFt(0, trans1, "first seg");
			VerifyFt(1, null, "verse number sync should keep second BT empty");
			//VerifyFt(2, null, "no trans of verse number");
			VerifyFt(3, trans3, "3rd seg should get second BT");
			VerifyFt(4, trans5, "2nd verse does not match, keep assigning sequentially");
			//VerifyFt(5, null, "no trans of verse number");
			VerifyFt(6, null, "5th seg has no BTs left to assign");
			VerifyFt(7, null, "last seg left with empty BT");
		}
Beispiel #11
0
		public void MatchingVerses()
		{
			// Make a paragraph where both para contents and translation have two segments separated by verse number.
			string paraContents1 = "Das buch ist rot. ";
			string verse = "12";
			string paraContents2 = "Das Madchen ist shon.";
			ITsStrBldr bldr = m_tsf.MakeString(paraContents1 + verse + paraContents2, m_wsVern).GetBldr();
			bldr.SetStrPropValue(paraContents1.Length, paraContents1.Length + verse.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			m_para.Contents.UnderlyingTsString = bldr.GetString();
			string trans1 = "The book is red.";
			string trans2 = "The girl is beautiful";
			bldr = m_tsf.MakeString(trans1 + verse + trans2, m_wsTrans).GetBldr();
			bldr.SetStrPropValue(trans1.Length, trans1.Length + verse.Length, (int)FwTextPropType.ktptNamedStyle,
								 ScrStyleNames.VerseNumber);
			m_trans.Translation.SetAlternative(bldr.GetString(), m_wsTrans);

			BtConverter converter = new BtConverter(m_para);
			converter.ConvertCmTransToInterlin(m_wsTrans);
			int cseg = Cache.GetVectorSize(m_para.Hvo, kflidSegments);
			Assert.AreEqual(3, cseg, "parsing para should produce three segs.");
			VerifyFt(0, trans1, "first seg");
			// Currently we don't care whether there is an FT for verse segments...maybe one day we will.
			//VerifyFt(1, null, "no second FT");
			VerifyFt(2, trans2, "last seg");
		}
        public static void UpdateMainTransFromSegmented(StTxtPara para, int[] wss)
        {
            if (!para.IsValidObject())
            {
                return;                 // in merge, paragraph may be modified then deleted.
            }
            FdoCache cache = para.Cache;

            BtConverter.EnsureMainParaSegments(para, wss[0]);
            ISilDataAccess sda         = cache.MainCacheAccessor;
            List <int>     segments    = para.Segments;
            int            kflidFT     = StTxtPara.SegmentFreeTranslationFlid(cache);
            ITsString      tssContents = para.Contents.UnderlyingTsString;
            IScripture     scr         = para.Cache.LangProject.TranslatedScriptureOA;
            ICmTranslation originalBT  = para.GetBT();            // Can be null
            string         sUnfinished = BackTranslationStatus.Unfinished.ToString();

            foreach (int ws in wss)
            {
                ITsStrBldr bldr          = TsStrBldrClass.Create();
                bool       wantNextSpace = false;        // suppresses space before the first thing we add.
                bool       haveBtText    = false;        // Text that isn't segment label text
                foreach (int hvoSeg in segments)
                {
                    // If it's a label, insert it directly. Suppress following space.
                    int       beginOffset = sda.get_IntProp(hvoSeg, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginOffset);
                    int       endOffset   = sda.get_IntProp(hvoSeg, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidEndOffset);
                    ITsString tssFt;
                    // Whether we want to insert a space before the current segment is determined by the previous one.
                    // Save that value so we can set wantSpace appropriately for the following one.
                    bool wantSpace = wantNextSpace;
                    if (SegmentBreaker.HasLabelText(tssContents, beginOffset, endOffset))
                    {
                        tssFt         = (new CmBaseAnnotation(cache, hvoSeg)).TextAnnotated;
                        tssFt         = scr.ConvertCVNumbersInStringForBT(CorrectFootnotes(tssFt), ws);
                        wantNextSpace = false;
                    }
                    else
                    {
                        int hvoFt = sda.get_ObjectProp(hvoSeg, kflidFT);
                        tssFt         = sda.get_MultiStringAlt(hvoFt, (int)CmAnnotation.CmAnnotationTags.kflidComment, ws);
                        haveBtText   |= (tssFt.Length > 0);
                        wantNextSpace = EndsWithNonSpace(tssFt);
                    }
                    if (tssFt.Length > 0)
                    {
                        if (wantSpace)
                        {
                            // The preceding segment should typically be followed by a space.
                            if (!StartsWithSpaceOrOrc(tssFt))
                            {
                                bldr.Replace(bldr.Length, bldr.Length, " ", null);
                            }
                        }
                        bldr.ReplaceTsString(bldr.Length, bldr.Length, tssFt);
                    }
                }

                // If the back translation doesn't have text, we don't want to create verse
                // segment labels. This prevents the problem where the book thinks it has a
                // back translation because of automatically generated verse labels (TE-8283).
                if (!haveBtText)
                {
                    // This check might not be needed, but it shouldn't hurt anything.
                    if (originalBT != null)
                    {
                        if (originalBT.Translation.GetAlternative(ws).Length > 0)
                        {
                            string origStatus = originalBT.Status.GetAlternative(ws);
                            if (!String.IsNullOrEmpty(origStatus) && origStatus != sUnfinished)
                            {
                                originalBT.Status.SetAlternative(sUnfinished, ws);
                            }
                        }
                    }
                    continue;
                }

                ITsString      newFt = bldr.GetString();
                ICmTranslation trans;
                if (newFt.Length == 0)
                {
                    trans = para.GetBT();
                    if (trans == null)
                    {
                        return;                         // don't bother creating one to store an empty translation!
                    }
                }
                else
                {
                    trans = para.GetOrCreateBT();
                }
                // Don't write unless it changed...PropChanged can be expensive.
                if (!trans.Translation.GetAlternative(ws).UnderlyingTsString.Equals(newFt))
                {
                    trans.Translation.SetAlternative(newFt, ws);
                    trans.Status.SetAlternative(sUnfinished, ws);
                }
            }
        }
		protected override void MonitorAction()
		{
			if (m_cache.GetIdFromGuid(LangProject.kguidAnnPunctuationInContext) == 0)
				return; // Testing, can't do conversion.
			BtConverter converter = new BtConverter(m_objectToMonitor.Owner as StTxtPara);
			converter.ConvertCmTransToInterlin(m_ws);
		}