Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/SIL.Machine/PunctuationAnalysis/UsfmStructureExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,6 @@ public List<Chapter> GetChapters(IReadOnlyDictionary<int, List<int>> includeChap
var currentVerseSegments = new List<TextSegment>();
foreach (TextSegment textSegment in _textSegments)
{
if (textSegment.Book != null)
currentBook = Canon.BookIdToNumber(textSegment.Book);
if (textSegment.Chapter > 0)
currentChapter = textSegment.Chapter;
if (includeChapters != null && currentBook > 0)
{
if (!includeChapters.TryGetValue(currentBook, out List<int> bookChapters))
continue;
if (currentChapter > 0 && bookChapters.Count > 0 && !bookChapters.Contains(currentChapter))
continue;
}
if (textSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Verse))
{
if (currentVerseSegments.Count > 0)
Expand All @@ -168,6 +157,17 @@ public List<Chapter> GetChapters(IReadOnlyDictionary<int, List<int>> includeChap
}
currentChapterVerses = new List<Verse>();
}
if (textSegment.Book != null)
currentBook = Canon.BookIdToNumber(textSegment.Book);
if (textSegment.Chapter > 0)
currentChapter = textSegment.Chapter;
if (includeChapters != null && currentBook > 0)
{
if (!includeChapters.TryGetValue(currentBook, out List<int> bookChapters))
continue;
if (currentChapter > 0 && bookChapters.Count > 0 && !bookChapters.Contains(currentChapter))
continue;
}
currentVerseSegments.Add(textSegment);
}
if (currentVerseSegments.Count > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ public void FullQuotationDenormalizationPipeline()
string normalizedUsfm =
@"
\id GEN
\c 1
\c 2
\v 1 Thus the heavens and the earth were completed in all their vast array.
\v 2 And by the seventh day God had finished the work He had been doing;
so on that day He rested from all His work.
\v 3 Then God blessed the seventh day and sanctified it,
because on that day He rested from all the work of creation that He had accomplished.
\c 3
\v 1 Now the serpent was more subtle than any animal
of the field which Yahweh God had made.
He said to the woman, ""Has God really said,
Expand All @@ -25,7 +31,11 @@ of the field which Yahweh God had made.

string expectedDenormalizedUsfm =
@"\id GEN
\c 1
\c 2
\v 1 Thus the heavens and the earth were completed in all their vast array.
\v 2 And by the seventh day God had finished the work He had been doing; so on that day He rested from all His work.
\v 3 Then God blessed the seventh day and sanctified it, because on that day He rested from all the work of creation that He had accomplished.
\c 3
\v 1 Now the serpent was more subtle than any animal of the field which Yahweh God had made. He said to the woman, “Has God really said, ‘You shall not eat of any tree of the garden’?”
\v 2 The woman said to the serpent, “We may eat fruit from the trees of the garden,
\v 3 but not the fruit of the tree which is in the middle of the garden. God has said, ‘You shall not eat of it. You shall not touch it, lest you die.’”
Expand All @@ -44,7 +54,7 @@ of the field which Yahweh God had made.
List<(int ChapterNumber, QuotationMarkUpdateStrategy Strategy)> bestChapterStrategies =
quotationMarkDenormalizationFirstPass.FindBestChapterStrategies();

Assert.That(bestChapterStrategies.Select(tuple => tuple.ChapterNumber).SequenceEqual([1]));
Assert.That(bestChapterStrategies.Select(tuple => tuple.ChapterNumber).SequenceEqual([2, 3]));

var quotationMarkDenormalizer = new QuotationMarkDenormalizationUsfmUpdateBlockHandler(
standardEnglishQuoteConvention,
Expand Down
Loading
Loading