Created
July 4, 2016 11:39
-
-
Save andrewclegg/5cac106a8352d49b7c69571db6973ebb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class InputIterator(file: File) extends Iterable[LabelledDocument] { | |
val lines = Source.fromFile(file).getLines() | |
override def iterator: Iterator[LabelledDocument] = { | |
lines.map { | |
line => | |
val fields = line.split("\t") | |
val label = fields(0) | |
val text = fields(2) // Ignore 1 as this is just the active/inactive flag | |
val doc = new LabelledDocument() | |
doc.setLabel(label) | |
doc.setContent(text) | |
doc | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment