I want to implement a new model language for spaCY. I have installed spaCy (using the guide of the official web site) on my Windows SO but I haven't understand where and how I could write and run my future files. Help me, Thanks.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
I hope I understand your question correctly: If you only want to use spaCy, you can simply create a Python file,
import spacy
and run it.However, if you want to add things to the spaCy source – for example to add new language data that doesn't yet exist – you need to compile spaCy from source. On Windows, this needs a little more preparation – but it's not that difficult:
pip install -r requirements.txt
.python setup.py build_ext --inplace
from the same directory. This will build and compile spaCy into the directory.PYTHONPATH
is set to the new spaCy directory. This is important so Python knows that you want to execute this exact version of spaCy, and not some other one you have installed somewhere else. On Windows, I normally use this command:set PYTHONPATH=C:\path\to\spacy\directory
. There's also this thread with more info. (I'm no Windows expert, though – so if anyone reads this and disagrees, feel free to correct me here.)You can now edit the source, add files and run them. If you want to add a new language, I'd recommend starting by adding a new directory to
spacy/lang
and creating an__init__.py
. You can find more info on how this should look in the usage guide on adding languages.To test if everything works, start the Python interpreter and import and initialise your language. For example, let's assume you've added
Icelandic
. You should then be able to do this: