Merge pull request #3446 from jepler/python35-compression-fix

makeqstrdata: Work around python3.5/3.6 compatibility problem
This commit is contained in:
Scott Shawcroft 2020-09-21 10:35:00 -07:00 committed by GitHub
commit df067b498d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,7 +109,11 @@ class TextSplitter:
def __init__(self, words):
words.sort(key=lambda x: len(x), reverse=True)
self.words = set(words)
self.pat = re.compile("|".join(re.escape(w) for w in words) + "|.", flags=re.DOTALL)
if words:
pat = "|".join(re.escape(w) for w in words) + "|."
else:
pat = "."
self.pat = re.compile(pat, flags=re.DOTALL)
def iter_words(self, text):
s = []