Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
2243d30c
Commit
2243d30c
authored
Aug 22, 2017
by
Xin Pan
Committed by
GitHub
Aug 22, 2017
Browse files
Merge pull request #2250 from cclauss/patch-15
file() was removed in Python 3, use open() instead
parents
d1cdc444
f70641f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
qa_kg/util/data_reader.py
qa_kg/util/data_reader.py
+6
-3
No files found.
qa_kg/util/data_reader.py
View file @
2243d30c
...
@@ -14,7 +14,10 @@
...
@@ -14,7 +14,10 @@
# ==============================================================================
# ==============================================================================
from
collections
import
namedtuple
from
collections
import
namedtuple
from
Queue
import
Queue
try
:
from
queue
import
Queue
# Python 3
except
ImportError
:
from
Queue
import
Queue
# Python 2
import
re
import
re
import
threading
import
threading
import
numpy
as
np
import
numpy
as
np
...
@@ -43,7 +46,7 @@ class SampleBuilder:
...
@@ -43,7 +46,7 @@ class SampleBuilder:
def
read_kb
(
self
):
def
read_kb
(
self
):
kb_raw
=
[]
kb_raw
=
[]
for
line
in
file
(
self
.
config
.
KB_file
):
for
line
in
open
(
self
.
config
.
KB_file
):
sub
,
rel
,
obj
=
line
.
strip
().
split
(
'|'
)
sub
,
rel
,
obj
=
line
.
strip
().
split
(
'|'
)
kb_raw
.
append
((
sub
,
rel
,
obj
))
kb_raw
.
append
((
sub
,
rel
,
obj
))
tf
.
logging
.
info
(
'# of KB records: %d'
%
len
(
kb_raw
))
tf
.
logging
.
info
(
'# of KB records: %d'
%
len
(
kb_raw
))
...
@@ -55,7 +58,7 @@ class SampleBuilder:
...
@@ -55,7 +58,7 @@ class SampleBuilder:
raw
=
[]
raw
=
[]
tf
.
logging
.
info
(
tf
.
logging
.
info
(
'Reading data file {}'
.
format
(
self
.
config
.
data_files
[
name
]))
'Reading data file {}'
.
format
(
self
.
config
.
data_files
[
name
]))
for
line
in
file
(
self
.
config
.
data_files
[
name
]):
for
line
in
open
(
self
.
config
.
data_files
[
name
]):
question
,
answers
=
line
.
strip
().
split
(
'
\t
'
)
question
,
answers
=
line
.
strip
().
split
(
'
\t
'
)
question
=
question
.
replace
(
'],'
,
']'
)
# ignore ',' in the template
question
=
question
.
replace
(
'],'
,
']'
)
# ignore ',' in the template
raw
.
append
((
question
,
answers
))
raw
.
append
((
question
,
answers
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment