Skip to content

Commit a617373

Browse files
committed
Remove redundant string property
1 parent 9e80ee9 commit a617373

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

machine/punctuation_analysis/quotation_mark_finder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def find_all_potential_quotation_marks_in_text_segment(
3636
self, text_segment: TextSegment
3737
) -> List[QuotationMarkStringMatch]:
3838
quotation_matches: List[QuotationMarkStringMatch] = []
39-
for quotation_mark_match in self._QUOTATION_MARK_PATTERN.finditer(text_segment.text.string):
39+
for quotation_mark_match in self._QUOTATION_MARK_PATTERN.finditer(str(text_segment.text)):
4040
if self._quote_conventions.is_valid_opening_quotation_mark(
4141
quotation_mark_match.group()
4242
) or self._quote_conventions.is_valid_closing_quotation_mark(quotation_mark_match.group()):

machine/punctuation_analysis/quotation_mark_string_match.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __eq__(self, value):
3535

3636
@property
3737
def quotation_mark(self) -> str:
38-
return self._text_segment.text[self._start_index : self._end_index].string
38+
return str(self._text_segment.text[self._start_index : self._end_index])
3939

4040
def is_valid_opening_quotation_mark(self, quote_conventions: QuoteConventionSet) -> bool:
4141
return quote_conventions.is_valid_opening_quotation_mark(self.quotation_mark)
@@ -59,18 +59,18 @@ def previous_character(self) -> Optional[str]:
5959
if previous_segment is not None and not self._text_segment.marker_is_in_preceding_context(
6060
UsfmMarkerType.PARAGRAPH
6161
):
62-
return previous_segment.text[-1].string
62+
return str(previous_segment.text[-1])
6363
return None
64-
return self._text_segment.text[self._start_index - 1].string
64+
return str(self._text_segment.text[self._start_index - 1])
6565

6666
@property
6767
def next_character(self) -> Optional[str]:
6868
if self.is_at_end_of_segment():
6969
next_segment = self._text_segment.next_segment
7070
if next_segment is not None and not next_segment.marker_is_in_preceding_context(UsfmMarkerType.PARAGRAPH):
71-
return next_segment.text[0].string
71+
return str(next_segment.text[0])
7272
return None
73-
return self._text_segment.text[self._end_index].string
73+
return str(self._text_segment.text[self._end_index])
7474

7575
def leading_substring_matches(self, regex_pattern: regex.Pattern) -> bool:
7676
return regex_pattern.search(self._text_segment.substring_before(self._start_index)) is not None
@@ -100,9 +100,9 @@ def end_index(self) -> int:
100100
# Not used, but a useful method for debugging
101101
@property
102102
def context(self) -> str:
103-
return self._text_segment.text[
103+
return str(self._text_segment.text[
104104
max(self._start_index - 10, 0) : min(self._end_index + 10, len(self._text_segment.text))
105-
].string
105+
])
106106

107107
def resolve(self, depth: int, direction: QuotationMarkDirection) -> QuotationMarkMetadata:
108108
return QuotationMarkMetadata(

machine/punctuation_analysis/text_segment.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ def length(self) -> int:
4040
return len(self._text)
4141

4242
def substring_before(self, index: int) -> str:
43-
return self._text[:index].string
43+
return str(self._text[:index])
4444

4545
def substring_after(self, index: int) -> str:
46-
return self._text[index:].string
46+
return str(self._text[index:])
4747

4848
def marker_is_in_preceding_context(self, marker: UsfmMarkerType) -> bool:
4949
return marker in self._markers_in_preceding_context
@@ -57,7 +57,7 @@ def is_last_segment_in_verse(self) -> bool:
5757
def replace_substring(self, start_index: int, end_index: int, replacement: str) -> None:
5858
self._text = GraphemeString(self.substring_before(start_index) + replacement + self.substring_after(end_index))
5959
if self._usfm_token is not None:
60-
self._usfm_token.text = self._text.string
60+
self._usfm_token.text = str(self._text)
6161

6262
class Builder:
6363
def __init__(self):
@@ -97,17 +97,13 @@ def __init__(self, string: str) -> None:
9797
def __len__(self) -> int:
9898
return len(self._string_index_by_grapheme_index)
9999

100-
@property
101-
def string(self) -> str:
102-
return self._string
103-
104100
def __str__(self):
105101
return self._string
106102

107103
def __eq__(self, other) -> bool:
108104
if not isinstance(other, GraphemeString):
109105
return False
110-
return self._string == other.string
106+
return self._string == other._string
111107

112108
def __getitem__(self, key) -> "GraphemeString":
113109
if isinstance(key, int):

0 commit comments

Comments
 (0)