sillsdev / sillsdev/machine.py
Marker placement does not occur in verse ranges
Open
@benjaminking is already working on this.
Since Sep 15, 2026.
invalid
- Dominant language
- Python
- Stars
- 12
- Forks
- 3
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 5
Description
Verse ranges are represented as multiple rows in a UsfmUpdateBlock, only the first of which is non-empty. The marker placement algorithm uses only one alignment matrix, defaulting to the last, which is empty in the case of a verse range. This results in markers not being placed for verse ranges.
Here is a failing test for this case:
source = "This is the first part. This is the second part."
pretranslation = "Esta es la primera parte. Esta es la segunda parte."
align_info = PlaceMarkersAlignmentInfo(
source_tokens=[t for t in TOKENIZER.tokenize(source)],
translation_tokens=[t for t in TOKENIZER.tokenize(pretranslation)],
alignment=to_word_alignment_matrix("0-0 1-1 2-2 3-3 4-4 5-5 6-6 7-7 8-8 9-9 10-10 11-11"),
paragraph_behavior=UpdateUsfmMarkerBehavior.PRESERVE,
style_behavior=UpdateUsfmMarkerBehavior.STRIP,
)
empty_align_info = PlaceMarkersAlignmentInfo(
source_tokens=[],
translation_tokens=[],
alignment=to_word_alignment_matrix(""),
paragraph_behavior=UpdateUsfmMarkerBehavior.PRESERVE,
style_behavior=UpdateUsfmMarkerBehavior.STRIP,
)
usfm = r"""\id MAT
\c 1
\v 1-2 This is the first part.
\p This is the second part.
"""
result = r"""\id MAT
\c 1
\v 1-2 Esta es la primera parte.
\p Esta es la segunda parte.
"""
rows = [
UpdateUsfmRow(scr_ref("MAT 1:1"), str(pretranslation), metadata={"alignment_info": align_info}),
UpdateUsfmRow(scr_ref("MAT 1:2"), "", metadata={"alignment_info": empty_align_info}),
]
target = update_usfm(rows, usfm, update_block_handlers=[PlaceMarkersUsfmUpdateBlockHandler()])
assert_usfm_equals(target, result)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.