add README
Browse files
README.md
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- zh
|
4 |
+
|
5 |
+
license: apache-2.0
|
6 |
+
|
7 |
+
tags:
|
8 |
+
- Roberta
|
9 |
+
- CWS
|
10 |
+
- Chinese Word Segmentation
|
11 |
+
- Chinese
|
12 |
+
|
13 |
+
inference: false
|
14 |
+
---
|
15 |
+
#### How to use
|
16 |
+
|
17 |
+
You can use this model with Transformers *pipeline* for token-classification.
|
18 |
+
|
19 |
+
```python
|
20 |
+
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
21 |
+
from transformers import pipeline
|
22 |
+
|
23 |
+
nlp = pipeline("token-classification", model="enpchina/cws_chinese_shunpao_0923", aggregation_strategy="simple")
|
24 |
+
example = "非兩君之盡心於民事,以實心而行實政, 其能得此,於諸紳士也哉。"
|
25 |
+
cws_results = nlp(example)
|
26 |
+
print(cws_results)
|
27 |
+
print()
|
28 |
+
tab = [w["word"].replace(" ","") for w in cws_results]
|
29 |
+
print(tab)
|
30 |
+
print()
|
31 |
+
print(" ".join(tab))
|
32 |
+
```
|