Commit 2243d30c authored by Xin Pan's avatar Xin Pan Committed by GitHub
Browse files

Merge pull request #2250 from cclauss/patch-15

file() was removed in Python 3, use open() instead
parents d1cdc444 f70641f2
......@@ -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
......@@ -43,7 +46,7 @@ class SampleBuilder:
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))
......@@ -55,7 +58,7 @@ class SampleBuilder:
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))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment