Skip to content

Commit

Permalink
[algorithm] commandline querying
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondtay committed Apr 11, 2015
1 parent 2b11053 commit 80f4dd9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/scala/advanced/InvertedIndex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ object InvertedIndex extends App {
line =>
val xs = line.split(sep) // array of strings or empty array
val key = xs.head
println(s"Analyzing data for $key")
for {
w <- xs.tail
} {
Expand All @@ -42,6 +43,19 @@ object InvertedIndex extends App {
ts = addTm(ts, w, key)
}
}
println("Analysis done.")
stdin.getLines.foreach {
query =>
println(s"query is $query..")
st.contains(query) match {
case true => st(query).map(x => println(" " + x))
case false =>
ts.contains(query) match {
case true => ts(query).map(x => println(" " + x))
case false => println("Didn't find anything.Try again or hit ctrl-c to quit")
}
}
}
}
}

Expand Down

0 comments on commit 80f4dd9

Please sign in to comment.