I have a Scala code in which i am creating a new file in resource directory.
And then doing some work around with that new file. (in my case splitting the file)
logger.debug("Run training process...")
InferTopics.main(("--input " + tmpDir + "new_corpus.mallet --inferencer " + tmpDir + "inferencer " + "--output-doc-topics " + tmpDir + "doc-topics-new.txt --num-iterations 1000").split(" "))
logger.debug("Inferring process finished.")
In the below code of line I am trying to split the new file created above however file is not available unless I am terminating the code.
val lines = Source
.fromResource("doc-topics-new.txt")
.getLines
.toList
.drop(1) match {
case Nil => List.empty
case x :: xs => x.split(" ").drop(2).mkString(" ") :: xs
}
In a gist, The problem is File is only getting created once i am terminating the code and not after the call of code to create the file.
Please note: The new file is getting generated by calling a mallet module, which infer an input file and create a new one 'doc-topics-new.txt'.
Any suggestion