The Stanford NLP Group's official Python NLP library. It contains support for running various accurate natural language processing tools on 60+ languages and for accessing the Java Stanford CoreNLP software from Python.
There are a few initial setup steps.
- Download Stanford CoreNLP and models for the language you wish to use
- Put the model jars in the distribution folder
- Tell the Python code where Stanford CoreNLP is located by setting the
CORENLP_HOMEenvironment variable (e.g., in *nix):
We provide comprehensive examples in our documentation that show how one can use CoreNLP through Stanza and extract various annotations from it.
Online Colab Notebooks
To get your started, we also provide interactive Jupyter notebooks in the
demo folder. You can also open these notebooks and run them interactively on Google Colab. To view all available notebooks, follow these steps:
- Go to the Google Colab website
- Navigate to
Open notebook, and choose
GitHubin the pop-up menu
- Note that you do not need to give Colab access permission to your github account
stanfordnlp/stanzain the search bar, and click enter
Trained Models for the Neural Pipeline
We currently provide models for all of the Universal Dependencies treebanks v2.5, as well as NER models for a few widely-spoken languages. You can find instructions for downloading and using these models here.
Batching To Maximize Pipeline Speed
To maximize speed performance, it is essential to run the pipeline on batches of documents. Running a for loop on one sentence at a time will be very slow. The best approach at this time is to concatenate documents together, with each document separated by a blank line (i.e., two line breaks
\n\n). The tokenizer will recognize blank lines as sentence breaks. We are actively working on improving multi-document processing.
Training your own neural pipelines
All neural modules in this library can be trained with your own data. The tokenizer, the multi-word token (MWT) expander, the POS/morphological features tagger, the lemmatizer and the dependency parser require CoNLL-U formatted data, while the NER model requires the BIOES format. Currently, we do not support model training via the
Pipeline interface. Therefore, to train your own models, you need to clone this git repository and run training from the source.
For detailed step-by-step guidance on how to train and evaluate your own models, please visit our training documentation.