Skip to content

Commit 471a8a0

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/PaddleNLP into develop
2 parents b07d60f + 64954f0 commit 471a8a0

File tree

5 files changed

+25
-24
lines changed

5 files changed

+25
-24
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ ner("《孤女》是2010年九州出版社出版的小说,作者是余兼羽")
7171

7272
# 句法分析
7373
ddp = Taskflow("dependency_parsing")
74-
ddp("百度是一家高科技公司")
75-
>>> [{'word': ['百度', '', '一家', '高科技', '公司'], 'head': ['2', '0', '5', '5', '2'], 'deprel': ['SBV', 'HED', 'ATT', 'ATT', 'VOB']}]
74+
ddp("9月9日上午纳达尔在亚瑟·阿什球场击败俄罗斯球员梅德韦杰夫")
75+
>>> [{'word': ['9月9日', '上午', '纳达尔', '', '亚瑟·阿什球场', '击败', '俄罗斯', '球员', '梅德韦杰夫'], 'head': [2, 6, 6, 5, 6, 0, 8, 9, 6], 'deprel': ['ATT', 'ADV', 'SBV', 'MT', 'ADV', 'HED', 'ATT', 'ATT', 'VOB']}]
7676

7777
# 情感分析
7878
senta = Taskflow("sentiment_analysis")
79-
senta("怀着十分激动的心情放映,可是看着看着发现,在放映完毕后,出现一集米老鼠的动画片")
80-
>>> [{'text': '怀着十分激动的心情放映,可是看着看着发现,在放映完毕后,出现一集米老鼠的动画片', 'label': 'negative', 'score': 0.6691398620605469}]
79+
senta("这个产品用起来真的很流畅,我非常喜欢")
80+
>>> [{'text': '这个产品用起来真的很流畅,我非常喜欢', 'label': 'positive', 'score': 0.9938690066337585}]
8181
```
8282
更多使用方法请参考[Taskflow文档](./docs/model_zoo/taskflow.md)
8383

README_en.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ ner("《孤女》是2010年九州出版社出版的小说,作者是余兼羽")
7070

7171
# Dependency Parsing
7272
ddp = Taskflow("dependency_parsing")
73-
ddp("百度是一家高科技公司")
74-
>>> [{'word': ['百度', '', '一家', '高科技', '公司'], 'head': ['2', '0', '5', '5', '2'], 'deprel': ['SBV', 'HED', 'ATT', 'ATT', 'VOB']}]
73+
ddp("9月9日上午纳达尔在亚瑟·阿什球场击败俄罗斯球员梅德韦杰夫")
74+
>>> [{'word': ['9月9日', '上午', '纳达尔', '', '亚瑟·阿什球场', '击败', '俄罗斯', '球员', '梅德韦杰夫'], 'head': [2, 6, 6, 5, 6, 0, 8, 9, 6], 'deprel': ['ATT', 'ADV', 'SBV', 'MT', 'ADV', 'HED', 'ATT', 'ATT', 'VOB']}]
7575

7676
# Sentiment Analysis
7777
senta = Taskflow("sentiment_analysis")
78-
senta("怀着十分激动的心情放映,可是看着看着发现,在放映完毕后,出现一集米老鼠的动画片")
79-
>>> [{'text': '怀着十分激动的心情放映,可是看着看着发现,在放映完毕后,出现一集米老鼠的动画片', 'label': 'negative', 'score': 0.6691398620605469}]
78+
senta("这个产品用起来真的很流畅,我非常喜欢")
79+
>>> [{'text': '这个产品用起来真的很流畅,我非常喜欢', 'label': 'positive', 'score': 0.9938690066337585}]
8080
```
8181

8282
For more usage please refer to [Taskflow Docs](./docs/model_zoo/taskflow.md)

docs/model_zoo/taskflow.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,21 @@ corrector(['遇到逆竟时,我们必须勇于面对,而且要愈挫愈勇
126126
from paddlenlp import Taskflow
127127

128128
ddp = Taskflow("dependency_parsing")
129-
ddp("百度是一家高科技公司")
130-
>>> [{'word': ['百度', '', '一家', '高科技', '公司'], 'head': ['2', '0', '5', '5', '2'], 'deprel': ['SBV', 'HED', 'ATT', 'ATT', 'VOB']}]
129+
ddp("9月9日上午纳达尔在亚瑟·阿什球场击败俄罗斯球员梅德韦杰夫")
130+
>>> [{'word': ['9月9日', '上午', '纳达尔', '', '亚瑟·阿什球场', '击败', '俄罗斯', '球员', '梅德韦杰夫'], 'head': [2, 6, 6, 5, 6, 0, 8, 9, 6], 'deprel': ['ATT', 'ADV', 'SBV', 'MT', 'ADV', 'HED', 'ATT', 'ATT', 'VOB']}]
131131

132-
ddp(["百度是一家高科技公司", "他送了一本书"])
133-
>>> [{'word': ['百度', '', '一家', '高科技', '公司'], 'head': ['2', '0', '5', '5', '2'], 'deprel': ['SBV', 'HED', 'ATT', 'ATT', 'VOB']}, {'word': ['', '', '', '一本', ''], 'head': ['2', '0', '2', '5', '2'], 'deprel': ['SBV', 'HED', 'MT', 'ATT', 'VOB']}]
132+
ddp(["9月9日上午纳达尔在亚瑟·阿什球场击败俄罗斯球员梅德韦杰夫", "他送了一本书"])
133+
>>> [{'word': ['9月9日', '上午', '纳达尔', '', '亚瑟·阿什球场', '击败', '俄罗斯', '球员', '梅德韦杰夫'], 'head': [2, 6, 6, 5, 6, 0, 8, 9, 6], 'deprel': ['ATT', 'ADV', 'SBV', 'MT', 'ADV', 'HED', 'ATT', 'ATT', 'VOB']}, {'word': ['', '', '', '一本', ''], 'head': [2, 0, 2, 5, 2], 'deprel': ['SBV', 'HED', 'MT', 'ATT', 'VOB']}]
134134

135135
# 输出概率值和词性标签
136136
ddp = Taskflow("dependency_parsing", prob=True, use_pos=True)
137-
ddp("百度是一家高科技公司")
138-
>>> [{'word': ['百度', '', '一家', '高科技', '公司'], 'postag': ['ORG', 'v', 'm', 'n', 'n'], 'head': ['2', '0', '5', '5', '2'], 'deprel': ['SBV', 'HED', 'ATT', 'ATT', 'VOB'], 'prob': [1.0, 1.0, 1.0, 1.0, 1.0]}]
137+
ddp("9月9日上午纳达尔在亚瑟·阿什球场击败俄罗斯球员梅德韦杰夫")
138+
>>> [{'word': ['9月9日', '上午', '纳达尔', '', '亚瑟·阿什', '球场', '击败', '俄罗斯', '球员', '梅德韦杰夫'], 'head': [2, 7, 7, 6, 6, 7, 0, 9, 10, 7], 'deprel': ['ATT', 'ADV', 'SBV', 'MT', 'ATT', 'ADV', 'HED', 'ATT', 'ATT', 'VOB'], 'postag': ['TIME', 'TIME', 'PER', 'p', 'PER', 'n', 'v', 'LOC', 'n', 'PER'], 'prob': [0.79, 0.98, 1.0, 0.49, 0.97, 0.86, 1.0, 0.85, 0.97, 0.99]}]
139139

140140
# 使用ddparser-ernie-1.0进行预测
141141
ddp = Taskflow("dependency_parsing", model="ddparser-ernie-1.0")
142-
ddp("百度是一家高科技公司")
143-
>>> [{'word': ['百度', '', '一家', '高科技', '公司'], 'head': ['2', '0', '5', '5', '2'], 'deprel': ['SBV', 'HED', 'ATT', 'ATT', 'VOB']}]
142+
ddp("9月9日上午纳达尔在亚瑟·阿什球场击败俄罗斯球员梅德韦杰夫")
143+
>>> [{'word': ['9月9日', '上午', '纳达尔', '', '亚瑟·阿什球场', '击败', '俄罗斯', '球员', '梅德韦杰夫'], 'head': [2, 6, 6, 5, 6, 0, 8, 9, 6], 'deprel': ['ATT', 'ADV', 'SBV', 'MT', 'ADV', 'HED', 'ATT', 'ATT', 'VOB']}]
144144
```
145145

146146
### 情感分析
@@ -149,12 +149,11 @@ ddp("百度是一家高科技公司")
149149
from paddlenlp import Taskflow
150150

151151
senta = Taskflow("sentiment_analysis")
152-
senta("怀着十分激动的心情放映,可是看着看着发现,在放映完毕后,出现一集米老鼠的动画片")
153-
>>> [{'text': '怀着十分激动的心情放映,可是看着看着发现,在放映完毕后,出现一集米老鼠的动画片', 'label': 'negative', 'score': 0.6691398620605469}]
152+
senta("这个产品用起来真的很流畅,我非常喜欢")
153+
>>> [{'text': '这个产品用起来真的很流畅,我非常喜欢', 'label': 'positive', 'score': 0.9938690066337585}]
154154

155-
senta(["怀着十分激动的心情放映,可是看着看着发现,在放映完毕后,出现一集米老鼠的动画片",
156-
"作为老的四星酒店,房间依然很整洁,相当不错。机场接机服务很好,可以在车上办理入住手续,节省时间"])
157-
>>> [{'text': '怀着十分激动的心情放映,可是看着看着发现,在放映完毕后,出现一集米老鼠的动画片', 'label': 'negative', 'score': 0.6691398620605469}, {'text': '作为老的四星酒店,房间依然很整洁,相当不错。机场接机服务很好,可以在车上办理入住手续,节省时间', 'label': 'positive', 'score': 0.9857505559921265}]
155+
senta(["这个产品用起来真的很流畅,我非常喜欢", "作为老的四星酒店,房间依然很整洁,相当不错。机场接机服务很好,可以在车上办理入住手续,节省时间"])
156+
>>> [{'text': '这个产品用起来真的很流畅,我非常喜欢', 'label': 'positive', 'score': 0.9938690066337585}, {'text': '作为老的四星酒店,房间依然很整洁,相当不错。机场接机服务很好,可以在车上办理入住手续,节省时间', 'label': 'positive', 'score': 0.985750675201416}]
158157

159158
# 使用SKEP情感分析预训练模型进行预测
160159
senta = Taskflow("sentiment_analysis", model="skep_ernie_1.0_large_ch")

paddlenlp/taskflow/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ def download_file(save_dir, filename, url, md5=None):
4545
url(string): The url downling the file.
4646
md5(string, optional): The md5 value that checking the version downloaded.
4747
"""
48-
logger.disable()
4948
fullname = os.path.join(save_dir, filename)
5049
if os.path.exists(fullname):
5150
if md5 and (not md5file(fullname) == md5):
51+
logger.disable()
5252
get_path_from_url(url, save_dir, md5)
5353
else:
54+
logger.info("Downloading {} from {}".format(filename, url))
55+
logger.disable()
5456
get_path_from_url(url, save_dir, md5)
5557
logger.enable()
5658
return fullname

paddlenlp/utils/downloader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
except:
3232

3333
class tqdm(object):
34-
def __init__(self, total=None):
34+
def __init__(self, total=None, **kwargs):
3535
self.total = total
3636
self.n = 0
3737

@@ -206,7 +206,7 @@ def _download(url, path, md5sum=None):
206206
total_size = req.headers.get('content-length')
207207
with open(tmp_fullname, 'wb') as f:
208208
if total_size:
209-
with tqdm(total=(int(total_size) + 1023) // 1024) as pbar:
209+
with tqdm(total=(int(total_size) + 1023) // 1024, unit='B', unit_scale=True) as pbar:
210210
for chunk in req.iter_content(chunk_size=1024):
211211
f.write(chunk)
212212
pbar.update(1)

0 commit comments

Comments
 (0)