2015-07-01 13:39:38 +00:00
spaCy: Industrial-strength NLP
2016-10-03 10:33:22 +00:00
***** ***** ***** ***** ***** *****
2014-07-03 15:15:40 +00:00
2017-11-07 19:45:34 +00:00
spaCy is a library for advanced natural language processing in Python and
Cython. spaCy is built on the very latest research, but it isn't researchware.
It was designed from day one to be used in real products. spaCy currently supports
English, German, French and Spanish, as well as tokenization for Italian,
Portuguese, Dutch, Swedish, Finnish, Norwegian, Hungarian, Bengali, Hebrew, Thai,
Chinese and Japanese. It's commercial open-source software, released under the
MIT license.
2017-04-07 17:30:49 +00:00
2017-11-07 19:45:34 +00:00
⭐️ **Test spaCy v2.0.0 and the new models!** `Check out the new features here. <https://alpha.spacy.io/usage/v2> `_
💫 **Version 1.10 out now!** `Read the release notes here. <https://github.com/explosion/spaCy/releases/> `_
2016-10-19 00:32:08 +00:00
2017-03-08 10:08:09 +00:00
.. image :: https://img.shields.io/travis/explosion/spaCy/master.svg?style=flat-square
2016-10-15 21:51:16 +00:00
:target: https://travis-ci.org/explosion/spaCy
2017-11-07 19:45:34 +00:00
:alt: Travis Build Status
.. image :: https://img.shields.io/appveyor/ci/explosion/spacy/master.svg?style=flat-square
:target: https://ci.appveyor.com/project/explosion/spacy
:alt: Appveyor Build Status
2017-03-08 10:36:00 +00:00
2017-03-03 18:15:56 +00:00
.. image :: https://img.shields.io/github/release/explosion/spacy.svg?style=flat-square
2017-03-08 10:36:00 +00:00
:target: https://github.com/explosion/spaCy/releases
2016-10-16 05:07:07 +00:00
:alt: Current Release Version
2017-03-08 10:36:00 +00:00
2017-03-07 16:59:30 +00:00
.. image :: https://img.shields.io/pypi/v/spacy.svg?style=flat-square
:target: https://pypi.python.org/pypi/spacy
:alt: pypi Version
2017-03-08 10:36:00 +00:00
2017-03-03 18:15:56 +00:00
.. image :: https://anaconda.org/conda-forge/spacy/badges/version.svg
:target: https://anaconda.org/conda-forge/spacy
:alt: conda Version
2017-03-08 10:36:00 +00:00
2017-03-03 18:15:56 +00:00
.. image :: https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-09a3d5.svg?style=flat-square
2016-10-16 19:53:24 +00:00
:target: https://gitter.im/explosion/spaCy
2016-10-16 05:07:07 +00:00
:alt: spaCy on Gitter
2017-03-08 10:36:00 +00:00
2017-03-03 18:15:56 +00:00
.. image :: https://img.shields.io/twitter/follow/spacy_io.svg?style=social&label=Follow
2017-01-14 18:02:05 +00:00
:target: https://twitter.com/spacy_io
:alt: spaCy on Twitter
2015-06-24 03:05:33 +00:00
2016-10-31 22:29:57 +00:00
📖 Documentation
2016-11-05 01:35:37 +00:00
================
2016-10-31 22:29:57 +00:00
2017-11-07 19:45:34 +00:00
=================== ===
`Usage Workflows`_ How to use spaCy and its features.
`API Reference`_ The detailed reference for spaCy's API.
`Troubleshooting`_ Common problems and solutions for beginners.
`Tutorials`_ End-to-end examples, with code you can modify and run.
`Showcase & Demos`_ Demos, libraries and products from the spaCy community.
`Contribute`_ How to contribute to the spaCy project and code base.
=================== ===
.. _Usage Workflows: https://spacy.io/docs/usage/
.. _API Reference: https://spacy.io/docs/api/
.. _Troubleshooting: https://spacy.io/docs/usage/troubleshooting
.. _Tutorials: https://spacy.io/docs/usage/tutorials
.. _Showcase & Demos: https://spacy.io/docs/usage/showcase
2017-03-12 19:00:41 +00:00
.. _Contribute: https://github.com/explosion/spaCy/blob/master/CONTRIBUTING.md
2016-10-31 22:29:57 +00:00
💬 Where to ask questions
==========================
2016-10-15 22:51:31 +00:00
2017-11-07 19:45:34 +00:00
Please understand that we won't be able to provide individual support via email. We also believe that help is much more valuable if it's shared publicly, so that more people can benefit from it.
2017-10-24 19:39:18 +00:00
2017-03-12 19:00:41 +00:00
====================== ===
2017-11-07 19:45:34 +00:00
**Bug reports** `GitHub issue tracker`_
**Usage questions** `StackOverflow`_ , `Gitter chat`_ , `Reddit user group`_
**General discussion** `Gitter chat`_ , `Reddit user group`_
2017-03-12 19:00:41 +00:00
====================== ===
2017-11-07 19:45:34 +00:00
.. _GitHub issue tracker: https://github.com/explosion/spaCy/issues
2017-03-12 19:00:41 +00:00
.. _StackOverflow: http://stackoverflow.com/questions/tagged/spacy
2017-11-07 19:45:34 +00:00
.. _Gitter chat: https://gitter.im/explosion/spaCy
.. _Reddit user group: https://www.reddit.com/r/spacynlp
2016-10-15 22:51:31 +00:00
2016-05-04 14:26:16 +00:00
Features
2016-10-03 10:33:22 +00:00
========
2016-05-04 14:26:16 +00:00
2016-11-02 09:45:29 +00:00
* Non-destructive **tokenization**
2017-11-07 19:45:34 +00:00
* Syntax-driven sentence segmentation
* Pre-trained **word vectors**
2016-11-02 09:45:29 +00:00
* Part-of-speech tagging
2017-11-07 19:45:34 +00:00
* **Named entity** recognition
2016-11-02 09:45:29 +00:00
* Labelled dependency parsing
2017-11-07 19:45:34 +00:00
* Convenient string-to-int mapping
2016-05-04 14:26:16 +00:00
* Export to numpy data arrays
2017-11-07 19:45:34 +00:00
* GIL-free **multi-threading**
2016-11-02 09:45:29 +00:00
* Efficient binary serialization
2017-11-07 19:45:34 +00:00
* Easy **deep learning** integration
* Statistical models for **English** , **German** , **French** and **Spanish**
2016-11-02 09:45:29 +00:00
* State-of-the-art speed
* Robust, rigorously evaluated accuracy
2017-11-07 19:45:34 +00:00
See `facts, figures and benchmarks <https://spacy.io/docs/api/> `_ .
2016-05-04 14:26:16 +00:00
2017-11-07 19:45:34 +00:00
Top Performance
---------------
2016-05-04 14:26:16 +00:00
2017-11-07 19:45:34 +00:00
* Fastest in the world: <50ms per document. No faster system has ever been
announced.
* Accuracy within 1% of the current state-of-the-art on all tasks performed
(parsing, named entity recognition, part-of-speech tagging). The only more
accurate systems are an order of magnitude slower or more.
Supports
--------
2017-03-12 19:00:41 +00:00
==================== ===
**Operating system** macOS / OS X, Linux, Windows (Cygwin, MinGW, Visual Studio)
2017-03-26 23:07:21 +00:00
**Python version** CPython 2.6, 2.7, 3.3+. Only 64 bit.
2017-03-12 19:00:41 +00:00
**Package managers** `pip`_ (source packages only), `conda`_ (via `` conda-forge `` )
==================== ===
2016-05-04 14:26:16 +00:00
2017-03-12 19:00:41 +00:00
.. _pip: https://pypi.python.org/pypi/spacy
.. _conda: https://anaconda.org/conda-forge/spacy
2016-05-04 14:26:16 +00:00
2017-11-07 19:45:34 +00:00
Install spaCy
=============
Installation requires a working build environment. See notes on Ubuntu,
macOS/OS X and Windows for details.
2016-10-03 10:33:22 +00:00
pip
---
2017-03-08 10:36:00 +00:00
Using pip, spaCy releases are currently only available as source packages.
2016-10-03 10:33:22 +00:00
.. code :: bash
2017-11-07 19:45:34 +00:00
pip install -U spacy
2016-10-03 10:33:22 +00:00
2017-11-07 19:45:34 +00:00
When using pip it is generally recommended to install packages in a `` virtualenv ``
to avoid modifying system state:
2017-03-08 10:36:00 +00:00
.. code :: bash
2017-11-07 19:45:34 +00:00
virtualenv .env
2017-03-08 10:36:00 +00:00
source .env/bin/activate
pip install spacy
2016-10-03 10:33:22 +00:00
2017-03-03 18:15:56 +00:00
conda
-----
2017-03-08 10:36:00 +00:00
Thanks to our great community, we've finally re-added conda support. You can now
install spaCy via `` conda-forge `` :
2017-03-03 18:15:56 +00:00
.. code :: bash
2017-11-07 19:45:34 +00:00
conda config --add channels conda-forge
conda install spacy
2017-03-08 10:36:00 +00:00
2017-03-03 18:15:56 +00:00
For the feedstock including the build recipe and configuration,
check out `this repository <https://github.com/conda-forge/spacy-feedstock> `_ .
2017-03-08 10:36:00 +00:00
Improvements and pull requests to the recipe and setup are always appreciated.
2017-03-03 18:15:56 +00:00
2017-03-08 10:36:00 +00:00
Download models
===============
2016-10-03 10:33:22 +00:00
2017-03-18 16:56:05 +00:00
As of v1.7.0, models for spaCy can be installed as **Python packages** .
This means that they're a component of your application, just like any
2017-11-07 19:45:34 +00:00
other module. They're versioned and can be defined as a dependency in your
`` requirements.txt `` . Models can be installed from a download URL or
a local directory, manually or via pip. Their data can be located anywhere on
your file system. To make a model available to spaCy, all you need to do is
create a "shortcut link", an internal alias that tells spaCy where to find the
data files for a specific model name.
2017-03-18 16:56:05 +00:00
======================= ===
2017-11-07 19:45:34 +00:00
`spaCy Models`_ Available models, latest releases and direct download.
2017-03-18 16:56:05 +00:00
`Models Documentation`_ Detailed usage instructions.
======================= ===
2017-11-07 19:45:34 +00:00
.. _spaCy Models: https://github.com/explosion/spacy-models/releases/
2017-11-07 11:00:43 +00:00
.. _Models Documentation: https://spacy.io/docs/usage/models
2016-10-03 10:33:22 +00:00
.. code :: bash
2017-03-18 16:56:05 +00:00
# out-of-the-box: download best-matching default model
python -m spacy download en
2016-10-03 10:33:22 +00:00
2017-03-18 16:56:05 +00:00
# download best-matching version of specific model for your spaCy installation
2017-11-07 19:45:34 +00:00
python -m spacy download en_core_web_md
2016-10-03 10:33:22 +00:00
2017-03-18 16:56:05 +00:00
# pip install .tar.gz archive from path or URL
2017-11-07 19:45:34 +00:00
pip install /Users/you/en_core_web_md-1.2.0.tar.gz
pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_md-1.2.0/en_core_web_md-1.2.0.tar.gz
# set up shortcut link to load installed package as "en_default"
python -m spacy link en_core_web_md en_default
# set up shortcut link to load local model as "my_amazing_model"
python -m spacy link /Users/you/data my_amazing_model
2016-10-03 10:33:22 +00:00
2017-03-18 16:56:05 +00:00
Loading and using models
------------------------
2016-10-03 10:33:22 +00:00
2017-03-18 16:56:05 +00:00
To load a model, use `` spacy.load() `` with the model's shortcut link:
2016-10-03 10:33:22 +00:00
2017-03-18 16:56:05 +00:00
.. code :: python
2017-03-17 18:55:55 +00:00
2017-03-18 16:56:05 +00:00
import spacy
2017-11-07 19:45:34 +00:00
nlp = spacy.load('en_default')
2017-03-18 16:56:05 +00:00
doc = nlp(u'This is a sentence.')
2017-03-17 18:55:55 +00:00
2017-03-18 16:56:05 +00:00
If you've installed a model via pip, you can also `` import `` it directly and
2017-11-07 19:45:34 +00:00
then call its `` load() `` method with no arguments. This should also work for
older models in previous versions of spaCy.
2017-03-17 18:55:55 +00:00
2017-03-18 16:56:05 +00:00
.. code :: python
import spacy
2017-11-07 19:45:34 +00:00
import en_core_web_md
2017-03-18 16:56:05 +00:00
2017-11-07 19:45:34 +00:00
nlp = en_core_web_md.load()
2017-03-18 16:56:05 +00:00
doc = nlp(u'This is a sentence.')
2017-11-07 19:45:34 +00:00
📖 **For more info and examples, check out the** `models documentation <https://spacy.io/docs/usage/models> `_ .
2016-10-03 10:33:22 +00:00
2017-03-18 16:56:05 +00:00
Support for older versions
--------------------------
2017-03-08 10:36:00 +00:00
2017-11-07 19:45:34 +00:00
If you're using an older version (v1.6.0 or below), you can still download and
install the old models from within spaCy using `` python -m spacy.en.download all ``
2017-03-18 16:56:05 +00:00
or `` python -m spacy.de.download all `` . The `` .tar.gz `` archives are also
`attached to the v1.6.0 release <https://github.com/explosion/spaCy/tree/v1.6.0> `_ .
To download and install the models manually, unpack the archive, drop the
contained directory into `` spacy/data `` and load the model via `` spacy.load('en') ``
or `` spacy.load('de') `` .
2016-10-03 10:33:22 +00:00
Compile from source
===================
2017-03-08 10:36:00 +00:00
The other way to install spaCy is to clone its
`GitHub repository <https://github.com/explosion/spaCy> `_ and build it from
2016-10-03 10:33:22 +00:00
source. That is the common way if you want to make changes to the code base.
2017-11-07 19:45:34 +00:00
You'll need to make sure that you have a development enviroment consisting of a
2017-03-08 10:36:00 +00:00
Python distribution including header files, a compiler,
`pip <https://pip.pypa.io/en/latest/installing/> `__ , `virtualenv <https://virtualenv.pypa.io/> `_
and `git <https://git-scm.com> `_ installed. The compiler part is the trickiest.
How to do that depends on your system. See notes on Ubuntu, OS X and Windows for
details.
2016-10-03 10:33:22 +00:00
.. code :: bash
# make sure you are using recent pip/virtualenv versions
2017-11-07 19:45:34 +00:00
python -m pip install -U pip virtualenv
2017-03-08 10:37:04 +00:00
git clone https://github.com/explosion/spaCy
2016-10-03 10:33:22 +00:00
cd spaCy
2017-03-08 10:36:00 +00:00
2017-11-07 19:45:34 +00:00
virtualenv .env
2017-03-08 10:36:00 +00:00
source .env/bin/activate
2016-10-03 10:33:22 +00:00
pip install -r requirements.txt
2017-11-07 19:45:34 +00:00
pip install -e .
2017-03-08 10:36:00 +00:00
2017-11-07 19:45:34 +00:00
Compared to a regular install via pip, `requirements.txt <requirements.txt> `_
additionally installs developer dependencies such as Cython.
2017-11-04 13:24:14 +00:00
2017-03-08 10:36:00 +00:00
Instead of the above verbose commands, you can also use the following
2017-11-07 19:45:34 +00:00
`Fabric <http://www.fabfile.org/> `_ commands:
2017-03-08 10:36:00 +00:00
2017-03-12 19:03:15 +00:00
============= ===
2017-11-07 19:45:34 +00:00
`` fab env `` Create `` virtualenv `` and delete previous one, if it exists.
2017-03-12 19:03:15 +00:00
`` fab make `` Compile the source.
`` fab clean `` Remove compiled objects, including the generated C++.
`` fab test `` Run basic tests, aborting after first failure.
============= ===
2017-03-08 10:36:00 +00:00
2017-11-07 19:45:34 +00:00
All commands assume that your `` virtualenv `` is located in a directory `` .env `` .
If you're using a different directory, you can change it via the environment
variable `` VENV_DIR `` , for example:
.. code :: bash
VENV_DIR=".custom-env" fab clean make
2016-10-03 10:33:22 +00:00
Ubuntu
------
Install system-level dependencies via `` apt-get `` :
.. code :: bash
sudo apt-get install build-essential python-dev git
2016-10-31 22:36:34 +00:00
macOS / OS X
------------
2016-10-03 10:33:22 +00:00
2017-03-08 10:36:00 +00:00
Install a recent version of `XCode <https://developer.apple.com/xcode/> `_ ,
including the so-called "Command Line Tools". macOS and OS X ship with Python
2016-10-31 22:36:34 +00:00
and git preinstalled.
2016-10-03 10:33:22 +00:00
Windows
-------
2016-05-09 10:57:07 +00:00
2016-10-31 22:36:34 +00:00
Install a version of `Visual Studio Express <https://www.visualstudio.com/vs/visual-studio-express/> `_
2017-03-08 10:36:00 +00:00
or higher that matches the version that was used to compile your Python
interpreter. For official distributions these are VS 2008 (Python 2.7),
2016-10-31 22:36:34 +00:00
VS 2010 (Python 3.4) and VS 2015 (Python 3.5).
2016-10-22 11:28:27 +00:00
2016-10-03 10:33:22 +00:00
Run tests
=========
2017-03-08 10:36:00 +00:00
spaCy comes with an `extensive test suite <spacy/tests> `_ . First, find out where
spaCy is installed:
2016-10-03 10:33:22 +00:00
.. code :: bash
2017-03-08 10:36:00 +00:00
2016-10-03 10:33:22 +00:00
python -c "import os; import spacy; print(os.path.dirname(spacy.__file__))"
2017-03-08 10:36:00 +00:00
Then run `` pytest `` on that directory. The flags `` --vectors `` , `` --slow ``
2016-10-03 10:33:22 +00:00
and `` --model `` are optional and enable additional tests:
.. code :: bash
2017-03-08 10:36:00 +00:00
2016-10-03 10:33:22 +00:00
# make sure you are using recent pytest version
python -m pip install -U pytest
2017-11-07 19:45:34 +00:00
python -m pytest <spacy-directory> --vectors --models --slow
🛠 Changelog
============
=========== ============== ===========
Version Date Description
=========== ============== ===========
`v1.10.0`_ `` 2017-11-07 `` Alpha support for Thai & Russian, plus improvements and bug fixes
`v1.9.0`_ `` 2017-07-22 `` Spanish model, alpha support for Norwegian & Japanese, and bug fixes
`v1.8.2`_ `` 2017-04-26 `` French model and small improvements
`v1.8.1`_ `` 2017-04-23 `` Saving, loading and training bug fixes
`v1.8.0`_ `` 2017-04-16 `` Better NER training, saving and loading
`v1.7.5`_ `` 2017-04-07 `` Bug fixes and new CLI commands
`v1.7.3`_ `` 2017-03-26 `` Alpha support for Hebrew, new CLI commands and bug fixes
`v1.7.2`_ `` 2017-03-20 `` Small fixes to beam parser and model linking
`v1.7.1`_ `` 2017-03-19 `` Fix data download for system installation
`v1.7.0`_ `` 2017-03-18 `` New 50 MB model, CLI, better downloads and lots of bug fixes
`v1.6.0`_ `` 2017-01-16 `` Improvements to tokenizer and tests
`v1.5.0`_ `` 2016-12-27 `` Alpha support for Swedish and Hungarian
`v1.4.0`_ `` 2016-12-18 `` Improved language data and alpha Dutch support
`v1.3.0`_ `` 2016-12-03 `` Improve API consistency
`v1.2.0`_ `` 2016-11-04 `` Alpha tokenizers for Chinese, French, Spanish, Italian and Portuguese
`v1.1.0`_ `` 2016-10-23 `` Bug fixes and adjustments
`v1.0.0`_ `` 2016-10-18 `` Support for deep learning workflows and entity-aware rule matcher
`v0.101.0`_ `` 2016-05-10 `` Fixed German model
`v0.100.7`_ `` 2016-05-05 `` German support
`v0.100.6`_ `` 2016-03-08 `` Add support for GloVe vectors
`v0.100.5`_ `` 2016-02-07 `` Fix incorrect use of header file
`v0.100.4`_ `` 2016-02-07 `` Fix OSX problem introduced in 0.100.3
`v0.100.3`_ `` 2016-02-06 `` Multi-threading, faster loading and bugfixes
`v0.100.2`_ `` 2016-01-21 `` Fix data version lock
`v0.100.1`_ `` 2016-01-21 `` Fix install for OSX
`v0.100`_ `` 2016-01-19 `` Revise setup.py, better model downloads, bug fixes
`v0.99`_ `` 2015-11-08 `` Improve span merging, internal refactoring
`v0.98`_ `` 2015-11-03 `` Smaller package, bug fixes
`v0.97`_ `` 2015-10-23 `` Load the StringStore from a json list, instead of a text file
`v0.96`_ `` 2015-10-19 `` Hotfix to .merge method
`v0.95`_ `` 2015-10-18 `` Bug fixes
`v0.94`_ `` 2015-10-09 `` Fix memory and parse errors
`v0.93`_ `` 2015-09-22 `` Bug fixes to word vectors
=========== ============== ===========
.. _v1.10.0: https://github.com/explosion/spaCy/releases/tag/v1.10.0
.. _v1.9.0: https://github.com/explosion/spaCy/releases/tag/v1.9.0
.. _v1.8.2: https://github.com/explosion/spaCy/releases/tag/v1.8.2
.. _v1.8.1: https://github.com/explosion/spaCy/releases/tag/v1.8.1
.. _v1.8.0: https://github.com/explosion/spaCy/releases/tag/v1.8.0
.. _v1.7.5: https://github.com/explosion/spaCy/releases/tag/v1.7.5
.. _v1.7.3: https://github.com/explosion/spaCy/releases/tag/v1.7.3
.. _v1.7.2: https://github.com/explosion/spaCy/releases/tag/v1.7.2
.. _v1.7.1: https://github.com/explosion/spaCy/releases/tag/v1.7.1
.. _v1.7.0: https://github.com/explosion/spaCy/releases/tag/v1.7.0
.. _v1.6.0: https://github.com/explosion/spaCy/releases/tag/v1.6.0
.. _v1.5.0: https://github.com/explosion/spaCy/releases/tag/v1.5.0
.. _v1.4.0: https://github.com/explosion/spaCy/releases/tag/v1.4.0
.. _v1.3.0: https://github.com/explosion/spaCy/releases/tag/v1.3.0
.. _v1.2.0: https://github.com/explosion/spaCy/releases/tag/v1.2.0
.. _v1.1.0: https://github.com/explosion/spaCy/releases/tag/v1.1.0
.. _v1.0.0: https://github.com/explosion/spaCy/releases/tag/v1.0.0
.. _v0.101.0: https://github.com/explosion/spaCy/releases/tag/0.101.0
.. _v0.100.7: https://github.com/explosion/spaCy/releases/tag/0.100.7
.. _v0.100.6: https://github.com/explosion/spaCy/releases/tag/0.100.6
.. _v0.100.5: https://github.com/explosion/spaCy/releases/tag/0.100.5
.. _v0.100.4: https://github.com/explosion/spaCy/releases/tag/0.100.4
.. _v0.100.3: https://github.com/explosion/spaCy/releases/tag/0.100.3
.. _v0.100.2: https://github.com/explosion/spaCy/releases/tag/0.100.2
.. _v0.100.1: https://github.com/explosion/spaCy/releases/tag/0.100.1
.. _v0.100: https://github.com/explosion/spaCy/releases/tag/0.100
.. _v0.99: https://github.com/explosion/spaCy/releases/tag/0.99
.. _v0.98: https://github.com/explosion/spaCy/releases/tag/0.98
.. _v0.97: https://github.com/explosion/spaCy/releases/tag/0.97
.. _v0.96: https://github.com/explosion/spaCy/releases/tag/0.96
.. _v0.95: https://github.com/explosion/spaCy/releases/tag/0.95
.. _v0.94: https://github.com/explosion/spaCy/releases/tag/0.94
.. _v0.93: https://github.com/explosion/spaCy/releases/tag/0.93