Skip to content
This repository has been archived by the owner on May 29, 2020. It is now read-only.

Eval label exception fix #19

Merged
merged 3 commits into from
Feb 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/scala/junto/Junto.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object Junto {
conf.evalLabelFile.toOption match {

case Some(evalLabelFile) => {
val evalLabelSequence = getLabels(evalLabelFile, separator)
val evalLabelSequence = getLabels(evalLabelFile, skipHeader = true)

val evalLabels = (for {
LabelSpec(nodeName, label, strength) <- evalLabelSequence
Expand All @@ -45,6 +45,7 @@ object Junto {
}

// Output predictions if an output file is specified.
// output predictions are comma seperated
conf.outputFile.toOption match {
case Some(outputFile) =>

Expand Down
14 changes: 9 additions & 5 deletions src/main/scala/junto/graph/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@ package object graph {
}
}

def getLabels(inputFile: String, separator: Char = ','): Iterator[LabelSpec] = {
def getLabels(inputFile: String, separator: Char = ',', skipHeader: Boolean = false): Iterator[LabelSpec] = {
val lines = getSource(inputFile).getLines

val header = if (skipHeader) lines.next() else None
// skip the header in eval files for now (perhaps use it later to identify labels with probabilities)
for {
line <- getSource(inputFile).getLines
line <- lines
items = line.split(separator)
} yield {
val source = items(0)
val target = items(1)
val node = items(0)
val label = items(1)
val weight = if (items.length == 2) 1.0 else items(2).toDouble
LabelSpec(source, target, weight)
LabelSpec(node, label, weight)
}
}

Expand Down