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

Invalid syntax in "/spacy/lang/ko/__init__.py" when calling spacy.blank("ko") for Korean #4068

Closed
veer-bains opened this issue Aug 2, 2019 · 5 comments
Labels
bug Bugs and behaviour differing from documentation compat Cross-platform and cross-Python compatibility help wanted (easy) Contributions welcome! (also suited for spaCy beginners) help wanted Contributions welcome! lang / ko Korean language data and models

Comments

@veer-bains
Copy link
Contributor

How to reproduce the behaviour

calling
spacy.blank("ko")
produces the following traceback:
`File "/usr/lib64/python2.7/site-packages/spacy/init.py", line 31, in blank
LangClass = util.get_lang_class(name)
File "/usr/lib64/python2.7/site-packages/spacy/util.py", line 70, in get_lang_class
module = importlib.import_module(".lang.%s" % lang, "spacy")
File "/usr/lib64/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/usr/lib64/python2.7/site-packages/spacy/lang/ko/init.py", line 28

surface: str

       ^

SyntaxError: invalid syntax`

The same script has worked fine for me with other languages, and the same format of data(english, german, chinese, spanish, and a few others), so perhaps this may not be an error on my side.

Your Environment

  • Operating System: CentOS ("Linux-3.10.0-957.21.3.el7.x86_64-x86_64-with-centos-7.6.1810-Core")
  • Python Version Used: 2.7
  • spaCy Version Used: 2.1.6
  • Environment Information: NIL (running script directly from terminal)
@ines ines added bug Bugs and behaviour differing from documentation compat Cross-platform and cross-Python compatibility lang / ko Korean language data and models labels Aug 2, 2019
@ines
Copy link
Member

ines commented Aug 2, 2019

Thanks for the report – looks like the problem here are the type annotations on the named tuple. There is a condition for Python 2.7 and 3.5, but I guess 2.7 just sees this as a syntax error and fails regardless 😞

Are you able to upgrade to Python 3? If so, that'd be the easiest workaround for now.

Relevant source is here btw: https:/explosion/spaCy/blob/master/spacy/lang/ko/__init__.py

It might make sense to rewrite the code so it doesn't use a named tuple, if possible. That means we could remove all the Python version handling and compatibility hacks here. (We will drop 2.7 and 3.5 eventually, but for now, we do have to support both.)

@ines ines added help wanted Contributions welcome! help wanted (easy) Contributions welcome! (also suited for spaCy beginners) labels Aug 2, 2019
@veer-bains
Copy link
Contributor Author

A lot of my team's code is dependent on Python 2.7 actually, because converting to Python 3 would actually generate pretty much the same kind of errors we're seeing here haha.
I guess if we must though, then we must. I'll pass the information along to my team. Thanks for the help!

@ines
Copy link
Member

ines commented Aug 2, 2019

@veer-bains Yeah, I totally understand that! The other alternative would be to build spaCy from source and remove the non-2.7 code in that file. (Or maybe someone on your team even has some time to fix it and submit a PR 🙂 This way, we can definitely make sure to ship the fix in the next release.)

@veer-bains
Copy link
Contributor Author

@ines Will do my best!

@ines ines closed this as completed in 874bd8c Aug 5, 2019
polm pushed a commit to polm/spaCy that referenced this issue Aug 18, 2019
…loses explosion#4068)

* fixed syntax error in declaring variables with python 2.7 in spacy/lang/ko/__init__.py

* fixed syntax error in declaring variables with python 2.7 in spacy/lang/ko/__init__.py

* Update __init__.py

* Create veer-bains.md

* Update __init__.py

fixed syntax errors in variable datatype assignment when calling spacy.blank("ko") with python 2.7
@lock
Copy link

lock bot commented Sep 4, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bugs and behaviour differing from documentation compat Cross-platform and cross-Python compatibility help wanted (easy) Contributions welcome! (also suited for spaCy beginners) help wanted Contributions welcome! lang / ko Korean language data and models
Projects
None yet
Development

No branches or pull requests

2 participants