Skip to content

Commit

Permalink
Merge branch 'main' into add_get_chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac091 authored Nov 21, 2023
2 parents ff15d78 + 58919a5 commit 5baf156
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion machine/corpora/corpora_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _get_verse_num(verse_str: str) -> int:
874: "cp874",
875: "cp875",
932: "cp932",
936: "gb2313",
936: "cp936",
949: "cp949",
950: "cp950",
1026: "cp1026",
Expand Down
4 changes: 2 additions & 2 deletions machine/corpora/usfm_file_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ def _get_id(filename: StrPath, encoding: str) -> str:
index = id.find(" ")
if index != -1:
id = id[:index]
return id.strip()
raise RuntimeError("The USFM does not contain and 'id' marker.")
return id.strip().upper()
raise RuntimeError("The USFM does not contain an 'id' marker.")
4 changes: 2 additions & 2 deletions machine/corpora/usfm_zip_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ def _get_id(archive_filename: StrPath, path: str, encoding: str) -> str:
index = id.find(" ")
if index != -1:
id = id[:index]
return id.strip()
raise RuntimeError("The USFM does not contain and 'id' marker.")
return id.strip().upper()
raise RuntimeError("The USFM does not contain an 'id' marker.")
16 changes: 16 additions & 0 deletions tests/corpora/test_usfm_file_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,19 @@ def test_get_rows_include_markers() -> None:

assert verse_ref(rows[16]).exact_equals(VerseRef.from_string("MAT 2:10", corpus.versification))
assert rows[16].text == "\\tc3-4 Chapter 2 verse 10"


def test_usfm_file_text_corpus_lowercase_usfm_id() -> None:
corpus = UsfmFileTextCorpus(USFM_TEST_PROJECT_PATH)

text = corpus.get_text("LEV")
assert text is not None
rows = list(text)

assert len(rows) == 2

assert verse_ref(rows[0]).exact_equals(VerseRef.from_string("LEV 14:55", corpus.versification))
assert rows[0].text == "Chapter fourteen, verse fifty-five. Segment b."

assert verse_ref(rows[1]).exact_equals(VerseRef.from_string("LEV 14:56", corpus.versification))
assert rows[1].text == "Chapter fourteen, verse fifty-six."
2 changes: 1 addition & 1 deletion tests/testutils/data/usfm/Tes/04LEVTes.SFM
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\id LEV - Test
\id lev - Test
\h Leviticus
\mt Leviticus
\c 14
Expand Down

0 comments on commit 5baf156

Please sign in to comment.