File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 1414# ==============================================================================
1515
1616from collections import namedtuple
17- from Queue import Queue
17+ try :
18+ from queue import Queue # Python 3
19+ except ImportError :
20+ from Queue import Queue # Python 2
1821import re
1922import threading
2023import numpy as np
@@ -43,7 +46,7 @@ def __init__(self, config):
4346
4447 def read_kb (self ):
4548 kb_raw = []
46- for line in file (self .config .KB_file ):
49+ for line in open (self .config .KB_file ):
4750 sub , rel , obj = line .strip ().split ('|' )
4851 kb_raw .append ((sub , rel , obj ))
4952 tf .logging .info ('# of KB records: %d' % len (kb_raw ))
@@ -55,7 +58,7 @@ def read_raw_data(self):
5558 raw = []
5659 tf .logging .info (
5760 'Reading data file {}' .format (self .config .data_files [name ]))
58- for line in file (self .config .data_files [name ]):
61+ for line in open (self .config .data_files [name ]):
5962 question , answers = line .strip ().split ('\t ' )
6063 question = question .replace ('],' , ']' ) # ignore ',' in the template
6164 raw .append ((question , answers ))
You can’t perform that action at this time.
0 commit comments