Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port USFM code from Machine up to commit c93f8dc #118

Merged
merged 17 commits into from
Sep 5, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
port commit 1011777; fix 2, 2a, 2b verse merging
mshannon-sil authored and johnml1135 committed Sep 5, 2024
commit f4812e3158e7fbe87f66727e939090e8f37d7e35
3 changes: 1 addition & 2 deletions machine/corpora/usfm_text_updater.py
Original file line number Diff line number Diff line change
@@ -256,9 +256,8 @@ def _advance_rows(self, seg_scr_refs: List[ScriptureRef]) -> List[str]:
break
if compare == 0:
# source and row match
# grab the text and increment both
# grab the text - both source and row will be incremented in due time...
row_texts.append(text)
source_index += 1
break
if compare <= 0:
# source is ahead of row, increment row
19 changes: 19 additions & 0 deletions tests/corpora/test_usfm_text_updater.py
Original file line number Diff line number Diff line change
@@ -168,6 +168,25 @@ def test_get_usfm_verse_range_multiple_rows_single_verse() -> None:
assert "\\v 11-12 Eleventh verse of the second chapter. Twelfth verse of the second chapter.\r\n" in target


def test_get_usfm_merge_verse_segments() -> None:
rows = [
(
scr_ref("MAT 2:2"),
str("Verse 2."),
),
(
scr_ref("MAT 2:2a"),
str("Verse 2a."),
),
(
scr_ref("MAT 2:2b"),
str("Verse 2b."),
),
]
target = update_usfm(rows)
assert "\\v 2-3 Verse 2. Verse 2a. Verse 2b.\r\n" in target


def test_get_usfm_verse_opt_break() -> None:
rows = [
(