AnkiSpacy is a package manager for spaCy and its models. By itself it is not very interesting. But its intent is to provide other Anki addons the power of spaCy without having to package and distribute spaCy.
Once installed the addon will create a Manage Spacy...
menu item under Anki's Tools
Menu.
By selecting this menu option you will be presented with the package manager dialog.
The package manager is a dialog that allows you to install spacy and its models.
The left panel shows a list of packages that can be installed. spaCy appears first in the list followed by its models.
The right panel allows you to install and uninstall the currently selected package. Additionally, it provides further information about the package.
At the bottom is a progress and info panel that outputs information as a package is installed.
Other Anki addons can subscribe to the hooks emitted by this addon. As each package is installed/uninstalled the sys.path of python is updated so they will be made available/unavailable to other Anki addons.
Hook Name | Description |
---|---|
AnkiSpacy.spacyInstalled | Emitted when spaCy is installed via the package manager or during Anki startup if spaCy is already installed. |
AnkiSpacy.spacyUninstalled | Emitted when spaCy is uninstalled via the package manager. |
AnkiSpacy.modelAvailable | Emitted when a model is installed via the package manager or during Anki startup if the model is already installed. This hook will be emitted for all models that are compatible with the currently installed version of spaCy. If the model is not compatible or spaCy is not installed the hook will not emit for that model. |
AnkiSpacy.modelUnavailable | Emitted when a model is uninstalled via the package manager. |
The hook is emitted with the following dict:
{
'name': <package_name>,
'version': <installed_version>,
'path': <installed path>
}
installed_version
will be None
if the package was uninstalled.
While spaCy and its models are python packages you do not need python installed. The addon uses the python shipped with anki to install the packages with pip.
Setup dev environment (Only tested in OS X).
python3 -m venv venv
venv/bin/python -m pip install -r requirements.txt
source ./venv/bin/activate
To create a distribution zip
inv dist
Thanks to @ianki for helping me figure out how to run pip within Anki's python distribution.