public Proximity(Project project, bool strictlyAdhereToNarratorPreferences = true) { m_strictlyAdhereToNarratorPreferences = strictlyAdhereToNarratorPreferences; m_referenceText = project.ReferenceText; m_booksToConsider = m_referenceText.GetBooksWithBlocksConnectedToReferenceText(project).ToList(); var dramatizationPreferences = project.DramatizationPreferences; m_narrationByAuthor = project.CharacterGroupGenerationPreferences.NarratorsOption == NarratorsOption.NarrationByAuthor; m_considerSameExtrabiblicalCharacter = new Dictionary <BookScript, List <HashSet <string> > >(); // get the standard character mapping for each book foreach (var book in m_booksToConsider) { // initialize the standard character data var bookData = new Dictionary <ExtraBiblicalMaterialSpeakerOption, HashSet <string> >(); GetStandardCharactersToTreatAsOne(book, dramatizationPreferences, bookData); // For performance reasons, remove sets with only one item m_considerSameExtrabiblicalCharacter[book] = new List <HashSet <string> >(4); foreach (var compatibleIds in bookData.Values.Where(set => set.Count > 1)) { m_considerSameExtrabiblicalCharacter[book].Add(compatibleIds); } } }
public void SetReferenceText_ChangeFromEnglishToFrenchWithOneBlockMismatched_ReferenceTextClearedForAllRelatedBlocks() { var testProject = TestProject.CreateTestProject(TestProject.TestBook.MRK); testProject.ReferenceText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English); testProject.IsOkayToClearExistingRefBlocksWhenChangingReferenceText = () => true; var mark = testProject.IncludedBooks[0]; var blocks = mark.GetScriptBlocks(); var mark5V41 = blocks.IndexOf(b => b.ChapterNumber == 5 && b.InitialStartVerseNumber == 41); var matchup = testProject.ReferenceText.GetBlocksForVerseMatchedToReferenceText(mark, mark5V41, testProject.Versification); Assert.AreEqual(5, matchup.CorrelatedBlocks.Count); Assert.AreEqual(40, matchup.CorrelatedBlocks[0].InitialStartVerseNumber); Assert.AreEqual(41, matchup.CorrelatedBlocks[1].InitialStartVerseNumber); Assert.IsTrue(matchup.CorrelatedBlocks.All(b => b.ReferenceBlocks.Count == 1)); matchup.MatchAllBlocks(null); matchup.SetReferenceText(3, "this won't match."); matchup.Apply(null); var matchedVernBlocks = blocks.Skip(mark5V41).Take(4).ToList(); Assert.IsTrue(matchedVernBlocks.All(b => b.MatchesReferenceText)); Assert.IsTrue(matchedVernBlocks.All(b => b.ReferenceBlocks.Single().ReferenceBlocks.Count == 0)); Assert.IsFalse(matchedVernBlocks.Any(b => string.IsNullOrEmpty(b.GetPrimaryReferenceText()))); ReferenceText rtFrench = TestReferenceText.CreateCustomReferenceText(TestReferenceText.TestReferenceTextResource.FrenchMRK); testProject.ReferenceText = rtFrench; Assert.IsTrue(blocks.Single(b => b.ChapterNumber == 5 && b.InitialStartVerseNumber == 40).MatchesReferenceText); mark5V41 = blocks.IndexOf(b => b.ChapterNumber == 5 && b.InitialStartVerseNumber == 41); var vernBlocksForMark5V41 = blocks.Skip(mark5V41).Take(4).ToList(); Assert.IsFalse(vernBlocksForMark5V41.Any(b => b.MatchesReferenceText)); }
public static dynamic GetTSObject(ReferenceText dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
private void CacheReferenceTextFonts(ReferenceText referenceText) { m_referenceTextFonts[referenceText] = new FontProxy(referenceText.FontFamily, referenceText.FontSizeInPoints, referenceText.RightToLeftScript); if (referenceText.HasSecondaryReferenceText) { CacheReferenceTextFonts(referenceText.SecondaryReferenceText); } }
/// <summary> /// Just create the text /// </summary> /// <param name="ClassName"></param> /// <param name="Collection"></param> /// <returns></returns> private static string CreateFileText(string ClassName, DataColumnCollection Collection) { // Create the param text string Params = ""; string ConstructorParams = ""; string ConstructorAssignments = ""; bool IsPrimitive; foreach (DataColumn Col in Collection) { // Get the type name string TypeName = ToTypeName(Col, out IsPrimitive); // The ID will be inhereted if (!Col.ColumnName.Equals("Id")) { Params += "\tpublic " + TypeName + " " + Col.ColumnName + ";\r\n"; } if (ConstructorParams.Length > 0) { ConstructorParams += ", "; } ConstructorParams += TypeName + " " + Col.ColumnName + "In"; ConstructorAssignments += "\t\t" + Col.ColumnName + " = " + Col.ColumnName + "In;\r\n"; } // Update class name references string Content = ReferenceText.Replace("%ClassName%", ClassName); // Update content referneces Content = Content.Replace("%Params%", Params); Content = Content.Replace("%ConstructorParams%", ConstructorParams); Content = Content.Replace("%ConstructorAssignments%", ConstructorAssignments); // Content = Content.Replace("%ConstructorParams%", ""); // Content = Content.Replace("%ConstructorAssignments%", ""); // get the content in question return(Content); }
public void CreateGlyssenScript_HasPrimaryAndSecondaryReferenceTexts_ProcessedCorrectly() { var project = TestProject.CreateBasicTestProject(); project.ReferenceText = ReferenceText.GetStandardReferenceText(ReferenceTextType.Russian); var glyssenScript = ScriptExporter.CreateGlyssenScript(project, s_lukChapter1); var block1 = glyssenScript.Script.Books[0].Chapters[0].Blocks[0]; Assert.That(block1.VernacularText.BlockElements.Count, Is.EqualTo(2)); var primaryRefText = block1.ReferenceTexts[0]; Assert.That(primaryRefText.BlockElements.Count, Is.EqualTo(4)); Assert.That(primaryRefText.BlockElements.First(), Is.TypeOf(typeof(Verse))); Assert.That(((Verse)primaryRefText.BlockElements.First()).Number, Is.EqualTo("1")); Assert.That(primaryRefText.BlockElements.Skip(1).First(), Is.TypeOf(typeof(ScriptText))); Assert.That(((ScriptText)primaryRefText.BlockElements.Skip(1).First()).Content, Is.EqualTo("Bikman Tiofilus, ")); Assert.That(primaryRefText.BlockElements.Skip(2).First(), Is.TypeOf(typeof(Verse))); Assert.That(((Verse)primaryRefText.BlockElements.Skip(2).First()).Number, Is.EqualTo("2")); Assert.That(primaryRefText.BlockElements.Skip(3).First(), Is.TypeOf(typeof(ScriptText))); Assert.That(((ScriptText)primaryRefText.BlockElements.Skip(3).First()).Content, Is.EqualTo("Ol i bihainim tok bilong")); Assert.That(primaryRefText.Text, Is.EqualTo("Bikman Tiofilus, Ol i bihainim tok bilong")); var secondaryRefText = block1.ReferenceTexts[1]; Assert.That(secondaryRefText.BlockElements.Count, Is.EqualTo(4)); Assert.That(secondaryRefText.BlockElements.First(), Is.TypeOf(typeof(Verse))); Assert.That(((Verse)secondaryRefText.BlockElements.First()).Number, Is.EqualTo("1")); Assert.That(secondaryRefText.BlockElements.Skip(1).First(), Is.TypeOf(typeof(ScriptText))); Assert.That(((ScriptText)secondaryRefText.BlockElements.Skip(1).First()).Content, Is.EqualTo("Many have undertaken to set ")); Assert.That(secondaryRefText.BlockElements.Skip(2).First(), Is.TypeOf(typeof(Verse))); Assert.That(((Verse)secondaryRefText.BlockElements.Skip(2).First()).Number, Is.EqualTo("2")); Assert.That(secondaryRefText.BlockElements.Skip(3).First(), Is.TypeOf(typeof(ScriptText))); Assert.That(((ScriptText)secondaryRefText.BlockElements.Skip(3).First()).Content, Is.EqualTo("just as they were handed")); Assert.That(secondaryRefText.Text, Is.EqualTo("Many have undertaken to set just as they were handed")); }
public ParserCharacterRepository(ICharacterVerseRepository cvInfo, ReferenceText referenceText) { m_cvInfo = cvInfo; m_referenceText = referenceText; }
public void SetReferenceText_ChangeFromEnglishToFrench_MatchedBlocksGetMigrated() { var testProject = TestProject.CreateTestProject(TestProject.TestBook.MRK); testProject.ReferenceText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English); var mark = testProject.IncludedBooks[0]; var blocks = mark.GetScriptBlocks(); // Case where the vern blocks match 1-for-1 to the English reference text var mark8V5 = blocks.IndexOf(b => b.ChapterNumber == 8 && b.InitialStartVerseNumber == 5); var matchup = testProject.ReferenceText.GetBlocksForVerseMatchedToReferenceText(mark, mark8V5, testProject.Versification); Assert.AreEqual(4, matchup.CorrelatedBlocks.Count); Assert.IsTrue(matchup.CorrelatedBlocks.All(b => b.ReferenceBlocks.Count == 1)); matchup.MatchAllBlocks(null); matchup.Apply(null); var matchedVernBlocks = blocks.Skip(mark8V5).Take(4).ToList(); Assert.IsTrue(matchedVernBlocks.All(b => b.MatchesReferenceText)); Assert.IsTrue(matchedVernBlocks.All(b => b.ReferenceBlocks.Single().ReferenceBlocks.Count == 0)); Assert.IsFalse(matchedVernBlocks.Any(b => string.IsNullOrEmpty(b.GetPrimaryReferenceText()))); // Case where two of the English reference text blocks get combined to match a vern block var mark9V9 = blocks.IndexOf(b => b.ChapterNumber == 9 && b.InitialStartVerseNumber == 9); var englishRefBlocks = testProject.ReferenceText.Books.Single(b => b.BookId == "MRK").GetScriptBlocks(); var mark9V9EnglishRefText = englishRefBlocks.IndexOf(b => b.ChapterNumber == 9 && b.InitialStartVerseNumber == 9); Assert.AreEqual(9, englishRefBlocks[mark9V9EnglishRefText + 1].InitialStartVerseNumber); matchup = testProject.ReferenceText.GetBlocksForVerseMatchedToReferenceText(mark, mark9V9, testProject.Versification); Assert.AreEqual(3, matchup.CorrelatedBlocks.Count); Assert.IsTrue(matchup.CorrelatedBlocks.All(b => b.ReferenceBlocks.Count == 1)); var expectedEnglishRefTextForMark9V9 = englishRefBlocks[mark9V9EnglishRefText].GetText(true) + " " + englishRefBlocks[mark9V9EnglishRefText + 1].GetText(true); Assert.AreEqual(expectedEnglishRefTextForMark9V9, matchup.CorrelatedBlocks[0].GetPrimaryReferenceText()); matchup.MatchAllBlocks(null); matchup.Apply(null); matchedVernBlocks = blocks.Skip(mark9V9).Take(3).ToList(); Assert.IsTrue(matchedVernBlocks.All(b => b.MatchesReferenceText)); Assert.IsTrue(matchedVernBlocks.All(b => b.ReferenceBlocks.Single().ReferenceBlocks.Count == 0)); Assert.IsFalse(matchedVernBlocks.Any(b => string.IsNullOrEmpty(b.GetPrimaryReferenceText()))); ReferenceText rtFrench = TestReferenceText.CreateCustomReferenceText(TestReferenceText.TestReferenceTextResource.FrenchMRK); testProject.ReferenceText = rtFrench; var frenchRefBlocks = rtFrench.Books.Single(b => b.BookId == "MRK").GetScriptBlocks(); // Verify results for case where the vern blocks match 1-for-1 to the English reference text matchedVernBlocks = blocks.Skip(mark8V5).Take(4).ToList(); Assert.IsTrue(matchedVernBlocks.All(b => b.MatchesReferenceText)); Assert.IsFalse(matchedVernBlocks.Any(b => string.IsNullOrEmpty(b.GetPrimaryReferenceText()))); Assert.IsTrue(matchedVernBlocks.All(b => b.ReferenceBlocks.Single().ReferenceBlocks.Count == 1)); Assert.IsFalse(matchedVernBlocks.All(b => string.IsNullOrEmpty(b.ReferenceBlocks.Single().GetPrimaryReferenceText()))); Assert.IsTrue(matchedVernBlocks.All(b => frenchRefBlocks.Any(fb => fb.GetText(true) == b.GetPrimaryReferenceText() && fb.ChapterNumber == b.ChapterNumber && fb.InitialVerseNumberOrBridge == b.InitialVerseNumberOrBridge && b.ReferenceBlocks.Single().GetPrimaryReferenceText() == fb.GetPrimaryReferenceText()))); // Verify results for case where two of the English reference text blocks get combined to match a vern block matchedVernBlocks = blocks.Skip(mark9V9).Take(3).ToList(); Assert.IsTrue(matchedVernBlocks.All(b => b.MatchesReferenceText)); Assert.IsFalse(matchedVernBlocks.Any(b => string.IsNullOrEmpty(b.GetPrimaryReferenceText()))); Assert.IsTrue(matchedVernBlocks.All(b => b.ReferenceBlocks.Single().ReferenceBlocks.Count == 1)); Assert.IsFalse(matchedVernBlocks.All(b => string.IsNullOrEmpty(b.ReferenceBlocks.Single().GetPrimaryReferenceText()))); var mark9V9FrenchRefText = frenchRefBlocks.IndexOf(b => b.ChapterNumber == 9 && b.InitialStartVerseNumber == 9); Assert.AreEqual(frenchRefBlocks[mark9V9FrenchRefText].GetText(true) + " " + frenchRefBlocks[mark9V9FrenchRefText + 1].GetText(true), matchedVernBlocks[0].GetPrimaryReferenceText()); Assert.AreEqual(expectedEnglishRefTextForMark9V9, matchedVernBlocks[0].ReferenceBlocks.Single().GetPrimaryReferenceText()); Assert.IsTrue(matchedVernBlocks.Skip(1).All(b => frenchRefBlocks.Any(fb => fb.GetText(true) == b.GetPrimaryReferenceText() && fb.ChapterNumber == b.ChapterNumber && fb.InitialVerseNumberOrBridge == b.InitialVerseNumberOrBridge && b.ReferenceBlocks.Single().GetPrimaryReferenceText() == fb.GetPrimaryReferenceText()))); }