Repository files navigation

spaCy: Industrial-strength NLP

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, Chinese and Japanese. It's commercial open-source software, released under the MIT license.

⭐️ Test spaCy v2.0.0 alpha and the new models!Read the release notes here.

πŸ’« Version 1.8 out now!Read the release notes here.

Travis Build StatusAppveyor Build StatusCurrent Release Versionpypi Versionconda VersionspaCy on GitterspaCy on Twitter

πŸ“– Documentation

Usage WorkflowsHow to use spaCy and its features.
API ReferenceThe detailed reference for spaCy's API.
TroubleshootingCommon problems and solutions for beginners.
TutorialsEnd-to-end examples, with code you can modify and run.
Showcase & DemosDemos, libraries and products from the spaCy community.
ContributeHow to contribute to the spaCy project and code base.

πŸ’¬ Where to ask questions

Bug reportsGitHub issue tracker
Usage questionsStackOverflow, Gitter chat, Reddit user group
General discussionGitter chat, Reddit user group
Commercial supportcontact@explosion.ai

Features

  • Non-destructive tokenization
  • Syntax-driven sentence segmentation
  • Pre-trained word vectors
  • Part-of-speech tagging
  • Named entity recognition
  • Labelled dependency parsing
  • Convenient string-to-int mapping
  • Export to numpy data arrays
  • GIL-free multi-threading
  • Efficient binary serialization
  • Easy deep learning integration
  • Statistical models for English, German, French and Spanish
  • State-of-the-art speed
  • Robust, rigorously evaluated accuracy

See facts, figures and benchmarks.

Top Performance

  • 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

Operating systemmacOS / OS X, Linux, Windows (Cygwin, MinGW, Visual Studio)
Python versionCPython 2.6, 2.7, 3.3+. Only 64 bit.
Package managerspip (source packages only), conda (via conda-forge)

Install spaCy

Installation requires a working build environment. See notes on Ubuntu, macOS/OS X and Windows for details.

pip

Using pip, spaCy releases are currently only available as source packages.

pip install -U spacy

When using pip it is generally recommended to install packages in a virtualenv to avoid modifying system state:

virtualenv .env
source .env/bin/activate
pip install spacy

conda

Thanks to our great community, we've finally re-added conda support. You can now install spaCy via conda-forge:

conda config --add channels conda-forge
conda install spacy

For the feedstock including the build recipe and configuration, check out this repository. Improvements and pull requests to the recipe and setup are always appreciated.

Download models

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 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.

spaCy ModelsAvailable models, latest releases and direct download.
Models DocumentationDetailed usage instructions.
# out-of-the-box: download best-matching default model
python -m spacy download en
# download best-matching version of specific model for your spaCy installation
python -m spacy download en_core_web_md
# pip install .tar.gz archive from path or URL
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

Loading and using models

To load a model, use spacy.load() with the model's shortcut link:

importspacynlp=spacy.load('en_default')
doc=nlp(u'This is a sentence.')

If you've installed a model via pip, you can also import it directly and then call its load() method with no arguments. This should also work for older models in previous versions of spaCy.

importspacyimporten_core_web_mdnlp=en_core_web_md.load()
doc=nlp(u'This is a sentence.')

πŸ“– For more info and examples, check out themodels documentation.

Support for older versions

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 or python -m spacy.de.download all. The .tar.gz archives are also attached to the v1.6.0 release. 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').

Compile from source

The other way to install spaCy is to clone its GitHub repository and build it from source. That is the common way if you want to make changes to the code base. You'll need to make sure that you have a development enviroment consisting of a Python distribution including header files, a compiler, pip, virtualenv and git 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.

# make sure you are using recent pip/virtualenv versions
python -m pip install -U pip virtualenv
git clone https://github.com/explosion/spaCy
cd spaCy
virtualenv .env
source .env/bin/activate
pip install -r requirements.txt
pip install -e .

Compared to regular install via pip requirements.txt additionally installs developer dependencies such as Cython.

Instead of the above verbose commands, you can also use the following Fabric commands:

fab envCreate virtualenv and delete previous one, if it exists.
fab makeCompile the source.
fab cleanRemove compiled objects, including the generated C++.
fab testRun basic tests, aborting after first failure.

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:

VENV_DIR=".custom-env" fab clean make

Ubuntu

Install system-level dependencies via apt-get:

sudo apt-get install build-essential python-dev git

macOS / OS X

Install a recent version of XCode, including the so-called "Command Line Tools". macOS and OS X ship with Python and git preinstalled.

Windows

Install a version of Visual Studio Express or higher that matches the version that was used to compile your Python interpreter. For official distributions these are VS 2008 (Python 2.7), VS 2010 (Python 3.4) and VS 2015 (Python 3.5).

Run tests

spaCy comes with an extensive test suite. First, find out where spaCy is installed:

python -c "import os; import spacy; print(os.path.dirname(spacy.__file__))"

Then run pytest on that directory. The flags --vectors, --slow and --model are optional and enable additional tests:

# make sure you are using recent pytest version
python -m pip install -U pytest
python -m pytest <spacy-directory> --vectors --models --slow

πŸ›  Changelog

VersionDateDescription
v1.8.22017-04-26French model and small improvements
v1.8.12017-04-23Saving, loading and training bug fixes
v1.8.02017-04-16Better NER training, saving and loading
v1.7.52017-04-07Bug fixes and new CLI commands
v1.7.32017-03-26Alpha support for Hebrew, new CLI commands and bug fixes
v1.7.22017-03-20Small fixes to beam parser and model linking
v1.7.12017-03-19Fix data download for system installation
v1.7.02017-03-18New 50 MB model, CLI, better downloads and lots of bug fixes
v1.6.02017-01-16Improvements to tokenizer and tests
v1.5.02016-12-27Alpha support for Swedish and Hungarian
v1.4.02016-12-18Improved language data and alpha Dutch support
v1.3.02016-12-03Improve API consistency
v1.2.02016-11-04Alpha tokenizers for Chinese, French, Spanish, Italian and Portuguese
v1.1.02016-10-23Bug fixes and adjustments
v1.0.02016-10-18Support for deep learning workflows and entity-aware rule matcher
v0.101.02016-05-10Fixed German model
v0.100.72016-05-05German support
v0.100.62016-03-08Add support for GloVe vectors
v0.100.52016-02-07Fix incorrect use of header file
v0.100.42016-02-07Fix OSX problem introduced in 0.100.3
v0.100.32016-02-06Multi-threading, faster loading and bugfixes
v0.100.22016-01-21Fix data version lock
v0.100.12016-01-21Fix install for OSX
v0.1002016-01-19Revise setup.py, better model downloads, bug fixes
v0.992015-11-08Improve span merging, internal refactoring
v0.982015-11-03Smaller package, bug fixes
v0.972015-10-23Load the StringStore from a json list, instead of a text file
v0.962015-10-19Hotfix to .merge method
v0.952015-10-18Bug fixes
v0.942015-10-09Fix memory and parse errors
v0.932015-09-22Bug fixes to word vectors

About

πŸ’« Industrial-strength Natural Language Processing (NLP) with Python and Cython

Resources

Contributing

Stars

0 stars

Watchers

9 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

spaCy: Industrial-strength NLP

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, Chinese and Japanese. It's commercial open-source software, released under the MIT license.

⭐️ Test spaCy v2.0.0 alpha and the new models!Read the release notes here.

πŸ’« Version 1.8 out now!Read the release notes here.

Travis Build StatusAppveyor Build StatusCurrent Release Versionpypi Versionconda VersionspaCy on GitterspaCy on Twitter

πŸ“– Documentation

Usage WorkflowsHow to use spaCy and its features.
API ReferenceThe detailed reference for spaCy's API.
TroubleshootingCommon problems and solutions for beginners.
TutorialsEnd-to-end examples, with code you can modify and run.
Showcase & DemosDemos, libraries and products from the spaCy community.
ContributeHow to contribute to the spaCy project and code base.

πŸ’¬ Where to ask questions

Bug reportsGitHub issue tracker
Usage questionsStackOverflow, Gitter chat, Reddit user group
General discussionGitter chat, Reddit user group
Commercial supportcontact@explosion.ai

Features

  • Non-destructive tokenization
  • Syntax-driven sentence segmentation
  • Pre-trained word vectors
  • Part-of-speech tagging
  • Named entity recognition
  • Labelled dependency parsing
  • Convenient string-to-int mapping
  • Export to numpy data arrays
  • GIL-free multi-threading
  • Efficient binary serialization
  • Easy deep learning integration
  • Statistical models for English, German, French and Spanish
  • State-of-the-art speed
  • Robust, rigorously evaluated accuracy

See facts, figures and benchmarks.

Top Performance

  • 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

Operating systemmacOS / OS X, Linux, Windows (Cygwin, MinGW, Visual Studio)
Python versionCPython 2.6, 2.7, 3.3+. Only 64 bit.
Package managerspip (source packages only), conda (via conda-forge)

Install spaCy

Installation requires a working build environment. See notes on Ubuntu, macOS/OS X and Windows for details.

pip

Using pip, spaCy releases are currently only available as source packages.

pip install -U spacy

When using pip it is generally recommended to install packages in a virtualenv to avoid modifying system state:

virtualenv .env
source .env/bin/activate
pip install spacy

conda

Thanks to our great community, we've finally re-added conda support. You can now install spaCy via conda-forge:

conda config --add channels conda-forge
conda install spacy

For the feedstock including the build recipe and configuration, check out this repository. Improvements and pull requests to the recipe and setup are always appreciated.

Download models

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 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.

spaCy ModelsAvailable models, latest releases and direct download.
Models DocumentationDetailed usage instructions.
# out-of-the-box: download best-matching default model
python -m spacy download en
# download best-matching version of specific model for your spaCy installation
python -m spacy download en_core_web_md
# pip install .tar.gz archive from path or URL
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

Loading and using models

To load a model, use spacy.load() with the model's shortcut link:

importspacynlp=spacy.load('en_default')
doc=nlp(u'This is a sentence.')

If you've installed a model via pip, you can also import it directly and then call its load() method with no arguments. This should also work for older models in previous versions of spaCy.

importspacyimporten_core_web_mdnlp=en_core_web_md.load()
doc=nlp(u'This is a sentence.')

πŸ“– For more info and examples, check out themodels documentation.

Support for older versions

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 or python -m spacy.de.download all. The .tar.gz archives are also attached to the v1.6.0 release. 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').

Compile from source

The other way to install spaCy is to clone its GitHub repository and build it from source. That is the common way if you want to make changes to the code base. You'll need to make sure that you have a development enviroment consisting of a Python distribution including header files, a compiler, pip, virtualenv and git 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.

# make sure you are using recent pip/virtualenv versions
python -m pip install -U pip virtualenv
git clone https://github.com/explosion/spaCy
cd spaCy
virtualenv .env
source .env/bin/activate
pip install -r requirements.txt
pip install -e .

Compared to regular install via pip requirements.txt additionally installs developer dependencies such as Cython.

Instead of the above verbose commands, you can also use the following Fabric commands:

fab envCreate virtualenv and delete previous one, if it exists.
fab makeCompile the source.
fab cleanRemove compiled objects, including the generated C++.
fab testRun basic tests, aborting after first failure.

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:

VENV_DIR=".custom-env" fab clean make

Ubuntu

Install system-level dependencies via apt-get:

sudo apt-get install build-essential python-dev git

macOS / OS X

Install a recent version of XCode, including the so-called "Command Line Tools". macOS and OS X ship with Python and git preinstalled.

Windows

Install a version of Visual Studio Express or higher that matches the version that was used to compile your Python interpreter. For official distributions these are VS 2008 (Python 2.7), VS 2010 (Python 3.4) and VS 2015 (Python 3.5).

Run tests

spaCy comes with an extensive test suite. First, find out where spaCy is installed:

python -c "import os; import spacy; print(os.path.dirname(spacy.__file__))"

Then run pytest on that directory. The flags --vectors, --slow and --model are optional and enable additional tests:

# make sure you are using recent pytest version
python -m pip install -U pytest
python -m pytest <spacy-directory> --vectors --models --slow

πŸ›  Changelog

VersionDateDescription
v1.8.22017-04-26French model and small improvements
v1.8.12017-04-23Saving, loading and training bug fixes
v1.8.02017-04-16Better NER training, saving and loading
v1.7.52017-04-07Bug fixes and new CLI commands
v1.7.32017-03-26Alpha support for Hebrew, new CLI commands and bug fixes
v1.7.22017-03-20Small fixes to beam parser and model linking
v1.7.12017-03-19Fix data download for system installation
v1.7.02017-03-18New 50 MB model, CLI, better downloads and lots of bug fixes
v1.6.02017-01-16Improvements to tokenizer and tests
v1.5.02016-12-27Alpha support for Swedish and Hungarian
v1.4.02016-12-18Improved language data and alpha Dutch support
v1.3.02016-12-03Improve API consistency
v1.2.02016-11-04Alpha tokenizers for Chinese, French, Spanish, Italian and Portuguese
v1.1.02016-10-23Bug fixes and adjustments
v1.0.02016-10-18Support for deep learning workflows and entity-aware rule matcher
v0.101.02016-05-10Fixed German model
v0.100.72016-05-05German support
v0.100.62016-03-08Add support for GloVe vectors
v0.100.52016-02-07Fix incorrect use of header file
v0.100.42016-02-07Fix OSX problem introduced in 0.100.3
v0.100.32016-02-06Multi-threading, faster loading and bugfixes
v0.100.22016-01-21Fix data version lock
v0.100.12016-01-21Fix install for OSX
v0.1002016-01-19Revise setup.py, better model downloads, bug fixes
v0.992015-11-08Improve span merging, internal refactoring
v0.982015-11-03Smaller package, bug fixes
v0.972015-10-23Load the StringStore from a json list, instead of a text file
v0.962015-10-19Hotfix to .merge method
v0.952015-10-18Bug fixes
v0.942015-10-09Fix memory and parse errors
v0.932015-09-22Bug fixes to word vectors

About

πŸ’« Industrial-strength Natural Language Processing (NLP) with Python and Cython

Resources

Contributing

Stars

0 stars

Watchers

9 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

spaCy: Industrial-strength NLP

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, Chinese and Japanese. It's commercial open-source software, released under the MIT license.

⭐️ Test spaCy v2.0.0 alpha and the new models!Read the release notes here.

πŸ’« Version 1.8 out now!Read the release notes here.

Travis Build StatusAppveyor Build StatusCurrent Release Versionpypi Versionconda VersionspaCy on GitterspaCy on Twitter

πŸ“– Documentation

Usage WorkflowsHow to use spaCy and its features.
API ReferenceThe detailed reference for spaCy's API.
TroubleshootingCommon problems and solutions for beginners.
TutorialsEnd-to-end examples, with code you can modify and run.
Showcase & DemosDemos, libraries and products from the spaCy community.
ContributeHow to contribute to the spaCy project and code base.

πŸ’¬ Where to ask questions

Bug reportsGitHub issue tracker
Usage questionsStackOverflow, Gitter chat, Reddit user group
General discussionGitter chat, Reddit user group
Commercial supportcontact@explosion.ai

Features

  • Non-destructive tokenization
  • Syntax-driven sentence segmentation
  • Pre-trained word vectors
  • Part-of-speech tagging
  • Named entity recognition
  • Labelled dependency parsing
  • Convenient string-to-int mapping
  • Export to numpy data arrays
  • GIL-free multi-threading
  • Efficient binary serialization
  • Easy deep learning integration
  • Statistical models for English, German, French and Spanish
  • State-of-the-art speed
  • Robust, rigorously evaluated accuracy

See facts, figures and benchmarks.

Top Performance

  • 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

Operating systemmacOS / OS X, Linux, Windows (Cygwin, MinGW, Visual Studio)
Python versionCPython 2.6, 2.7, 3.3+. Only 64 bit.
Package managerspip (source packages only), conda (via conda-forge)

Install spaCy

Installation requires a working build environment. See notes on Ubuntu, macOS/OS X and Windows for details.

pip

Using pip, spaCy releases are currently only available as source packages.

pip install -U spacy

When using pip it is generally recommended to install packages in a virtualenv to avoid modifying system state:

virtualenv .env
source .env/bin/activate
pip install spacy

conda

Thanks to our great community, we've finally re-added conda support. You can now install spaCy via conda-forge:

conda config --add channels conda-forge
conda install spacy

For the feedstock including the build recipe and configuration, check out this repository. Improvements and pull requests to the recipe and setup are always appreciated.

Download models

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 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.

spaCy ModelsAvailable models, latest releases and direct download.
Models DocumentationDetailed usage instructions.
# out-of-the-box: download best-matching default model
python -m spacy download en
# download best-matching version of specific model for your spaCy installation
python -m spacy download en_core_web_md
# pip install .tar.gz archive from path or URL
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

Loading and using models

To load a model, use spacy.load() with the model's shortcut link:

importspacynlp=spacy.load('en_default')
doc=nlp(u'This is a sentence.')

If you've installed a model via pip, you can also import it directly and then call its load() method with no arguments. This should also work for older models in previous versions of spaCy.

importspacyimporten_core_web_mdnlp=en_core_web_md.load()
doc=nlp(u'This is a sentence.')

πŸ“– For more info and examples, check out themodels documentation.

Support for older versions

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 or python -m spacy.de.download all. The .tar.gz archives are also attached to the v1.6.0 release. 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').

Compile from source

The other way to install spaCy is to clone its GitHub repository and build it from source. That is the common way if you want to make changes to the code base. You'll need to make sure that you have a development enviroment consisting of a Python distribution including header files, a compiler, pip, virtualenv and git 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.

# make sure you are using recent pip/virtualenv versions
python -m pip install -U pip virtualenv
git clone https://github.com/explosion/spaCy
cd spaCy
virtualenv .env
source .env/bin/activate
pip install -r requirements.txt
pip install -e .

Compared to regular install via pip requirements.txt additionally installs developer dependencies such as Cython.

Instead of the above verbose commands, you can also use the following Fabric commands:

fab envCreate virtualenv and delete previous one, if it exists.
fab makeCompile the source.
fab cleanRemove compiled objects, including the generated C++.
fab testRun basic tests, aborting after first failure.

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:

VENV_DIR=".custom-env" fab clean make

Ubuntu

Install system-level dependencies via apt-get:

sudo apt-get install build-essential python-dev git

macOS / OS X

Install a recent version of XCode, including the so-called "Command Line Tools". macOS and OS X ship with Python and git preinstalled.

Windows

Install a version of Visual Studio Express or higher that matches the version that was used to compile your Python interpreter. For official distributions these are VS 2008 (Python 2.7), VS 2010 (Python 3.4) and VS 2015 (Python 3.5).

Run tests

spaCy comes with an extensive test suite. First, find out where spaCy is installed:

python -c "import os; import spacy; print(os.path.dirname(spacy.__file__))"

Then run pytest on that directory. The flags --vectors, --slow and --model are optional and enable additional tests:

# make sure you are using recent pytest version
python -m pip install -U pytest
python -m pytest <spacy-directory> --vectors --models --slow

πŸ›  Changelog

VersionDateDescription
v1.8.22017-04-26French model and small improvements
v1.8.12017-04-23Saving, loading and training bug fixes
v1.8.02017-04-16Better NER training, saving and loading
v1.7.52017-04-07Bug fixes and new CLI commands
v1.7.32017-03-26Alpha support for Hebrew, new CLI commands and bug fixes
v1.7.22017-03-20Small fixes to beam parser and model linking
v1.7.12017-03-19Fix data download for system installation
v1.7.02017-03-18New 50 MB model, CLI, better downloads and lots of bug fixes
v1.6.02017-01-16Improvements to tokenizer and tests
v1.5.02016-12-27Alpha support for Swedish and Hungarian
v1.4.02016-12-18Improved language data and alpha Dutch support
v1.3.02016-12-03Improve API consistency
v1.2.02016-11-04Alpha tokenizers for Chinese, French, Spanish, Italian and Portuguese
v1.1.02016-10-23Bug fixes and adjustments
v1.0.02016-10-18Support for deep learning workflows and entity-aware rule matcher
v0.101.02016-05-10Fixed German model
v0.100.72016-05-05German support
v0.100.62016-03-08Add support for GloVe vectors
v0.100.52016-02-07Fix incorrect use of header file
v0.100.42016-02-07Fix OSX problem introduced in 0.100.3
v0.100.32016-02-06Multi-threading, faster loading and bugfixes
v0.100.22016-01-21Fix data version lock
v0.100.12016-01-21Fix install for OSX
v0.1002016-01-19Revise setup.py, better model downloads, bug fixes
v0.992015-11-08Improve span merging, internal refactoring
v0.982015-11-03Smaller package, bug fixes
v0.972015-10-23Load the StringStore from a json list, instead of a text file
v0.962015-10-19Hotfix to .merge method
v0.952015-10-18Bug fixes
v0.942015-10-09Fix memory and parse errors
v0.932015-09-22Bug fixes to word vectors

About

πŸ’« Industrial-strength Natural Language Processing (NLP) with Python and Cython

Resources

Contributing

Stars

0 stars

Watchers

9 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

spaCy: Industrial-strength NLP

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, Chinese and Japanese. It's commercial open-source software, released under the MIT license.

⭐️ Test spaCy v2.0.0 alpha and the new models!Read the release notes here.

πŸ’« Version 1.8 out now!Read the release notes here.

Travis Build StatusAppveyor Build StatusCurrent Release Versionpypi Versionconda VersionspaCy on GitterspaCy on Twitter

πŸ“– Documentation

Usage WorkflowsHow to use spaCy and its features.
API ReferenceThe detailed reference for spaCy's API.
TroubleshootingCommon problems and solutions for beginners.
TutorialsEnd-to-end examples, with code you can modify and run.
Showcase & DemosDemos, libraries and products from the spaCy community.
ContributeHow to contribute to the spaCy project and code base.

πŸ’¬ Where to ask questions

Bug reportsGitHub issue tracker
Usage questionsStackOverflow, Gitter chat, Reddit user group
General discussionGitter chat, Reddit user group
Commercial supportcontact@explosion.ai

Features

  • Non-destructive tokenization
  • Syntax-driven sentence segmentation
  • Pre-trained word vectors
  • Part-of-speech tagging
  • Named entity recognition
  • Labelled dependency parsing
  • Convenient string-to-int mapping
  • Export to numpy data arrays
  • GIL-free multi-threading
  • Efficient binary serialization
  • Easy deep learning integration
  • Statistical models for English, German, French and Spanish
  • State-of-the-art speed
  • Robust, rigorously evaluated accuracy

See facts, figures and benchmarks.

Top Performance

  • 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

Operating systemmacOS / OS X, Linux, Windows (Cygwin, MinGW, Visual Studio)
Python versionCPython 2.6, 2.7, 3.3+. Only 64 bit.
Package managerspip (source packages only), conda (via conda-forge)

Install spaCy

Installation requires a working build environment. See notes on Ubuntu, macOS/OS X and Windows for details.

pip

Using pip, spaCy releases are currently only available as source packages.

pip install -U spacy

When using pip it is generally recommended to install packages in a virtualenv to avoid modifying system state:

virtualenv .env
source .env/bin/activate
pip install spacy

conda

Thanks to our great community, we've finally re-added conda support. You can now install spaCy via conda-forge:

conda config --add channels conda-forge
conda install spacy

For the feedstock including the build recipe and configuration, check out this repository. Improvements and pull requests to the recipe and setup are always appreciated.

Download models

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 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.

spaCy ModelsAvailable models, latest releases and direct download.
Models DocumentationDetailed usage instructions.
# out-of-the-box: download best-matching default model
python -m spacy download en
# download best-matching version of specific model for your spaCy installation
python -m spacy download en_core_web_md
# pip install .tar.gz archive from path or URL
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

Loading and using models

To load a model, use spacy.load() with the model's shortcut link:

importspacynlp=spacy.load('en_default')
doc=nlp(u'This is a sentence.')

If you've installed a model via pip, you can also import it directly and then call its load() method with no arguments. This should also work for older models in previous versions of spaCy.

importspacyimporten_core_web_mdnlp=en_core_web_md.load()
doc=nlp(u'This is a sentence.')

πŸ“– For more info and examples, check out themodels documentation.

Support for older versions

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 or python -m spacy.de.download all. The .tar.gz archives are also attached to the v1.6.0 release. 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').

Compile from source

The other way to install spaCy is to clone its GitHub repository and build it from source. That is the common way if you want to make changes to the code base. You'll need to make sure that you have a development enviroment consisting of a Python distribution including header files, a compiler, pip, virtualenv and git 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.

# make sure you are using recent pip/virtualenv versions
python -m pip install -U pip virtualenv
git clone https://github.com/explosion/spaCy
cd spaCy
virtualenv .env
source .env/bin/activate
pip install -r requirements.txt
pip install -e .

Compared to regular install via pip requirements.txt additionally installs developer dependencies such as Cython.

Instead of the above verbose commands, you can also use the following Fabric commands:

fab envCreate virtualenv and delete previous one, if it exists.
fab makeCompile the source.
fab cleanRemove compiled objects, including the generated C++.
fab testRun basic tests, aborting after first failure.

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:

VENV_DIR=".custom-env" fab clean make

Ubuntu

Install system-level dependencies via apt-get:

sudo apt-get install build-essential python-dev git

macOS / OS X

Install a recent version of XCode, including the so-called "Command Line Tools". macOS and OS X ship with Python and git preinstalled.

Windows

Install a version of Visual Studio Express or higher that matches the version that was used to compile your Python interpreter. For official distributions these are VS 2008 (Python 2.7), VS 2010 (Python 3.4) and VS 2015 (Python 3.5).

Run tests

spaCy comes with an extensive test suite. First, find out where spaCy is installed:

python -c "import os; import spacy; print(os.path.dirname(spacy.__file__))"

Then run pytest on that directory. The flags --vectors, --slow and --model are optional and enable additional tests:

# make sure you are using recent pytest version
python -m pip install -U pytest
python -m pytest <spacy-directory> --vectors --models --slow

πŸ›  Changelog

VersionDateDescription
v1.8.22017-04-26French model and small improvements
v1.8.12017-04-23Saving, loading and training bug fixes
v1.8.02017-04-16Better NER training, saving and loading
v1.7.52017-04-07Bug fixes and new CLI commands
v1.7.32017-03-26Alpha support for Hebrew, new CLI commands and bug fixes
v1.7.22017-03-20Small fixes to beam parser and model linking
v1.7.12017-03-19Fix data download for system installation
v1.7.02017-03-18New 50 MB model, CLI, better downloads and lots of bug fixes
v1.6.02017-01-16Improvements to tokenizer and tests
v1.5.02016-12-27Alpha support for Swedish and Hungarian
v1.4.02016-12-18Improved language data and alpha Dutch support
v1.3.02016-12-03Improve API consistency
v1.2.02016-11-04Alpha tokenizers for Chinese, French, Spanish, Italian and Portuguese
v1.1.02016-10-23Bug fixes and adjustments
v1.0.02016-10-18Support for deep learning workflows and entity-aware rule matcher
v0.101.02016-05-10Fixed German model
v0.100.72016-05-05German support
v0.100.62016-03-08Add support for GloVe vectors
v0.100.52016-02-07Fix incorrect use of header file
v0.100.42016-02-07Fix OSX problem introduced in 0.100.3
v0.100.32016-02-06Multi-threading, faster loading and bugfixes
v0.100.22016-01-21Fix data version lock
v0.100.12016-01-21Fix install for OSX
v0.1002016-01-19Revise setup.py, better model downloads, bug fixes
v0.992015-11-08Improve span merging, internal refactoring
v0.982015-11-03Smaller package, bug fixes
v0.972015-10-23Load the StringStore from a json list, instead of a text file
v0.962015-10-19Hotfix to .merge method
v0.952015-10-18Bug fixes
v0.942015-10-09Fix memory and parse errors
v0.932015-09-22Bug fixes to word vectors

About

πŸ’« Industrial-strength Natural Language Processing (NLP) with Python and Cython

Resources

Contributing

Stars

0 stars

Watchers

9 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

spaCy: Industrial-strength NLP

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, Chinese and Japanese. It's commercial open-source software, released under the MIT license.

⭐️ Test spaCy v2.0.0 alpha and the new models!Read the release notes here.

πŸ’« Version 1.8 out now!Read the release notes here.

Travis Build StatusAppveyor Build StatusCurrent Release Versionpypi Versionconda VersionspaCy on GitterspaCy on Twitter

πŸ“– Documentation

Usage WorkflowsHow to use spaCy and its features.
API ReferenceThe detailed reference for spaCy's API.
TroubleshootingCommon problems and solutions for beginners.
TutorialsEnd-to-end examples, with code you can modify and run.
Showcase & DemosDemos, libraries and products from the spaCy community.
ContributeHow to contribute to the spaCy project and code base.

πŸ’¬ Where to ask questions

Bug reportsGitHub issue tracker
Usage questionsStackOverflow, Gitter chat, Reddit user group
General discussionGitter chat, Reddit user group
Commercial supportcontact@explosion.ai

Features

  • Non-destructive tokenization
  • Syntax-driven sentence segmentation
  • Pre-trained word vectors
  • Part-of-speech tagging
  • Named entity recognition
  • Labelled dependency parsing
  • Convenient string-to-int mapping
  • Export to numpy data arrays
  • GIL-free multi-threading
  • Efficient binary serialization
  • Easy deep learning integration
  • Statistical models for English, German, French and Spanish
  • State-of-the-art speed
  • Robust, rigorously evaluated accuracy

See facts, figures and benchmarks.

Top Performance

  • 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

Operating systemmacOS / OS X, Linux, Windows (Cygwin, MinGW, Visual Studio)
Python versionCPython 2.6, 2.7, 3.3+. Only 64 bit.
Package managerspip (source packages only), conda (via conda-forge)

Install spaCy

Installation requires a working build environment. See notes on Ubuntu, macOS/OS X and Windows for details.

pip

Using pip, spaCy releases are currently only available as source packages.

pip install -U spacy

When using pip it is generally recommended to install packages in a virtualenv to avoid modifying system state:

virtualenv .env
source .env/bin/activate
pip install spacy

conda

Thanks to our great community, we've finally re-added conda support. You can now install spaCy via conda-forge:

conda config --add channels conda-forge
conda install spacy

For the feedstock including the build recipe and configuration, check out this repository. Improvements and pull requests to the recipe and setup are always appreciated.

Download models

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 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.

spaCy ModelsAvailable models, latest releases and direct download.
Models DocumentationDetailed usage instructions.
# out-of-the-box: download best-matching default model
python -m spacy download en
# download best-matching version of specific model for your spaCy installation
python -m spacy download en_core_web_md
# pip install .tar.gz archive from path or URL
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

Loading and using models

To load a model, use spacy.load() with the model's shortcut link:

importspacynlp=spacy.load('en_default')
doc=nlp(u'This is a sentence.')

If you've installed a model via pip, you can also import it directly and then call its load() method with no arguments. This should also work for older models in previous versions of spaCy.

importspacyimporten_core_web_mdnlp=en_core_web_md.load()
doc=nlp(u'This is a sentence.')

πŸ“– For more info and examples, check out themodels documentation.

Support for older versions

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 or python -m spacy.de.download all. The .tar.gz archives are also attached to the v1.6.0 release. 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').

Compile from source

The other way to install spaCy is to clone its GitHub repository and build it from source. That is the common way if you want to make changes to the code base. You'll need to make sure that you have a development enviroment consisting of a Python distribution including header files, a compiler, pip, virtualenv and git 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.

# make sure you are using recent pip/virtualenv versions
python -m pip install -U pip virtualenv
git clone https://github.com/explosion/spaCy
cd spaCy
virtualenv .env
source .env/bin/activate
pip install -r requirements.txt
pip install -e .

Compared to regular install via pip requirements.txt additionally installs developer dependencies such as Cython.

Instead of the above verbose commands, you can also use the following Fabric commands:

fab envCreate virtualenv and delete previous one, if it exists.
fab makeCompile the source.
fab cleanRemove compiled objects, including the generated C++.
fab testRun basic tests, aborting after first failure.

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:

VENV_DIR=".custom-env" fab clean make

Ubuntu

Install system-level dependencies via apt-get:

sudo apt-get install build-essential python-dev git

macOS / OS X

Install a recent version of XCode, including the so-called "Command Line Tools". macOS and OS X ship with Python and git preinstalled.

Windows

Install a version of Visual Studio Express or higher that matches the version that was used to compile your Python interpreter. For official distributions these are VS 2008 (Python 2.7), VS 2010 (Python 3.4) and VS 2015 (Python 3.5).

Run tests

spaCy comes with an extensive test suite. First, find out where spaCy is installed:

python -c "import os; import spacy; print(os.path.dirname(spacy.__file__))"

Then run pytest on that directory. The flags --vectors, --slow and --model are optional and enable additional tests:

# make sure you are using recent pytest version
python -m pip install -U pytest
python -m pytest <spacy-directory> --vectors --models --slow

πŸ›  Changelog

VersionDateDescription
v1.8.22017-04-26French model and small improvements
v1.8.12017-04-23Saving, loading and training bug fixes
v1.8.02017-04-16Better NER training, saving and loading
v1.7.52017-04-07Bug fixes and new CLI commands
v1.7.32017-03-26Alpha support for Hebrew, new CLI commands and bug fixes
v1.7.22017-03-20Small fixes to beam parser and model linking
v1.7.12017-03-19Fix data download for system installation
v1.7.02017-03-18New 50 MB model, CLI, better downloads and lots of bug fixes
v1.6.02017-01-16Improvements to tokenizer and tests
v1.5.02016-12-27Alpha support for Swedish and Hungarian
v1.4.02016-12-18Improved language data and alpha Dutch support
v1.3.02016-12-03Improve API consistency
v1.2.02016-11-04Alpha tokenizers for Chinese, French, Spanish, Italian and Portuguese
v1.1.02016-10-23Bug fixes and adjustments
v1.0.02016-10-18Support for deep learning workflows and entity-aware rule matcher
v0.101.02016-05-10Fixed German model
v0.100.72016-05-05German support
v0.100.62016-03-08Add support for GloVe vectors
v0.100.52016-02-07Fix incorrect use of header file
v0.100.42016-02-07Fix OSX problem introduced in 0.100.3
v0.100.32016-02-06Multi-threading, faster loading and bugfixes
v0.100.22016-01-21Fix data version lock
v0.100.12016-01-21Fix install for OSX
v0.1002016-01-19Revise setup.py, better model downloads, bug fixes
v0.992015-11-08Improve span merging, internal refactoring
v0.982015-11-03Smaller package, bug fixes
v0.972015-10-23Load the StringStore from a json list, instead of a text file
v0.962015-10-19Hotfix to .merge method
v0.952015-10-18Bug fixes
v0.942015-10-09Fix memory and parse errors
v0.932015-09-22Bug fixes to word vectors

About

πŸ’« Industrial-strength Natural Language Processing (NLP) with Python and Cython

Resources

Contributing

Stars

0 stars

Watchers

9 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

spaCy: Industrial-strength NLP

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, Chinese and Japanese. It's commercial open-source software, released under the MIT license.

⭐️ Test spaCy v2.0.0 alpha and the new models!Read the release notes here.

πŸ’« Version 1.8 out now!Read the release notes here.

Travis Build StatusAppveyor Build StatusCurrent Release Versionpypi Versionconda VersionspaCy on GitterspaCy on Twitter

πŸ“– Documentation

Usage WorkflowsHow to use spaCy and its features.
API ReferenceThe detailed reference for spaCy's API.
TroubleshootingCommon problems and solutions for beginners.
TutorialsEnd-to-end examples, with code you can modify and run.
Showcase & DemosDemos, libraries and products from the spaCy community.
ContributeHow to contribute to the spaCy project and code base.

πŸ’¬ Where to ask questions

Bug reportsGitHub issue tracker
Usage questionsStackOverflow, Gitter chat, Reddit user group
General discussionGitter chat, Reddit user group
Commercial supportcontact@explosion.ai

Features

  • Non-destructive tokenization
  • Syntax-driven sentence segmentation
  • Pre-trained word vectors
  • Part-of-speech tagging
  • Named entity recognition
  • Labelled dependency parsing
  • Convenient string-to-int mapping
  • Export to numpy data arrays
  • GIL-free multi-threading
  • Efficient binary serialization
  • Easy deep learning integration
  • Statistical models for English, German, French and Spanish
  • State-of-the-art speed
  • Robust, rigorously evaluated accuracy

See facts, figures and benchmarks.

Top Performance

  • 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

Operating systemmacOS / OS X, Linux, Windows (Cygwin, MinGW, Visual Studio)
Python versionCPython 2.6, 2.7, 3.3+. Only 64 bit.
Package managerspip (source packages only), conda (via conda-forge)

Install spaCy

Installation requires a working build environment. See notes on Ubuntu, macOS/OS X and Windows for details.

pip

Using pip, spaCy releases are currently only available as source packages.

pip install -U spacy

When using pip it is generally recommended to install packages in a virtualenv to avoid modifying system state:

virtualenv .env
source .env/bin/activate
pip install spacy

conda

Thanks to our great community, we've finally re-added conda support. You can now install spaCy via conda-forge:

conda config --add channels conda-forge
conda install spacy

For the feedstock including the build recipe and configuration, check out this repository. Improvements and pull requests to the recipe and setup are always appreciated.

Download models

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 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.

spaCy ModelsAvailable models, latest releases and direct download.
Models DocumentationDetailed usage instructions.
# out-of-the-box: download best-matching default model
python -m spacy download en
# download best-matching version of specific model for your spaCy installation
python -m spacy download en_core_web_md
# pip install .tar.gz archive from path or URL
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

Loading and using models

To load a model, use spacy.load() with the model's shortcut link:

importspacynlp=spacy.load('en_default')
doc=nlp(u'This is a sentence.')

If you've installed a model via pip, you can also import it directly and then call its load() method with no arguments. This should also work for older models in previous versions of spaCy.

importspacyimporten_core_web_mdnlp=en_core_web_md.load()
doc=nlp(u'This is a sentence.')

πŸ“– For more info and examples, check out themodels documentation.

Support for older versions

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 or python -m spacy.de.download all. The .tar.gz archives are also attached to the v1.6.0 release. 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').

Compile from source

The other way to install spaCy is to clone its GitHub repository and build it from source. That is the common way if you want to make changes to the code base. You'll need to make sure that you have a development enviroment consisting of a Python distribution including header files, a compiler, pip, virtualenv and git 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.

# make sure you are using recent pip/virtualenv versions
python -m pip install -U pip virtualenv
git clone https://github.com/explosion/spaCy
cd spaCy
virtualenv .env
source .env/bin/activate
pip install -r requirements.txt
pip install -e .

Compared to regular install via pip requirements.txt additionally installs developer dependencies such as Cython.

Instead of the above verbose commands, you can also use the following Fabric commands:

fab envCreate virtualenv and delete previous one, if it exists.
fab makeCompile the source.
fab cleanRemove compiled objects, including the generated C++.
fab testRun basic tests, aborting after first failure.

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:

VENV_DIR=".custom-env" fab clean make

Ubuntu

Install system-level dependencies via apt-get:

sudo apt-get install build-essential python-dev git

macOS / OS X

Install a recent version of XCode, including the so-called "Command Line Tools". macOS and OS X ship with Python and git preinstalled.

Windows

Install a version of Visual Studio Express or higher that matches the version that was used to compile your Python interpreter. For official distributions these are VS 2008 (Python 2.7), VS 2010 (Python 3.4) and VS 2015 (Python 3.5).

Run tests

spaCy comes with an extensive test suite. First, find out where spaCy is installed:

python -c "import os; import spacy; print(os.path.dirname(spacy.__file__))"

Then run pytest on that directory. The flags --vectors, --slow and --model are optional and enable additional tests:

# make sure you are using recent pytest version
python -m pip install -U pytest
python -m pytest <spacy-directory> --vectors --models --slow

πŸ›  Changelog

VersionDateDescription
v1.8.22017-04-26French model and small improvements
v1.8.12017-04-23Saving, loading and training bug fixes
v1.8.02017-04-16Better NER training, saving and loading
v1.7.52017-04-07Bug fixes and new CLI commands
v1.7.32017-03-26Alpha support for Hebrew, new CLI commands and bug fixes
v1.7.22017-03-20Small fixes to beam parser and model linking
v1.7.12017-03-19Fix data download for system installation
v1.7.02017-03-18New 50 MB model, CLI, better downloads and lots of bug fixes
v1.6.02017-01-16Improvements to tokenizer and tests
v1.5.02016-12-27Alpha support for Swedish and Hungarian
v1.4.02016-12-18Improved language data and alpha Dutch support
v1.3.02016-12-03Improve API consistency
v1.2.02016-11-04Alpha tokenizers for Chinese, French, Spanish, Italian and Portuguese
v1.1.02016-10-23Bug fixes and adjustments
v1.0.02016-10-18Support for deep learning workflows and entity-aware rule matcher
v0.101.02016-05-10Fixed German model
v0.100.72016-05-05German support
v0.100.62016-03-08Add support for GloVe vectors
v0.100.52016-02-07Fix incorrect use of header file
v0.100.42016-02-07Fix OSX problem introduced in 0.100.3
v0.100.32016-02-06Multi-threading, faster loading and bugfixes
v0.100.22016-01-21Fix data version lock
v0.100.12016-01-21Fix install for OSX
v0.1002016-01-19Revise setup.py, better model downloads, bug fixes
v0.992015-11-08Improve span merging, internal refactoring
v0.982015-11-03Smaller package, bug fixes
v0.972015-10-23Load the StringStore from a json list, instead of a text file
v0.962015-10-19Hotfix to .merge method
v0.952015-10-18Bug fixes
v0.942015-10-09Fix memory and parse errors
v0.932015-09-22Bug fixes to word vectors

About

πŸ’« Industrial-strength Natural Language Processing (NLP) with Python and Cython

Resources

Contributing

Stars

0 stars

Watchers

9 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

spaCy: Industrial-strength NLP

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, Chinese and Japanese. It's commercial open-source software, released under the MIT license.

⭐️ Test spaCy v2.0.0 alpha and the new models!Read the release notes here.

πŸ’« Version 1.8 out now!Read the release notes here.

Travis Build StatusAppveyor Build StatusCurrent Release Versionpypi Versionconda VersionspaCy on GitterspaCy on Twitter

πŸ“– Documentation

Usage WorkflowsHow to use spaCy and its features.
API ReferenceThe detailed reference for spaCy's API.
TroubleshootingCommon problems and solutions for beginners.
TutorialsEnd-to-end examples, with code you can modify and run.
Showcase & DemosDemos, libraries and products from the spaCy community.
ContributeHow to contribute to the spaCy project and code base.

πŸ’¬ Where to ask questions

Bug reportsGitHub issue tracker
Usage questionsStackOverflow, Gitter chat, Reddit user group
General discussionGitter chat, Reddit user group
Commercial supportcontact@explosion.ai

Features

  • Non-destructive tokenization
  • Syntax-driven sentence segmentation
  • Pre-trained word vectors
  • Part-of-speech tagging
  • Named entity recognition
  • Labelled dependency parsing
  • Convenient string-to-int mapping
  • Export to numpy data arrays
  • GIL-free multi-threading
  • Efficient binary serialization
  • Easy deep learning integration
  • Statistical models for English, German, French and Spanish
  • State-of-the-art speed
  • Robust, rigorously evaluated accuracy

See facts, figures and benchmarks.

Top Performance

  • 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

Operating systemmacOS / OS X, Linux, Windows (Cygwin, MinGW, Visual Studio)
Python versionCPython 2.6, 2.7, 3.3+. Only 64 bit.
Package managerspip (source packages only), conda (via conda-forge)

Install spaCy

Installation requires a working build environment. See notes on Ubuntu, macOS/OS X and Windows for details.

pip

Using pip, spaCy releases are currently only available as source packages.

pip install -U spacy

When using pip it is generally recommended to install packages in a virtualenv to avoid modifying system state:

virtualenv .env
source .env/bin/activate
pip install spacy

conda

Thanks to our great community, we've finally re-added conda support. You can now install spaCy via conda-forge:

conda config --add channels conda-forge
conda install spacy

For the feedstock including the build recipe and configuration, check out this repository. Improvements and pull requests to the recipe and setup are always appreciated.

Download models

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 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.

spaCy ModelsAvailable models, latest releases and direct download.
Models DocumentationDetailed usage instructions.
# out-of-the-box: download best-matching default model
python -m spacy download en
# download best-matching version of specific model for your spaCy installation
python -m spacy download en_core_web_md
# pip install .tar.gz archive from path or URL
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

Loading and using models

To load a model, use spacy.load() with the model's shortcut link:

importspacynlp=spacy.load('en_default')
doc=nlp(u'This is a sentence.')

If you've installed a model via pip, you can also import it directly and then call its load() method with no arguments. This should also work for older models in previous versions of spaCy.

importspacyimporten_core_web_mdnlp=en_core_web_md.load()
doc=nlp(u'This is a sentence.')

πŸ“– For more info and examples, check out themodels documentation.

Support for older versions

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 or python -m spacy.de.download all. The .tar.gz archives are also attached to the v1.6.0 release. 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').

Compile from source

The other way to install spaCy is to clone its GitHub repository and build it from source. That is the common way if you want to make changes to the code base. You'll need to make sure that you have a development enviroment consisting of a Python distribution including header files, a compiler, pip, virtualenv and git 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.

# make sure you are using recent pip/virtualenv versions
python -m pip install -U pip virtualenv
git clone https://github.com/explosion/spaCy
cd spaCy
virtualenv .env
source .env/bin/activate
pip install -r requirements.txt
pip install -e .

Compared to regular install via pip requirements.txt additionally installs developer dependencies such as Cython.

Instead of the above verbose commands, you can also use the following Fabric commands:

fab envCreate virtualenv and delete previous one, if it exists.
fab makeCompile the source.
fab cleanRemove compiled objects, including the generated C++.
fab testRun basic tests, aborting after first failure.

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:

VENV_DIR=".custom-env" fab clean make

Ubuntu

Install system-level dependencies via apt-get:

sudo apt-get install build-essential python-dev git

macOS / OS X

Install a recent version of XCode, including the so-called "Command Line Tools". macOS and OS X ship with Python and git preinstalled.

Windows

Install a version of Visual Studio Express or higher that matches the version that was used to compile your Python interpreter. For official distributions these are VS 2008 (Python 2.7), VS 2010 (Python 3.4) and VS 2015 (Python 3.5).

Run tests

spaCy comes with an extensive test suite. First, find out where spaCy is installed:

python -c "import os; import spacy; print(os.path.dirname(spacy.__file__))"

Then run pytest on that directory. The flags --vectors, --slow and --model are optional and enable additional tests:

# make sure you are using recent pytest version
python -m pip install -U pytest
python -m pytest <spacy-directory> --vectors --models --slow

πŸ›  Changelog

VersionDateDescription
v1.8.22017-04-26French model and small improvements
v1.8.12017-04-23Saving, loading and training bug fixes
v1.8.02017-04-16Better NER training, saving and loading
v1.7.52017-04-07Bug fixes and new CLI commands
v1.7.32017-03-26Alpha support for Hebrew, new CLI commands and bug fixes
v1.7.22017-03-20Small fixes to beam parser and model linking
v1.7.12017-03-19Fix data download for system installation
v1.7.02017-03-18New 50 MB model, CLI, better downloads and lots of bug fixes
v1.6.02017-01-16Improvements to tokenizer and tests
v1.5.02016-12-27Alpha support for Swedish and Hungarian
v1.4.02016-12-18Improved language data and alpha Dutch support
v1.3.02016-12-03Improve API consistency
v1.2.02016-11-04Alpha tokenizers for Chinese, French, Spanish, Italian and Portuguese
v1.1.02016-10-23Bug fixes and adjustments
v1.0.02016-10-18Support for deep learning workflows and entity-aware rule matcher
v0.101.02016-05-10Fixed German model
v0.100.72016-05-05German support
v0.100.62016-03-08Add support for GloVe vectors
v0.100.52016-02-07Fix incorrect use of header file
v0.100.42016-02-07Fix OSX problem introduced in 0.100.3
v0.100.32016-02-06Multi-threading, faster loading and bugfixes
v0.100.22016-01-21Fix data version lock
v0.100.12016-01-21Fix install for OSX
v0.1002016-01-19Revise setup.py, better model downloads, bug fixes
v0.992015-11-08Improve span merging, internal refactoring
v0.982015-11-03Smaller package, bug fixes
v0.972015-10-23Load the StringStore from a json list, instead of a text file
v0.962015-10-19Hotfix to .merge method
v0.952015-10-18Bug fixes
v0.942015-10-09Fix memory and parse errors
v0.932015-09-22Bug fixes to word vectors

About

πŸ’« Industrial-strength Natural Language Processing (NLP) with Python and Cython

Resources

Contributing

Stars

0 stars

Watchers

9 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

spaCy: Industrial-strength NLP

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, Chinese and Japanese. It's commercial open-source software, released under the MIT license.

⭐️ Test spaCy v2.0.0 alpha and the new models!Read the release notes here.

πŸ’« Version 1.8 out now!Read the release notes here.

Travis Build StatusAppveyor Build StatusCurrent Release Versionpypi Versionconda VersionspaCy on GitterspaCy on Twitter

πŸ“– Documentation

Usage WorkflowsHow to use spaCy and its features.
API ReferenceThe detailed reference for spaCy's API.
TroubleshootingCommon problems and solutions for beginners.
TutorialsEnd-to-end examples, with code you can modify and run.
Showcase & DemosDemos, libraries and products from the spaCy community.
ContributeHow to contribute to the spaCy project and code base.

πŸ’¬ Where to ask questions

Bug reportsGitHub issue tracker
Usage questionsStackOverflow, Gitter chat, Reddit user group
General discussionGitter chat, Reddit user group
Commercial supportcontact@explosion.ai

Features

  • Non-destructive tokenization
  • Syntax-driven sentence segmentation
  • Pre-trained word vectors
  • Part-of-speech tagging
  • Named entity recognition
  • Labelled dependency parsing
  • Convenient string-to-int mapping
  • Export to numpy data arrays
  • GIL-free multi-threading
  • Efficient binary serialization
  • Easy deep learning integration
  • Statistical models for English, German, French and Spanish
  • State-of-the-art speed
  • Robust, rigorously evaluated accuracy

See facts, figures and benchmarks.

Top Performance

  • 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

Operating systemmacOS / OS X, Linux, Windows (Cygwin, MinGW, Visual Studio)
Python versionCPython 2.6, 2.7, 3.3+. Only 64 bit.
Package managerspip (source packages only), conda (via conda-forge)

Install spaCy

Installation requires a working build environment. See notes on Ubuntu, macOS/OS X and Windows for details.

pip

Using pip, spaCy releases are currently only available as source packages.

pip install -U spacy

When using pip it is generally recommended to install packages in a virtualenv to avoid modifying system state:

virtualenv .env
source .env/bin/activate
pip install spacy

conda

Thanks to our great community, we've finally re-added conda support. You can now install spaCy via conda-forge:

conda config --add channels conda-forge
conda install spacy

For the feedstock including the build recipe and configuration, check out this repository. Improvements and pull requests to the recipe and setup are always appreciated.

Download models

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 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.

spaCy ModelsAvailable models, latest releases and direct download.
Models DocumentationDetailed usage instructions.
# out-of-the-box: download best-matching default model
python -m spacy download en
# download best-matching version of specific model for your spaCy installation
python -m spacy download en_core_web_md
# pip install .tar.gz archive from path or URL
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

Loading and using models

To load a model, use spacy.load() with the model's shortcut link:

importspacynlp=spacy.load('en_default')
doc=nlp(u'This is a sentence.')

If you've installed a model via pip, you can also import it directly and then call its load() method with no arguments. This should also work for older models in previous versions of spaCy.

importspacyimporten_core_web_mdnlp=en_core_web_md.load()
doc=nlp(u'This is a sentence.')

πŸ“– For more info and examples, check out themodels documentation.

Support for older versions

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 or python -m spacy.de.download all. The .tar.gz archives are also attached to the v1.6.0 release. 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').

Compile from source

The other way to install spaCy is to clone its GitHub repository and build it from source. That is the common way if you want to make changes to the code base. You'll need to make sure that you have a development enviroment consisting of a Python distribution including header files, a compiler, pip, virtualenv and git 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.

# make sure you are using recent pip/virtualenv versions
python -m pip install -U pip virtualenv
git clone https://github.com/explosion/spaCy
cd spaCy
virtualenv .env
source .env/bin/activate
pip install -r requirements.txt
pip install -e .

Compared to regular install via pip requirements.txt additionally installs developer dependencies such as Cython.

Instead of the above verbose commands, you can also use the following Fabric commands:

fab envCreate virtualenv and delete previous one, if it exists.
fab makeCompile the source.
fab cleanRemove compiled objects, including the generated C++.
fab testRun basic tests, aborting after first failure.

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:

VENV_DIR=".custom-env" fab clean make

Ubuntu

Install system-level dependencies via apt-get:

sudo apt-get install build-essential python-dev git

macOS / OS X

Install a recent version of XCode, including the so-called "Command Line Tools". macOS and OS X ship with Python and git preinstalled.

Windows

Install a version of Visual Studio Express or higher that matches the version that was used to compile your Python interpreter. For official distributions these are VS 2008 (Python 2.7), VS 2010 (Python 3.4) and VS 2015 (Python 3.5).

Run tests

spaCy comes with an extensive test suite. First, find out where spaCy is installed:

python -c "import os; import spacy; print(os.path.dirname(spacy.__file__))"

Then run pytest on that directory. The flags --vectors, --slow and --model are optional and enable additional tests:

# make sure you are using recent pytest version
python -m pip install -U pytest
python -m pytest <spacy-directory> --vectors --models --slow

πŸ›  Changelog

VersionDateDescription
v1.8.22017-04-26French model and small improvements
v1.8.12017-04-23Saving, loading and training bug fixes
v1.8.02017-04-16Better NER training, saving and loading
v1.7.52017-04-07Bug fixes and new CLI commands
v1.7.32017-03-26Alpha support for Hebrew, new CLI commands and bug fixes
v1.7.22017-03-20Small fixes to beam parser and model linking
v1.7.12017-03-19Fix data download for system installation
v1.7.02017-03-18New 50 MB model, CLI, better downloads and lots of bug fixes
v1.6.02017-01-16Improvements to tokenizer and tests
v1.5.02016-12-27Alpha support for Swedish and Hungarian
v1.4.02016-12-18Improved language data and alpha Dutch support
v1.3.02016-12-03Improve API consistency
v1.2.02016-11-04Alpha tokenizers for Chinese, French, Spanish, Italian and Portuguese
v1.1.02016-10-23Bug fixes and adjustments
v1.0.02016-10-18Support for deep learning workflows and entity-aware rule matcher
v0.101.02016-05-10Fixed German model
v0.100.72016-05-05German support
v0.100.62016-03-08Add support for GloVe vectors
v0.100.52016-02-07Fix incorrect use of header file
v0.100.42016-02-07Fix OSX problem introduced in 0.100.3
v0.100.32016-02-06Multi-threading, faster loading and bugfixes
v0.100.22016-01-21Fix data version lock
v0.100.12016-01-21Fix install for OSX
v0.1002016-01-19Revise setup.py, better model downloads, bug fixes
v0.992015-11-08Improve span merging, internal refactoring
v0.982015-11-03Smaller package, bug fixes
v0.972015-10-23Load the StringStore from a json list, instead of a text file
v0.962015-10-19Hotfix to .merge method
v0.952015-10-18Bug fixes
v0.942015-10-09Fix memory and parse errors
v0.932015-09-22Bug fixes to word vectors

About

πŸ’« Industrial-strength Natural Language Processing (NLP) with Python and Cython

Resources

Contributing

Stars

0 stars

Watchers

9 watching

Forks

Releases

Packages

Contributors

Languages