Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
dc5abb6f
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dc5abb6f
编写于
10月 16, 2019
作者:
Y
Yibing Liu
提交者:
pkpk
10月 16, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix windows encoding problem (#3595) (#3597)
上级
fc437d49
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
26 addition
and
10 deletion
+26
-10
PaddleNLP/language_representations_kit/BERT/reader/cls.py
PaddleNLP/language_representations_kit/BERT/reader/cls.py
+2
-1
PaddleNLP/language_representations_kit/BERT/reader/pretraining.py
...P/language_representations_kit/BERT/reader/pretraining.py
+2
-1
PaddleNLP/language_representations_kit/BERT/reader/squad.py
PaddleNLP/language_representations_kit/BERT/reader/squad.py
+8
-7
PaddleNLP/language_representations_kit/BERT/run_classifier.py
...leNLP/language_representations_kit/BERT/run_classifier.py
+4
-0
PaddleNLP/language_representations_kit/BERT/run_squad.py
PaddleNLP/language_representations_kit/BERT/run_squad.py
+4
-0
PaddleNLP/language_representations_kit/BERT/tokenization.py
PaddleNLP/language_representations_kit/BERT/tokenization.py
+2
-1
PaddleNLP/language_representations_kit/BERT/train.py
PaddleNLP/language_representations_kit/BERT/train.py
+4
-0
未找到文件。
PaddleNLP/language_representations_kit/BERT/reader/cls.py
浏览文件 @
dc5abb6f
...
...
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
io
import
os
import
types
import
csv
...
...
@@ -100,7 +101,7 @@ class DataProcessor(object):
@
classmethod
def
_read_tsv
(
cls
,
input_file
,
quotechar
=
None
):
"""Reads a tab separated value file."""
with
open
(
input_file
,
"r
"
)
as
f
:
with
io
.
open
(
input_file
,
"r"
,
encoding
=
"utf8
"
)
as
f
:
reader
=
csv
.
reader
(
f
,
delimiter
=
"
\t
"
,
quotechar
=
quotechar
)
lines
=
[]
for
line
in
reader
:
...
...
PaddleNLP/language_representations_kit/BERT/reader/pretraining.py
浏览文件 @
dc5abb6f
...
...
@@ -15,6 +15,7 @@
from
__future__
import
print_function
from
__future__
import
division
import
io
import
os
import
numpy
as
np
import
types
...
...
@@ -125,7 +126,7 @@ class DataReader(object):
def
load_vocab
(
self
,
vocab_file
):
"""Loads a vocabulary file into a dictionary."""
vocab
=
collections
.
OrderedDict
()
fin
=
open
(
vocab_file
)
fin
=
io
.
open
(
vocab_file
,
encoding
=
"utf8"
)
for
num
,
line
in
enumerate
(
fin
):
items
=
self
.
convert_to_unicode
(
line
.
strip
()).
split
(
"
\t
"
)
if
len
(
items
)
>
2
:
...
...
PaddleNLP/language_representations_kit/BERT/reader/squad.py
浏览文件 @
dc5abb6f
...
...
@@ -14,6 +14,7 @@
# limitations under the License.
"""Run BERT on SQuAD 1.1 and SQuAD 2.0."""
import
io
import
six
import
math
import
json
...
...
@@ -95,7 +96,7 @@ class InputFeatures(object):
def
read_squad_examples
(
input_file
,
is_training
,
version_2_with_negative
=
False
):
"""Read a SQuAD json file into a list of SquadExample."""
with
open
(
input_file
,
"r
"
)
as
reader
:
with
io
.
open
(
input_file
,
"r"
,
encoding
=
"utf8
"
)
as
reader
:
input_data
=
json
.
load
(
reader
)[
"data"
]
def
is_whitespace
(
c
):
...
...
@@ -763,15 +764,15 @@ def write_predictions(all_examples, all_features, all_results, n_best_size,
all_nbest_json
[
example
.
qas_id
]
=
nbest_json
with
open
(
output_prediction_file
,
"w
"
)
as
writer
:
writer
.
write
(
json
.
dumps
(
all_predictions
,
indent
=
4
)
+
"
\n
"
)
with
io
.
open
(
output_prediction_file
,
"w"
,
encoding
=
"utf8
"
)
as
writer
:
writer
.
write
(
json
.
dumps
(
all_predictions
,
indent
=
4
)
+
u
"
\n
"
)
with
open
(
output_nbest_file
,
"w
"
)
as
writer
:
writer
.
write
(
json
.
dumps
(
all_nbest_json
,
indent
=
4
)
+
"
\n
"
)
with
io
.
open
(
output_nbest_file
,
"w"
,
encoding
=
"utf8
"
)
as
writer
:
writer
.
write
(
json
.
dumps
(
all_nbest_json
,
indent
=
4
)
+
u
"
\n
"
)
if
version_2_with_negative
:
with
open
(
output_null_log_odds_file
,
"w
"
)
as
writer
:
writer
.
write
(
json
.
dumps
(
scores_diff_json
,
indent
=
4
)
+
"
\n
"
)
with
io
.
open
(
output_null_log_odds_file
,
"w"
,
encoding
=
"utf8
"
)
as
writer
:
writer
.
write
(
json
.
dumps
(
scores_diff_json
,
indent
=
4
)
+
u
"
\n
"
)
def
get_final_text
(
pred_text
,
orig_text
,
do_lower_case
,
verbose
):
...
...
PaddleNLP/language_representations_kit/BERT/run_classifier.py
浏览文件 @
dc5abb6f
...
...
@@ -17,6 +17,10 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
sys
reload
(
sys
)
sys
.
setdefaultencoding
(
'utf8'
)
import
os
import
time
import
argparse
...
...
PaddleNLP/language_representations_kit/BERT/run_squad.py
浏览文件 @
dc5abb6f
...
...
@@ -17,6 +17,10 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
sys
reload
(
sys
)
sys
.
setdefaultencoding
(
'utf8'
)
import
argparse
import
collections
import
multiprocessing
...
...
PaddleNLP/language_representations_kit/BERT/tokenization.py
浏览文件 @
dc5abb6f
...
...
@@ -21,6 +21,7 @@ from __future__ import print_function
import
collections
import
unicodedata
import
six
import
io
def
convert_to_unicode
(
text
):
...
...
@@ -69,7 +70,7 @@ def printable_text(text):
def
load_vocab
(
vocab_file
):
"""Loads a vocabulary file into a dictionary."""
vocab
=
collections
.
OrderedDict
()
fin
=
open
(
vocab_file
)
fin
=
io
.
open
(
vocab_file
,
encoding
=
"utf8"
)
for
num
,
line
in
enumerate
(
fin
):
items
=
convert_to_unicode
(
line
.
strip
()).
split
(
"
\t
"
)
if
len
(
items
)
>
2
:
...
...
PaddleNLP/language_representations_kit/BERT/train.py
浏览文件 @
dc5abb6f
...
...
@@ -17,6 +17,10 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
sys
reload
(
sys
)
sys
.
setdefaultencoding
(
'utf8'
)
import
os
import
time
import
sys
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录