Skip to content

Commit

Permalink
fix remaining flake8 warnings. Also addresses #34
Browse files Browse the repository at this point in the history
  • Loading branch information
tsroten committed Jun 24, 2023
1 parent c24fcfb commit 8579f69
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/zhon/pinyin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from __future__ import unicode_literals
from string import whitespace
from re import escape


_a = "a\u0101\u00E0\u00E1\u01CE"
Expand Down Expand Up @@ -37,7 +38,7 @@
marks = "·012345:-'"

#: A string containing valid punctuation marks that are not stops.
non_stops = """"#$%&'()*+,-/:;<=>@[\]^_`{|}~"""
non_stops = """"#$%&'()*+,-/\\:;<=>@[]^_`{|}~"""

#: A string containing valid stop punctuation marks.
stops = ".!?"
Expand Down Expand Up @@ -152,9 +153,9 @@ def _build_sentence(word):
container-closing punctuation marks (e.g. apostrophe and brackets).
"""
return (
"(?:{word}|[{non_stops}]|(?<![{stops} ]) )+" "[{stops}]['\"\]\}}\)]*"
).format(word=word, non_stops=non_stops.replace("-", "\-"), stops=stops)
return r"(?:{word}|[{non_stops}]|(?<![{stops} ]) )+[{stops}]['\"\]}}\)]*".format(
word=word, non_stops=escape(non_stops), stops=escape(stops)
)


#: A regular expression pattern for a valid accented Pinyin syllable.
Expand Down

0 comments on commit 8579f69

Please sign in to comment.