Iterate over the corpus, returning one sparse vector at a time.
for lineNo, line in enumerate(open(self.fname)):
if line.startswith("//"):
continue
parts = line.split()
target, fields = parts[0], [part.rsplit(":", 1) for part in parts[1:]]
After Change
Iterate over the corpus, returning one sparse vector at a time.
for lineNo, line in enumerate(open(self.fname)):
line = line[: line.find("//")].strip()
if not line:
continue // ignore comments and empty lines
parts = line.split()
if not parts: