Skip to content

Scripture Update block #168

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Scripture Update block #168

wants to merge 9 commits into from

Conversation

johnml1135
Copy link
Collaborator

@johnml1135 johnml1135 commented Apr 3, 2025

Will this evolve first?


This change is Reviewable

Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. I just have a couple of comments.

Reviewed 10 of 10 files at r1, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @johnml1135)


machine/corpora/scripture_update_block.py line 11 at r1 (raw file):

    def __init__(self) -> None:
        self._ref: ScriptureRef = ScriptureRef()

What is this field used for?


machine/corpora/scripture_update_block.py line 12 at r1 (raw file):

    def __init__(self) -> None:
        self._ref: ScriptureRef = ScriptureRef()
        self._elements: list[ScriptureUpdateElement] = []

If this is accessible outside of this class, then I would expose it as a public read-only property.

@property
def elements(self) -> List[ScriptureUpdateElement]:
    return self._elements

machine/corpora/scripture_update_block_handler_base.py line 6 at r1 (raw file):

class ScriptureUpdateBlockHandlerBase:

This can just be an interface. You can rename it to ScriptureUpdateBlockHandler.


machine/corpora/usfm_parser_state.py line 112 at r1 (raw file):

    def is_verse_text(self) -> bool:
        # anything before verse 1 is not verse text
        if self.verse_ref.verse_num == 0:

I am a little worried about this change. In this context, is_verse_text is referring to the UsfmTextType. Just to be safe, I think we should remove this change and add the check to UpdateUsfmParserHandler.end_para().


machine/corpora/scripture_update_element.py line 16 at r1 (raw file):

@dataclass
class ScriptureUpdateElement:

I think ScriptureUpdateOperation would be a more precise name, unless I'm misunderstanding the purpose of this class. "Element" is kind of generic.

@johnml1135
Copy link
Collaborator Author

machine/corpora/scripture_update_block.py line 11 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

What is this field used for?

Some functionality will have to be aware of the scripture passage to know how to process the verse text. For instance, if Ben's algorithm fails in a chapter, that entire chapter should be left alone - this is facilitated by being verse-aware.

@johnml1135
Copy link
Collaborator Author

machine/corpora/scripture_update_block.py line 12 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

If this is accessible outside of this class, then I would expose it as a public read-only property.

@property
def elements(self) -> List[ScriptureUpdateElement]:
    return self._elements

Done.

@johnml1135
Copy link
Collaborator Author

machine/corpora/scripture_update_block_handler_base.py line 6 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

This can just be an interface. You can rename it to ScriptureUpdateBlockHandler.

Done.

@johnml1135
Copy link
Collaborator Author

machine/corpora/scripture_update_element.py line 16 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

I think ScriptureUpdateOperation would be a more precise name, unless I'm misunderstanding the purpose of this class. "Element" is kind of generic.

These are the elements that are updated - they are not the operations themselves. I don't know if there is a better way to represent that.

@johnml1135
Copy link
Collaborator Author

machine/corpora/usfm_parser_state.py line 112 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

I am a little worried about this change. In this context, is_verse_text is referring to the UsfmTextType. Just to be safe, I think we should remove this change and add the check to UpdateUsfmParserHandler.end_para().

Let's discuss the implications for the different scenarios.

Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 13 of 13 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @johnml1135)


machine/corpora/scripture_update_block.py line 11 at r1 (raw file):

Previously, johnml1135 (John Lambert) wrote…

Some functionality will have to be aware of the scripture passage to know how to process the verse text. For instance, if Ben's algorithm fails in a chapter, that entire chapter should be left alone - this is facilitated by being verse-aware.

Ok, then you should expose it as a public property.


machine/corpora/scripture_update_element.py line 16 at r1 (raw file):

Previously, johnml1135 (John Lambert) wrote…

These are the elements that are updated - they are not the operations themselves. I don't know if there is a better way to represent that.

Ok, I think I understand better what the class represents.


tests/corpora/test_usfm_file_text.py line 69 at r2 (raw file):

    rows = list(text)

    assert len(rows) == 52

Why did this unit test change? It worries me that changing the USFM updater is affecting USFM parsing.


machine/corpora/scripture_update_block_handler.py line 10 at r2 (raw file):

class ScriptureUpdateBlockHandler(ABC):

    def process_block(self, block: ScriptureUpdateBlock) -> ScriptureUpdateBlock:

This method should not have an implementation, like other interfaces in Machine.py.

@abstractmethod
def process_block(self, block: ScriptureUpdateBlock) -> ScriptureUpdateBlock:
    ...

@johnml1135
Copy link
Collaborator Author

machine/corpora/scripture_update_block.py line 11 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

Ok, then you should expose it as a public property.

Yes... that makes sense now :-)

@johnml1135
Copy link
Collaborator Author

machine/corpora/scripture_update_block_handler.py line 10 at r2 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

This method should not have an implementation, like other interfaces in Machine.py.

@abstractmethod
def process_block(self, block: ScriptureUpdateBlock) -> ScriptureUpdateBlock:
    ...

Paradigms...

@johnml1135
Copy link
Collaborator Author

tests/corpora/test_usfm_file_text.py line 69 at r2 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

Why did this unit test change? It worries me that changing the USFM updater is affecting USFM parsing.

It's related to the "is verse text" If there are two '\p' before a verse, are they separate enties to be translated differently or should the second one be a true "paragraph" while the first is a "segment initiating paragraph"?

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 95.67568% with 8 lines in your changes missing coverage. Please review.

Project coverage is 87.20%. Comparing base (a3d7276) to head (3097b78).

Files with missing lines Patch % Lines
machine/corpora/update_usfm_parser_handler.py 94.80% 4 Missing ⚠️
machine/corpora/scripture_update_block.py 93.33% 2 Missing ⚠️
machine/corpora/scripture_update_element.py 96.77% 1 Missing ⚠️
...chine/corpora/zip_paratext_project_text_updater.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #168      +/-   ##
==========================================
- Coverage   88.55%   87.20%   -1.35%     
==========================================
  Files         276      276              
  Lines       16498    16094     -404     
==========================================
- Hits        14609    14035     -574     
- Misses       1889     2059     +170     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants