public void ConvertingTextSegments_InterleavedBt() { CheckDisposed(); using (TempSFFileMaker fileMaker = new TempSFFileMaker()) { string fileName = fileMaker.CreateFile("MAT", new string[] { @"\mt Matthew", @"\c 1", @"\v 1 This is my verse text", @"\rt my Back translation", @"\v 2 Second verse" }); m_settings.AddFile(fileName, ImportDomain.Main, null, 0); ImportMappingInfo mapping = m_settings.MappingForMarker(@"\rt", MappingSet.Main); mapping.StyleName = "Default Paragraph Characters"; mapping.Domain = MarkerDomain.BackTrans; // Set the vernacular WS to use the UPPERCASE encoder LgWritingSystem wsVern = new LgWritingSystem(Cache, Cache.LangProject.DefaultVernacularWritingSystem); wsVern.LegacyMapping = "UPPERCASE"; // Save settings before enumerating, which will get the styles hooked up in the mapping list m_settings.SaveSettings(); DummySCScriptureText text = new DummySCScriptureText(m_settings, ImportDomain.Main); ISCTextEnum textEnum = text.TextEnum(new ScrReference(40, 0, 0, Paratext.ScrVers.English), new ScrReference(40, 1, 2, Paratext.ScrVers.English)); ISCTextSegment textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read id segment "); Assert.AreEqual(@"\id", textSeg.Marker); Assert.AreEqual("MAT ", textSeg.Text); Assert.AreEqual(40, textSeg.FirstReference.Book); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read mt segment"); Assert.AreEqual(@"\mt", textSeg.Marker); Assert.AreEqual(@"MATTHEW ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read c segment"); Assert.AreEqual(@"\c", textSeg.Marker); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read v 1"); Assert.AreEqual(@"\v", textSeg.Marker); Assert.AreEqual("1", textSeg.LiteralVerseNum); Assert.AreEqual(@" THIS IS MY VERSE TEXT ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read btvt segment"); Assert.AreEqual(@"\rt", textSeg.Marker); Assert.AreEqual(@"my Back translation ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read v 2"); Assert.AreEqual(@"\v", textSeg.Marker); Assert.AreEqual("2", textSeg.LiteralVerseNum); Assert.AreEqual(@" SECOND VERSE ", textSeg.Text); Assert.IsNull(textEnum.Next()); } }
public void ConvertingTextSegments_BTImportDomain() { CheckDisposed(); using (TempSFFileMaker fileMaker = new TempSFFileMaker()) { string fileName = fileMaker.CreateFile("MAT", new string[] { @"\mt Matthew", @"\c 1", @"\v 1", @"\vt my \uw retronica\uw* translation", @"\k keywordbt" }); m_settings.AddFile(fileName, ImportDomain.BackTrans, "en", 0); m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\uw ", @"\uw*", false, MappingTargetType.TEStyle, MarkerDomain.BackTrans, "Untranslated Word", "es")); m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\k", null, "Key Word")); // Set the vernacular WS to use the UPPERCASE encoder LgWritingSystem wsEnglish = new LgWritingSystem(Cache, Cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr("en")); wsEnglish.LegacyMapping = "UPPERCASE"; // Save settings before enumerating, which will get the styles hooked up in the mapping list m_settings.SaveSettings(); DummySCScriptureText text = new DummySCScriptureText(m_settings, ImportDomain.BackTrans); ISCTextEnum textEnum = text.TextEnum(new ScrReference(40, 0, 0, Paratext.ScrVers.English), new ScrReference(40, 1, 2, Paratext.ScrVers.English)); ISCTextSegment textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read id segment "); Assert.AreEqual(@"\id", textSeg.Marker); Assert.AreEqual("MAT ", textSeg.Text); Assert.AreEqual(40, textSeg.FirstReference.Book); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read mt segment"); Assert.AreEqual(@"\mt", textSeg.Marker); Assert.AreEqual(@"MATTHEW ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read c segment"); Assert.AreEqual(@"\c", textSeg.Marker); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read v 1"); Assert.AreEqual(@"\v", textSeg.Marker); Assert.AreEqual("1", textSeg.LiteralVerseNum); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read first vt segment"); Assert.AreEqual(@"\vt", textSeg.Marker); Assert.AreEqual(@"MY ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read untranslated word segment (Spanish)"); Assert.AreEqual(@"\uw ", textSeg.Marker); Assert.AreEqual(@"retronica", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to segment following untranslated word"); Assert.AreEqual(@"\uw*", textSeg.Marker); Assert.AreEqual(@" TRANSLATION ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read keyword segment"); Assert.AreEqual(@"\k", textSeg.Marker); Assert.AreEqual(@"KEYWORDBT ", textSeg.Text); Assert.IsNull(textEnum.Next()); } }
public void ConvertingTextSegments_MainImportDomain() { CheckDisposed(); using (TempSFFileMaker fileMaker = new TempSFFileMaker()) { string fileName = fileMaker.CreateFile("MAT", new string[] { @"\mt Matthew", @"\c 1", @"\v 1", @"\vt This is \em my\em* verse text with a", @"\sp espanol", @"\k keyword", @"\f footnote text", // This tests the switch statement in GetEncodingConverterForMarkerDomain @"\spkwf raro", // This tests the need for & ~MarkerDomain.Footnote in ConvertSource @"\ft end of footnote", @"\btvt my \em Back\em* translation", @"\k keywordbt" }); m_settings.AddFile(fileName, ImportDomain.Main, null, 0); m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\em ", @"\em*", "Emphasis")); m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\k", null, "Key Word")); ImportMappingInfo mapping = m_settings.MappingForMarker(@"\sp", MappingSet.Main); mapping.StyleName = "Default Paragraph Characters"; mapping.IcuLocale = "es"; mapping = m_settings.MappingForMarker(@"\f", MappingSet.Main); mapping.StyleName = ScrStyleNames.NormalFootnoteParagraph; mapping = m_settings.MappingForMarker(@"\spkwf", MappingSet.Main); mapping.StyleName = "Key Word"; mapping.IcuLocale = "es"; mapping.Domain = MarkerDomain.Default | MarkerDomain.Footnote; mapping = m_settings.MappingForMarker(@"\ft", MappingSet.Main); mapping.StyleName = "Default Paragraph Characters"; mapping.Domain = MarkerDomain.Default | MarkerDomain.Footnote; mapping = m_settings.MappingForMarker(@"\btvt", MappingSet.Main); mapping.Domain = MarkerDomain.BackTrans; // Set the vernacular WS to use the UPPERCASE encoder LgWritingSystem wsVern = new LgWritingSystem(Cache, Cache.LangProject.DefaultVernacularWritingSystem); wsVern.LegacyMapping = "UPPERCASE"; // Save settings before enumerating, which will get the styles hooked up in the mapping list m_settings.SaveSettings(); DummySCScriptureText text = new DummySCScriptureText(m_settings, ImportDomain.Main); ISCTextEnum textEnum = text.TextEnum(new ScrReference(40, 0, 0, Paratext.ScrVers.English), new ScrReference(40, 1, 2, Paratext.ScrVers.English)); ISCTextSegment textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read id segment "); Assert.AreEqual(@"\id", textSeg.Marker); Assert.AreEqual("MAT ", textSeg.Text); Assert.AreEqual(40, textSeg.FirstReference.Book); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read mt segment"); Assert.AreEqual(@"\mt", textSeg.Marker); Assert.AreEqual(@"MATTHEW ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read c segment"); Assert.AreEqual(@"\c", textSeg.Marker); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read v 1"); Assert.AreEqual(@"\v", textSeg.Marker); Assert.AreEqual("1", textSeg.LiteralVerseNum); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read first vt segment"); Assert.AreEqual(@"\vt", textSeg.Marker); Assert.AreEqual(@"THIS IS ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read emphasis segment"); Assert.AreEqual(@"\em ", textSeg.Marker); Assert.AreEqual(@"MY", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read emphasis segment"); Assert.AreEqual(@"\em*", textSeg.Marker); Assert.AreEqual(@" VERSE TEXT WITH A ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read Spanish segment"); Assert.AreEqual(@"\sp", textSeg.Marker); Assert.AreEqual(@"espanol ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read keyword segment"); Assert.AreEqual(@"\k", textSeg.Marker); Assert.AreEqual(@"KEYWORD ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read footnote text segment"); Assert.AreEqual(@"\f", textSeg.Marker); Assert.AreEqual(@"FOOTNOTE TEXT ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read Spanish keyword in footnote segment"); Assert.AreEqual(@"\spkwf", textSeg.Marker); Assert.AreEqual(@"raro ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read end of footnote segment"); Assert.AreEqual(@"\ft", textSeg.Marker); Assert.AreEqual(@"END OF FOOTNOTE ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read btvt segment"); Assert.AreEqual(@"\btvt", textSeg.Marker); Assert.AreEqual(@"my ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, @"Unable to read BT \em segment"); Assert.AreEqual(@"\em ", textSeg.Marker); Assert.AreEqual(@"Back", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, @"Unable to read BT \em segment"); Assert.AreEqual(@"\em*", textSeg.Marker); Assert.AreEqual(@" translation ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read BT keyword segment"); Assert.AreEqual(@"\k", textSeg.Marker); Assert.AreEqual(@"keywordbt ", textSeg.Text); Assert.IsNull(textEnum.Next()); } }