Skip to content

Commit 3219b9d

Browse files
authored
Merge pull request #123 from FengZiYjun/v0.3.0
fastNLP V0.3.0
2 parents ef82c1f + 094a566 commit 3219b9d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+35184
-2065
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ For example:
4848
## Resources
4949

5050
- [Documentation](https://fastnlp.readthedocs.io/en/latest/)
51+
- [Tutorials](https://github.com/fastnlp/fastNLP/tutorials)
5152
- [Source Code](https://github.com/fastnlp/fastNLP)
5253

54+
5355
## Installation
5456
Run the following commands to install fastNLP package.
5557
```shell
@@ -70,7 +72,7 @@ pip install fastNLP
7072
</tr>
7173
<tr>
7274
<td><b> fastNLP.core </b></td>
73-
<td> data representation & train/test presedure </td>
75+
<td> data representation & train/test procedure </td>
7476
</tr>
7577
<tr>
7678
<td><b> fastNLP.models </b></td>

fastNLP/api/README.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# fastNLP 高级接口
2+
3+
### 环境与配置
4+
1. 系统环境:linux/ubuntu(推荐)
5+
2. 编程语言:Python>=3.6
6+
3. Python包依赖
7+
- **torch==1.0**
8+
- numpy>=1.14.2
9+
10+
### 中文分词
11+
```python
12+
text = ['编者按:7月12日,英国航空航天系统公司公布了该公司研制的第一款高科技隐形无人机雷电之神。',
13+
'这款飞行从外型上来看酷似电影中的太空飞行器,据英国方面介绍,可以实现洲际远程打击。',
14+
'那么这款无人机到底有多厉害?']
15+
from fastNLP.api import CWS
16+
cws = CWS(device='cpu')
17+
print(cws.predict(text))
18+
# ['编者 按 : 7月 12日 , 英国 航空 航天 系统 公司 公布 了 该 公司 研制 的 第一 款 高 科技 隐形 无人 机雷电 之 神 。', '这 款 飞行 从 外型 上 来 看 酷似 电影 中 的 太空 飞行器 , 据 英国 方面 介绍 , 可以 实现 洲际 远程 打击 。', '那么 这 款 无人 机 到底 有 多 厉害 ?']
19+
```
20+
21+
### 中文分词+词性标注
22+
```python
23+
text = ['编者按:7月12日,英国航空航天系统公司公布了该公司研制的第一款高科技隐形无人机雷电之神。',
24+
'这款飞行从外型上来看酷似电影中的太空飞行器,据英国方面介绍,可以实现洲际远程打击。',
25+
'那么这款无人机到底有多厉害?']
26+
from fastNLP.api import POS
27+
pos = POS(device='cpu')
28+
print(pos.predict(text))
29+
# [['编者/NN', '按/P', ':/PU', '7月/NT', '12日/NR', ',/PU', '英国/NR', '航空/NN', '航天/NN', '系统/NN', '公司/NN', '公布/VV', '了/AS', '该/DT', '公司/NN', '研制/VV', '的/DEC', '第一/OD', '款高/NN', '科技/NN', '隐形/NN', '无/VE', '人机/NN', '雷电/NN', '之/DEG', '神/NN', '。/PU'], ['这/DT', '款/NN', '飞行/VV', '从/P', '外型/NN', '上/LC', '来/MSP', '看/VV', '酷似/VV', '电影/NN', '中/LC', '的/DEG', '太空/NN', '飞行器/NN', ',/PU', '据/P', '英国/NR', '方面/NN', '介绍/VV', ',/PU', '可以/VV', '实现/VV', '洲际/NN', '远程/NN', '打击/NN', '。/PU'], ['那么/AD', '这/DT', '款/NN', '无/VE', '人机/NN', '到底/AD', '有/VE', '多/CD', '厉害/NN', '?/PU']]
30+
```
31+
32+
### 中文分词+词性标注+句法分析
33+
```python
34+
text = ['编者按:7月12日,英国航空航天系统公司公布了该公司研制的第一款高科技隐形无人机雷电之神。',
35+
'这款飞行从外型上来看酷似电影中的太空飞行器,据英国方面介绍,可以实现洲际远程打击。',
36+
'那么这款无人机到底有多厉害?']
37+
from fastNLP.api import Parser
38+
parser = Parser(device='cpu')
39+
print(parser.predict(text))
40+
# [['12/nsubj', '12/prep', '2/punct', '5/nn', '2/pobj', '12/punct', '11/nn', '11/nn', '11/nn', '11/nn', '2/pobj', '0/root', '12/asp', '15/det', '16/nsubj', '21/rcmod', '16/cpm', '21/nummod', '21/nn', '21/nn', '22/top', '12/ccomp', '24/nn', '26/assmod', '24/assm', '22/dobj', '12/punct'], ['2/det', '8/xsubj', '8/mmod', '8/prep', '6/lobj', '4/plmod', '8/prtmod', '0/root', '8/ccomp', '11/lobj', '14/assmod', '11/assm', '14/nn', '9/dobj', '8/punct', '22/prep', '18/nn', '19/nsubj', '16/pccomp', '22/punct', '22/mmod', '8/dep', '25/nn', '25/nn', '22/dobj', '8/punct'], ['4/advmod', '3/det', '4/nsubj', '0/root', '4/dobj', '7/advmod', '4/conj', '9/nummod', '7/dobj', '4/punct']]
41+
```
42+
43+
完整样例见`examples.py`

fastNLP/api/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .api import CWS, POS, Parser

0 commit comments

Comments
 (0)