logger.info("initializing corpus reader from %s" % input)
self.input, self.transposed = input, transposed
if isinstance(input, string_types):
input = open(input)
header = next(input).strip()
if not header.lower().startswith("%%matrixmarket matrix coordinate real general"):
raise ValueError("File %s not in Matrix Market format with coordinate real general; instead found: \n%s" %
(self.input, header))
After Change
logger.info("initializing corpus reader from %s" % input)
self.input, self.transposed = input, transposed
with utils.file_or_filename(self.input) as lines:
header = utils.to_unicode(next(lines)).strip()
if not header.lower().startswith("%%matrixmarket matrix coordinate real general"):
raise ValueError("File %s not in Matrix Market format with coordinate real general; instead found: \n%s" %
(self.input, header))