Skip to content
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

SyntaxError raised due to improper use of escape sequence "\s*" #129

Open
diegodebrito opened this issue Dec 3, 2024 · 1 comment
Open

Comments

@diegodebrito
Copy link

I am getting a SyntaxError when debugging some code. The error is related to an invalid use with \ in the context of string matching (see link for exact line below).

re.finditer('{0}\s*'.format(re.escape(sent)), self.original_text)

Which raises the following error:

E     File "local\.venv\Lib\site-packages\pysbd\segmenter.py", line 66
E       for match in re.finditer('{0}\s*'.format(re.escape(sent)), self.original_text):
E                                ^^^^^^^^
E   SyntaxError: invalid escape sequence '\s'

for match in re.finditer('{0}\s*'.format(re.escape(sent)), self.original_text):

@diegodebrito
Copy link
Author

Found another occurrence of a similar error in

txt = re.sub('(?<={0})\.'.format(am), '∯', txt)

E     File "local\.venv\Lib\site-packages\pysbd\lang\arabic.py", line 29
E       txt = re.sub('(?<={0})\.'.format(am), '∯', txt)
E                    ^^^^^^^^^^^^
E   SyntaxError: invalid escape sequence '\.'

And in

txt = re.sub('(?<={0})\.'.format(am), '∯', txt)

E     File "local\.venv\Lib\site-packages\pysbd\lang\persian.py", line 29
E       txt = re.sub('(?<={0})\.'.format(am), '∯', txt)
E                    ^^^^^^^^^^^^
E   SyntaxError: invalid escape sequence '\.'

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

No branches or pull requests

1 participant