docs: make Chinese README the default

This commit is contained in:
wehub-resource-sync
2026-07-13 10:29:15 +00:00
parent 5e6323c517
commit d4c43c506a
+112 -137
View File
@@ -1,23 +1,19 @@
<!-- WEHUB_ZH_README -->
> [!NOTE]
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
> [English](./README.en.md) · [原始项目](https://github.com/explosion/spaCy) · [上游 README](https://github.com/explosion/spaCy/blob/HEAD/README.md)
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
<a href="https://explosion.ai"><img src="https://explosion.ai/assets/img/logo.svg" width="125" height="125" align="right" /></a>
# spaCy: Industrial-strength NLP
# spaCy:工业级 NLP
spaCy is a library for **advanced Natural Language Processing** in Python and
Cython. It's built on the very latest research, and was designed from day one to
be used in real products.
spaCy 是一个用于 Python 和 Cython 的**高级自然语言处理(Natural Language Processing**库。它基于最前沿的研究成果,从诞生之初就面向真实产品场景而设计。
spaCy comes with [pretrained pipelines](https://spacy.io/models) and currently
supports tokenization and training for **70+ languages**. It features
state-of-the-art speed and **neural network models** for tagging, parsing,
**named entity recognition**, **text classification** and more, multi-task
learning with pretrained **transformers** like BERT, as well as a
production-ready [**training system**](https://spacy.io/usage/training) and easy
model packaging, deployment and workflow management. spaCy is commercial
open-source software, released under the
[MIT license](https://github.com/explosion/spaCy/blob/master/LICENSE).
spaCy 提供[预训练流水线(pretrained pipelines](https://spacy.io/models),目前支持 **70+** 种语言的词元化(tokenization)与训练。它在词性标注、句法分析、**命名实体识别(named entity recognition**、**文本分类(text classification**等任务上具备顶尖速度与**神经网络模型**,支持基于 BERT 等预训练 **Transformer** 的多任务学习,还提供生产就绪的[**训练系统(training system**](https://spacy.io/usage/training),以及便捷的模型打包、部署与工作流管理。spaCy 是商业开源软件,采用 [MIT 许可证(MIT license](https://github.com/explosion/spaCy/blob/master/LICENSE).
💫 **Version 3.8 out now!**
[Check out the release notes here.](https://github.com/explosion/spaCy/releases)
💫 **3.8 版本现已发布!**
[在此查看发行说明。](https://github.com/explosion/spaCy/releases)
[![tests](https://github.com/explosion/spaCy/actions/workflows/tests.yml/badge.svg)](https://github.com/explosion/spaCy/actions/workflows/tests.yml)
[![Current Release Version](https://img.shields.io/github/release/explosion/spacy.svg?style=flat-square&logo=github)](https://github.com/explosion/spaCy/releases)
@@ -29,30 +25,30 @@ open-source software, released under the
[![PyPi downloads](https://static.pepy.tech/personalized-badge/spacy?period=total&units=international_system&left_color=grey&right_color=orange&left_text=pip%20downloads)](https://pypi.org/project/spacy/)
[![Conda downloads](https://img.shields.io/conda/dn/conda-forge/spacy?label=conda%20downloads)](https://anaconda.org/conda-forge/spacy)
## 📖 Documentation
## 📖 文档
| Documentation | |
| 文档 | |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ⭐️ **[spaCy 101]** | New to spaCy? Here's everything you need to know! |
| 📚 **[Usage Guides]** | How to use spaCy and its features. |
| 🚀 **[New in v3.0]** | New features, backwards incompatibilities and migration guide. |
| 🪐 **[Project Templates]** | End-to-end workflows you can clone, modify and run. |
| 🎛 **[API Reference]** | The detailed reference for spaCy's API. |
| ⏩ **[GPU Processing]** | Use spaCy with CUDA-compatible GPU processing. |
| 📦 **[Models]** | Download trained pipelines for spaCy. |
| 🦙 **[Large Language Models]** | Integrate LLMs into spaCy pipelines. |
| 🌌 **[Universe]** | Plugins, extensions, demos and books from the spaCy ecosystem. |
| ⚙️ **[spaCy VS Code Extension]** | Additional tooling and features for working with spaCy's config files. |
| 👩‍🏫 **[Online Course]** | Learn spaCy in this free and interactive online course. |
| 📰 **[Blog]** | Read about current spaCy and Prodigy development, releases, talks and more from Explosion. |
| 📺 **[Videos]** | Our YouTube channel with video tutorials, talks and more. |
| 🔴 **[Live Stream]** | Join Matt as he works on spaCy and chat about NLP. |
| 🛠 **[Changelog]** | Changes and version history. |
| 💝 **[Contribute]** | How to contribute to the spaCy project and code base. |
| 👕 **[Swag]** | Support us and our work with unique, custom-designed swag! |
| <a href="https://explosion.ai/tailored-solutions"><img src="https://github.com/explosion/spaCy/assets/13643239/36d2a42e-98c0-4599-90e1-788ef75181be" width="150" alt="Tailored Solutions"/></a> | Custom NLP consulting, implementation and strategic advice by spaCys core development team. Streamlined, production-ready, predictable and maintainable. Send us an email or take our 5-minute questionnaire, and well'be in touch! **[Learn more &rarr;](https://explosion.ai/tailored-solutions)** |
| ⭐️ **[spaCy 101]** | 初次接触 spaCy?这里有你需要了解的一切! |
| 📚 **[Usage Guides]** | 如何使用 spaCy 及其功能。 |
| 🚀 **[New in v3.0]** | 新功能、向后不兼容变更与迁移指南。 |
| 🪐 **[Project Templates]** | 可克隆、修改并运行的端到端工作流。 |
| 🎛 **[API Reference]** | spaCy API 的详细参考文档。 |
| ⏩ **[GPU Processing]** | 在兼容 CUDA 的 GPU 上运行 spaCy。 |
| 📦 **[Models]** | 下载 spaCy 的训练流水线。 |
| 🦙 **[Large Language Models]** | 将大语言模型(LLM)集成到 spaCy 流水线中。 |
| 🌌 **[Universe]** | spaCy 生态中的插件、扩展、演示与书籍。 |
| ⚙️ **[spaCy VS Code Extension]** | 用于处理 spaCy 配置文件的额外工具与功能。 |
| 👩‍🏫 **[Online Course]** | 在这门免费互动在线课程中学习 spaCy。 |
| 📰 **[Blog]** | 阅读 Explosion 关于 spaCy Prodigy 的最新开发动态、版本发布、演讲等内容。 |
| 📺 **[Videos]** | 我们的 YouTube 频道,提供视频教程、演讲等内容。 |
| 🔴 **[Live Stream]** | Matt 一起直播开发 spaCy,畅聊 NLP |
| 🛠 **[Changelog]** | 变更与版本历史。 |
| 💝 **[Contribute]** | 如何为 spaCy 项目与代码库做贡献。 |
| 👕 **[Swag]** | 购买独特定制周边,支持我们及我们的工作! |
| <a href="https://explosion.ai/tailored-solutions"><img src="https://github.com/explosion/spaCy/assets/13643239/36d2a42e-98c0-4599-90e1-788ef75181be" width="150" alt="定制解决方案"/></a> | 由 spaCy 核心开发团队提供的定制 NLP 咨询、实施与战略建议。精简、生产就绪、可预测且易于维护。给我们发邮件或填写 5 分钟问卷,我们会尽快与您联系!**[了解更多 &rarr;](https://explosion.ai/tailored-solutions)** |
[spacy 101]: https://spacy.io/usage/spacy-101
[spaCy 101]: https://spacy.io/usage/spacy-101
[new in v3.0]: https://spacy.io/usage/v3
[usage guides]: https://spacy.io/usage/
[api reference]: https://spacy.io/api/
@@ -70,79 +66,73 @@ open-source software, released under the
[contribute]: https://github.com/explosion/spaCy/blob/master/CONTRIBUTING.md
[swag]: https://explosion.ai/merch
## 💬 Where to ask questions
## 💬 在哪里提问
The spaCy project is maintained by the [spaCy team](https://explosion.ai/about).
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.
spaCy 项目由 [spaCy 团队](https://explosion.ai/about).
维护。请注意,我们无法通过电子邮件提供一对一支持。
我们也认为,公开分享的帮助更有价值,这样更多人可以从中受益。
| Type | Platforms |
| 类型 | 平台 |
| ------------------------------- | --------------------------------------- |
| 🚨 **Bug Reports** | [GitHub Issue Tracker] |
| 🎁 **Feature Requests & Ideas** | [GitHub Discussions] · [Live Stream] |
| 👩‍💻 **Usage Questions** | [GitHub Discussions] · [Stack Overflow] |
| 🗯 **General Discussion** | [GitHub Discussions] · [Live Stream] |
| 🚨 **缺陷报告** | [GitHub Issue Tracker] |
| 🎁 **功能请求与想法** | [GitHub Discussions] · [Live Stream] |
| 👩‍💻 **使用问题** | [GitHub Discussions] · [Stack Overflow] |
| 🗯 **一般讨论** | [GitHub Discussions] · [Live Stream] |
[github issue tracker]: https://github.com/explosion/spaCy/issues
[github discussions]: https://github.com/explosion/spaCy/discussions
[stack overflow]: https://stackoverflow.com/questions/tagged/spacy
[live stream]: https://www.youtube.com/playlist?list=PLBmcuObd5An5_iAxNYLJa_xWmNzsYce8c
## Features
## 特性
- Support for **70+ languages**
- **Trained pipelines** for different languages and tasks
- Multi-task learning with pretrained **transformers** like BERT
- Support for pretrained **word vectors** and embeddings
- State-of-the-art speed
- Production-ready **training system**
- Linguistically-motivated **tokenization**
- Components for named **entity recognition**, part-of-speech-tagging,
dependency parsing, sentence segmentation, **text classification**,
lemmatization, morphological analysis, entity linking and more
- Easily extensible with **custom components** and attributes
- Support for custom models in **PyTorch**, **TensorFlow** and other frameworks
- Built in **visualizers** for syntax and NER
- Easy **model packaging**, deployment and workflow management
- Robust, rigorously evaluated accuracy
- 支持 **70+ 种语言**
- 适用于不同语言和任务的 **训练流水线(pipeline**
- 多任务学习,使用 BERT 等预训练 **transformer**
- 支持预训练 **词向量(word vectors** 和嵌入(embeddings
- 业界领先的运行速度
- 可用于生产的 **训练系统**
- 基于语言学动机的 **分词(tokenization**
- 命名 **实体识别(NER**、词性标注、依存句法分析、句子分割、**文本分类**、词形还原、形态学分析、实体链接等组件
- 可通过 **自定义组件** 和属性轻松扩展
- 支持在 **PyTorch**、**TensorFlow** 及其他框架中使用自定义模型
- 内置句法和 NER 的 **可视化工具(visualizer**
- 便捷的 **模型打包**、部署与工作流管理
- 稳健、经过严格评估的准确度
📖 **For more details, see the
[facts, figures and benchmarks](https://spacy.io/usage/facts-figures).**
📖 **更多详情请参阅
[事实、数据与基准测试](https://spacy.io/usage/facts-figures).**
## ⏳ Install spaCy
## ⏳ 安装 spaCy
For detailed installation instructions, see the
[documentation](https://spacy.io/usage).
详细安装说明请参阅
[文档](https://spacy.io/usage).
- **Operating system**: macOS / OS X · Linux · Windows (Cygwin, MinGW, Visual
Studio)
- **Python version**: Python >=3.7, <3.13 (only 64 bit)
- **Package managers**: [pip] · [conda] (via `conda-forge`)
- **操作系统**macOS / OS X · Linux · WindowsCygwinMinGWVisual
Studio
- **Python 版本**Python >=3.7<3.13(仅 64 位)
- **包管理器**[pip] · [conda](通过 `conda-forge`
[pip]: https://pypi.org/project/spacy/
[conda]: https://anaconda.org/conda-forge/spacy
### pip
Using pip, spaCy releases are available as source packages and binary wheels.
Before you install spaCy and its dependencies, make sure that your `pip`,
`setuptools` and `wheel` are up to date.
使用 pip 时,spaCy 发布包提供源码包和二进制 wheel 包。
在安装 spaCy 及其依赖之前,请确保你的 `pip`
`setuptools` `wheel` 已是最新版本。
```bash
pip install -U pip setuptools wheel
pip install spacy
```
To install additional data tables for lemmatization and normalization you can
run `pip install spacy[lookups]` or install
[`spacy-lookups-data`](https://github.com/explosion/spacy-lookups-data)
separately. The lookups package is needed to create blank models with
lemmatization data, and to lemmatize in languages that don't yet come with
pretrained models and aren't powered by third-party libraries.
要安装用于词形还原和规范化的额外数据表,可以
运行 `pip install spacy[lookups]`,或单独安装
[`spacy-lookups-data`](https://github.com/explosion/spacy-lookups-data)
lookups 包用于创建带有词形还原数据的空白模型,以及在尚未提供预训练模型、且不依赖第三方库的语言中进行词形还原。
When using pip it is generally recommended to install packages in a virtual
environment to avoid modifying system state:
使用 pip 时,通常建议在虚拟环境中安装软件包,以避免修改系统状态:
```bash
python -m venv .env
@@ -153,45 +143,38 @@ pip install spacy
### conda
You can also install spaCy from `conda` via the `conda-forge` channel. For the
feedstock including the build recipe and configuration, check out
[this repository](https://github.com/conda-forge/spacy-feedstock).
你也可以通过 `conda-forge` 频道从 `conda` 安装 spaCy。有关包含构建配方和配置的 feedstock,请参阅
[此仓库](https://github.com/conda-forge/spacy-feedstock).
```bash
conda install -c conda-forge spacy
```
### Updating spaCy
### 更新 spaCy
Some updates to spaCy may require downloading new statistical models. If you're
running spaCy v2.0 or higher, you can use the `validate` command to check if
your installed models are compatible and if not, print details on how to update
them:
spaCy 的某些更新可能需要下载新的统计模型。如果你运行的是 spaCy v2.0 或更高版本,可以使用 `validate` 命令检查已安装模型是否兼容;若不兼容,会输出如何更新它们的详细信息:
```bash
pip install -U spacy
python -m spacy validate
```
If you've trained your own models, keep in mind that your training and runtime
inputs must match. After updating spaCy, we recommend **retraining your models**
with the new version.
如果你训练了自己的模型,请注意训练时与运行时的输入必须一致。更新 spaCy 后,我们建议使用新版本 **重新训练你的模型**
📖 **For details on upgrading from spaCy 2.x to spaCy 3.x, see the
[migration guide](https://spacy.io/usage/v3#migrating).**
📖 **有关从 spaCy 2.x 升级到 spaCy 3.x 的详情,请参阅
[迁移指南](https://spacy.io/usage/v3#migrating).**
## 📦 Download model packages
## 📦 下载模型包
Trained pipelines for spaCy can be installed as **Python packages**. This means
that they're a component of your application, just like any other module. Models
can be installed using spaCy's [`download`](https://spacy.io/api/cli#download)
command, or manually by pointing pip to a path or URL.
spaCy 的训练流水线可作为 **Python 软件包** 安装。这意味着
它们是你应用程序的组成部分,就像任何其他模块一样。可以使用 spaCy 的 [`download`](https://spacy.io/api/cli#download)
命令安装模型,也可以通过让 pip 指向路径或 URL 手动安装。
| Documentation | |
| 文档 | |
| -------------------------- | ---------------------------------------------------------------- |
| **[Available Pipelines]** | Detailed pipeline descriptions, accuracy figures and benchmarks. |
| **[Models Documentation]** | Detailed usage and installation instructions. |
| **[Training]** | How to train your own pipelines on your data. |
| **[可用流水线]** | 详细的流水线说明、准确度数据与基准测试。 |
| **[模型文档]** | 详细的使用与安装说明。 |
| **[训练]** | 如何在自己的数据上训练自定义流水线。 |
[available pipelines]: https://spacy.io/models
[models documentation]: https://spacy.io/usage/models
@@ -207,10 +190,10 @@ pip install /Users/you/en_core_web_sm-3.0.0-py3-none-any.whl
pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.0.0/en_core_web_sm-3.0.0.tar.gz
```
### Loading and using models
### 加载和使用模型
To load a model, use [`spacy.load()`](https://spacy.io/api/top-level#spacy.load)
with the model name or a path to the model data directory.
要加载模型,请使用 [`spacy.load()`](https://spacy.io/api/top-level#spacy.load)
,并传入模型名称或模型数据目录的路径。
```python
import spacy
@@ -218,8 +201,8 @@ nlp = spacy.load("en_core_web_sm")
doc = nlp("This is a sentence.")
```
You can also `import` a model directly via its full name and then call its
`load()` method with no arguments.
你也可以通过模型的完整名称直接 `import`,然后无参调用其
`load()` 方法。
```python
import spacy
@@ -229,31 +212,28 @@ nlp = en_core_web_sm.load()
doc = nlp("This is a sentence.")
```
📖 **For more info and examples, check out the
[models documentation](https://spacy.io/docs/usage/models).**
📖 **更多信息和示例,请参阅
[模型文档](https://spacy.io/docs/usage/models).**
## ⚒ Compile from source
## ⚒ 从源码编译
The other way to install spaCy is to clone its
[GitHub repository](https://github.com/explosion/spaCy) 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 environment consisting of a
Python distribution including header files, a compiler,
安装 spaCy 的另一种方式是克隆其
[GitHub 仓库](https://github.com/explosion/spaCy),并从源码构建。
如果你想修改代码库,这通常是常用的方式。
你需要确保已具备开发环境,包括带头文件的 Python 发行版、编译器、
[pip](https://pip.pypa.io/en/latest/installing/),
[virtualenv](https://virtualenv.pypa.io/en/latest/) and
[git](https://git-scm.com) installed. The compiler part is the trickiest. How to
do that depends on your system.
[virtualenv](https://virtualenv.pypa.io/en/latest/)
[git](https://git-scm.com) 已安装。编译器部分最为棘手,具体做法取决于你的系统。
| Platform | |
| 平台 | |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Ubuntu** | Install system-level dependencies via `apt-get`: `sudo apt-get install build-essential python-dev git` . |
| **Mac** | 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 and git preinstalled. |
| **Windows** | Install a version of the [Visual C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) or [Visual Studio Express](https://visualstudio.microsoft.com/vs/express/) that matches the version that was used to compile your Python interpreter. |
| **Ubuntu** | 通过 `apt-get` 安装系统级依赖:`sudo apt-get install build-essential python-dev git` |
| **Mac** | 安装最新版 [XCode](https://developer.apple.com/xcode/),,其中包含所谓的「Command Line Tools」。macOS OS X 预装了 Python git |
| **Windows** | 安装与你的 Python 解释器编译所用版本相匹配的 [Visual C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) [Visual Studio Express](https://visualstudio.microsoft.com/vs/express/) |
For more details and instructions, see the documentation on
[compiling spaCy from source](https://spacy.io/usage#source) and the
[quickstart widget](https://spacy.io/usage#section-quickstart) to get the right
commands for your platform and Python version.
如需更多详情和操作说明,请参阅
[从源码编译 spaCy](https://spacy.io/usage#source) 以及
[快速入门 widget](https://spacy.io/usage#section-quickstart),以获取适用于你的平台与 Python 版本的正确命令。
```bash
git clone https://github.com/explosion/spaCy
@@ -269,22 +249,17 @@ pip install -r requirements.txt
pip install --no-build-isolation --editable .
```
To install with extras:
安装 extras 扩展:
```bash
pip install --no-build-isolation --editable .[lookups,cuda102]
```
## 🚦 Run tests
## 🚦 运行测试
spaCy comes with an [extensive test suite](spacy/tests). In order to run the
tests, you'll usually want to clone the repository and build spaCy from source.
This will also install the required development dependencies and test utilities
defined in the [`requirements.txt`](requirements.txt).
spaCy 附带[完善的测试套件](spacy/tests)。要运行测试,你通常需要克隆仓库并从源码构建 spaCy。这也会安装 [`requirements.txt`](requirements.txt) 中定义的必要开发依赖与测试工具。
Alternatively, you can run `pytest` on the tests from within the installed
`spacy` package. Don't forget to also install the test utilities via spaCy's
[`requirements.txt`](requirements.txt):
或者,你也可以在已安装的 `spacy` 包内对测试运行 `pytest`。别忘了通过 spaCy 的 [`requirements.txt`](requirements.txt) 安装测试工具:
```bash
pip install -r requirements.txt