Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
b9cbe195
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看板
未验证
提交
b9cbe195
编写于
10月 30, 2019
作者:
Y
Yibing Liu
提交者:
GitHub
10月 30, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix py3 problem on windows (#3818)
上级
3858f51e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
18 deletion
+19
-18
PaddleNLP/PaddleLARK/BERT/reader/squad.py
PaddleNLP/PaddleLARK/BERT/reader/squad.py
+19
-18
未找到文件。
PaddleNLP/PaddleLARK/BERT/reader/squad.py
浏览文件 @
b9cbe195
...
...
@@ -307,32 +307,33 @@ def convert_examples_to_features(
end_position
=
0
if
example_index
<
3
:
print
(
"*** Example ***"
)
print
(
"unique_id: %s"
%
(
unique_id
))
print
(
"example_index: %s"
%
(
example_index
))
print
(
"doc_span_index: %s"
%
(
doc_span_index
))
print
(
"tokens: %s"
%
" "
.
join
(
print
(
u
"*** Example ***"
)
print
(
u
"unique_id: %s"
%
(
unique_id
))
print
(
u
"example_index: %s"
%
(
example_index
))
print
(
u
"doc_span_index: %s"
%
(
doc_span_index
))
print
(
u
"tokens: %s"
%
" "
.
join
(
[
tokenization
.
printable_text
(
x
)
for
x
in
tokens
]))
print
(
"token_to_orig_map: %s"
%
" "
.
join
([
print
(
u
"token_to_orig_map: %s"
%
" "
.
join
([
"%d:%d"
%
(
x
,
y
)
for
(
x
,
y
)
in
six
.
iteritems
(
token_to_orig_map
)
]))
print
(
"token_is_max_context: %s"
%
" "
.
join
([
print
(
u
"token_is_max_context: %s"
%
" "
.
join
([
"%d:%s"
%
(
x
,
y
)
for
(
x
,
y
)
in
six
.
iteritems
(
token_is_max_context
)
]))
print
(
"input_ids: %s"
%
" "
.
join
([
str
(
x
)
for
x
in
input_ids
]))
print
(
"input_mask: %s"
%
" "
.
join
([
str
(
x
)
for
x
in
input_mask
]))
print
(
"segment_ids: %s"
%
print
(
u
"input_ids: %s"
%
" "
.
join
([
str
(
x
)
for
x
in
input_ids
]))
print
(
u
"input_mask: %s"
%
" "
.
join
([
str
(
x
)
for
x
in
input_mask
]))
print
(
u
"segment_ids: %s"
%
" "
.
join
([
str
(
x
)
for
x
in
segment_ids
]))
if
is_training
and
example
.
is_impossible
:
print
(
"impossible example"
)
print
(
u
"impossible example"
)
if
is_training
and
not
example
.
is_impossible
:
answer_text
=
" "
.
join
(
tokens
[
start_position
:(
end_position
+
1
)])
print
(
"start_position: %d"
%
(
start_position
))
print
(
"end_position: %d"
%
(
end_position
))
print
(
"answer: %s"
%
print
(
u
"start_position: %d"
%
(
start_position
))
print
(
u
"end_position: %d"
%
(
end_position
))
print
(
u
"answer: %s"
%
(
tokenization
.
printable_text
(
answer_text
)))
feature
=
InputFeatures
(
...
...
@@ -825,7 +826,7 @@ def get_final_text(pred_text, orig_text, do_lower_case, verbose):
start_position
=
tok_text
.
find
(
pred_text
)
if
start_position
==
-
1
:
if
verbose
:
print
(
"Unable to find text: '%s' in '%s'"
%
(
pred_text
,
orig_text
))
print
(
u
"Unable to find text: '%s' in '%s'"
%
(
pred_text
,
orig_text
))
return
orig_text
end_position
=
start_position
+
len
(
pred_text
)
-
1
...
...
@@ -834,7 +835,7 @@ def get_final_text(pred_text, orig_text, do_lower_case, verbose):
if
len
(
orig_ns_text
)
!=
len
(
tok_ns_text
):
if
verbose
:
print
(
"Length not equal after stripping spaces: '%s' vs '%s'"
,
print
(
u
"Length not equal after stripping spaces: '%s' vs '%s'"
,
orig_ns_text
,
tok_ns_text
)
return
orig_text
...
...
@@ -852,7 +853,7 @@ def get_final_text(pred_text, orig_text, do_lower_case, verbose):
if
orig_start_position
is
None
:
if
verbose
:
print
(
"Couldn't map start position"
)
print
(
u
"Couldn't map start position"
)
return
orig_text
orig_end_position
=
None
...
...
@@ -863,7 +864,7 @@ def get_final_text(pred_text, orig_text, do_lower_case, verbose):
if
orig_end_position
is
None
:
if
verbose
:
print
(
"Couldn't map end position"
)
print
(
u
"Couldn't map end position"
)
return
orig_text
output_text
=
orig_text
[
orig_start_position
:(
orig_end_position
+
1
)]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录