Skip to content

Commit

Permalink
Merge pull request tensorflow#2250 from cclauss/patch-15
Browse files Browse the repository at this point in the history
file() was removed in Python 3, use open() instead
  • Loading branch information
panyx0718 authored Aug 22, 2017
2 parents d1cdc44 + f70641f commit 2243d30
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions qa_kg/util/data_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
# ==============================================================================

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 threading
import numpy as np
Expand Down Expand Up @@ -43,7 +46,7 @@ def __init__(self, config):

def read_kb(self):
kb_raw = []
for line in file(self.config.KB_file):
for line in open(self.config.KB_file):
sub, rel, obj = line.strip().split('|')
kb_raw.append((sub, rel, obj))
tf.logging.info('# of KB records: %d' % len(kb_raw))
Expand All @@ -55,7 +58,7 @@ def read_raw_data(self):
raw = []
tf.logging.info(
'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 = question.replace('],', ']') # ignore ',' in the template
raw.append((question, answers))
Expand Down

0 comments on commit 2243d30

Please sign in to comment.