explosion / explosion/spacy-course
Wrong word segmentation in chinese course
Open
- Dominant language
- Python
- Stars
- 2.4k
- Forks
- 377
- PR merge metrics
- No merged PRs in 30d
Description
The sentence is just splited by character.
```
# 导入spacy并创建中文nlp对象
import spacy
nlp = spacy.blank("zh")
# 处理文本
doc = nlp("我喜欢老虎和狮子。")
# 遍历打印doc中的内容
for i, token in enumerate(doc):
print(i, token.text)
# 截取Doc中"老虎"的部分
laohu = doc[2:3]
print(laohu.text)
# 截取Doc中"老虎和狮子"的部分(不包括"。")
laohu_he_shizi = doc[2:5]
print(laohu_he_shizi.text)
```
Output
```
0 我
1 喜
2 欢
3 老
4 虎
5 和
6 狮
7 子
8 。
欢
欢老虎
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.