Skip to content

Commit

Permalink
convert from abstract class, use ENGLISH_VERSIFICATION
Browse files Browse the repository at this point in the history
  • Loading branch information
mshannon-sil committed Apr 4, 2024
1 parent 3e97c10 commit 4e6ccde
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
5 changes: 3 additions & 2 deletions machine/corpora/corpora_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

import regex as re

from ..scripture import ENGLISH_VERSIFICATION
from ..scripture.canon import book_id_to_number
from ..scripture.verse_ref import VERSE_RANGE_SEPARATOR, VERSE_SEQUENCE_INDICATOR, Versification, VersificationType
from ..scripture.verse_ref import VERSE_RANGE_SEPARATOR, VERSE_SEQUENCE_INDICATOR, Versification

T = TypeVar("T")

Expand Down Expand Up @@ -107,7 +108,7 @@ def get_usx_versification(project_dir: Path, versification: Optional[Versificati
if versification is None and versification_filename.is_file():
versification_name = project_dir.name
versification = Versification.load(versification_filename, fallback_name=versification_name)
return Versification.get_builtin(VersificationType.ENGLISH) if versification is None else versification
return ENGLISH_VERSIFICATION if versification is None else versification


def merge_verse_ranges(verse1: str, verse2: str) -> str:
Expand Down
5 changes: 3 additions & 2 deletions machine/corpora/dbl_bundle_text_corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from typing import List
from zipfile import ZipFile

from ..scripture.verse_ref import Versification, VersificationType
from ..scripture import ENGLISH_VERSIFICATION
from ..scripture.verse_ref import Versification
from ..utils.typeshed import StrPath
from .scripture_text_corpus import ScriptureTextCorpus
from .usx_zip_text import UsxZipText
Expand Down Expand Up @@ -32,7 +33,7 @@ def __init__(self, filename: StrPath) -> None:
TextIOWrapper(stream, encoding="utf-8-sig"), "versification.vrs", fallback_name=abbr
)
else:
versification = Versification.get_builtin(VersificationType.ENGLISH)
versification = ENGLISH_VERSIFICATION

texts: List[UsxZipText] = []
for content_elem in doc.getroot().findall("./publications/publication[@default='true']/structure/content"):
Expand Down
3 changes: 1 addition & 2 deletions machine/corpora/paratext_project_settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from abc import ABC
from dataclasses import dataclass

from ..scripture.canon import book_id_to_number
Expand All @@ -7,7 +6,7 @@


@dataclass
class ParatextProjectSettings(ABC):
class ParatextProjectSettings:
name: str
full_name: str
encoding: str
Expand Down
7 changes: 3 additions & 4 deletions machine/corpora/scripture_text.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Generator, List, Optional

from ..scripture.verse_ref import VerseRef, Versification, VersificationType
from ..scripture import ENGLISH_VERSIFICATION
from ..scripture.verse_ref import VerseRef, Versification
from ..utils.context_managed_generator import ContextManagedGenerator
from .corpora_utils import gen, get_scripture_text_sort_key
from .text_base import TextBase
Expand All @@ -10,9 +11,7 @@
class ScriptureText(TextBase):
def __init__(self, id: str, versification: Optional[Versification] = None) -> None:
super().__init__(id, get_scripture_text_sort_key(id))
self._versification = (
Versification.get_builtin(VersificationType.ENGLISH) if versification is None else versification
)
self._versification = ENGLISH_VERSIFICATION if versification is None else versification

@property
def versification(self) -> Versification:
Expand Down
5 changes: 3 additions & 2 deletions machine/corpora/usfm_file_text_corpus.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from pathlib import Path
from typing import List, Optional

from ..scripture.verse_ref import Versification, VersificationType
from ..scripture import ENGLISH_VERSIFICATION
from ..scripture.verse_ref import Versification
from ..utils.typeshed import StrPath
from .scripture_text_corpus import ScriptureTextCorpus
from .usfm_file_text import UsfmFileText
Expand All @@ -19,7 +20,7 @@ def __init__(
file_pattern: str = "*.SFM",
) -> None:
if versification is None:
versification = Versification.get_builtin(VersificationType.ENGLISH)
versification = ENGLISH_VERSIFICATION
stylesheet = UsfmStylesheet(stylesheet_filename)
texts: List[UsfmFileText] = []
for sfm_filename in Path(project_dir).glob(file_pattern):
Expand Down
5 changes: 3 additions & 2 deletions machine/corpora/usfm_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import regex as re

from ..scripture import ENGLISH_VERSIFICATION
from ..scripture.canon import book_id_to_number
from ..scripture.verse_ref import Versification, VersificationType
from ..scripture.verse_ref import Versification
from ..utils.typeshed import StrPath
from .usfm_parser_handler import UsfmParserHandler
from .usfm_parser_state import UsfmElementType, UsfmParserElement, UsfmParserState
Expand Down Expand Up @@ -45,7 +46,7 @@ def __init__(
else:
tokens = usfm
if versification is None:
versification = Versification.get_builtin(VersificationType.ENGLISH)
versification = ENGLISH_VERSIFICATION
self.state = UsfmParserState(self.stylesheet, versification, tokens)
self.handler = handler
self.tokens_preserve_whitespace = tokens_preserve_whitespace
Expand Down

0 comments on commit 4e6ccde

Please sign in to comment.