Commits

Anonymous committed e2e9bd6

added "results-file" flag, which dumps output to that file only if not null

  • Participants
  • Parent commits b8da142

Comments (0)

Files changed (2)

File src/main/scala/opennlp/textgrounder/geolocate/Evaluation.scala

     evalobj.output_results(isfinal = true)
     errprint("Ending final results for strategy %s", stratname)
 
-    // Print some shit.
-    import java.io.{File, PrintWriter}
-    val pw = new PrintWriter(new File("kldivs"))
-    try {
-      val outfields = GeoDocumentData.combined_document_data_outfields
-      pw.println(outfields mkString "\t")
-      for ((k, v) <- results.toList.sortWith((x, y) => x._2.kldiv < y._2.kldiv)) {
-        val argh = k.asInstanceOf[GeoDocument[SphereCoord]]
-        argh.optcoord = Option(v.asInstanceOf[SphereDocumentEvaluationResult].pred_center)
-        pw.println(argh.get_fields(outfields) mkString "\t")
+    if (Params.results_file != null) {
+      // Print some shit.
+      import java.io.{File, PrintWriter}
+      val pw = new PrintWriter(new File(Params.results_file))
+      try {
+        val outfields = GeoDocumentData.combined_document_data_outfields
+        pw.println(outfields mkString "\t")
+        for ((k, v) <- results.toList.sortWith((x, y) => x._2.kldiv < y._2.kldiv)) {
+          val argh = k.asInstanceOf[GeoDocument[SphereCoord]]
+          argh.optcoord = Option(v.asInstanceOf[SphereDocumentEvaluationResult].pred_center)
+          pw.println(argh.get_fields(outfields) mkString "\t")
+        }
+      } finally {
+        pw.close()
       }
-    } finally {
-      pw.close()
     }
   }
 }

File src/main/scala/opennlp/textgrounder/geolocate/Geolocate.scala

   protected val ap =
     if (parser == null) new ArgParser("unknown") else parser
 
+  var results_file =
+    ap.option[String]("results-file",
+      metavar = "FILE",
+      help = """File to contain the results of geolocation in the 'article data'
+format. Each line is a document whose coordinates are the center of the most
+similar score, sorted in ascending order by score. (This works for KL divergence
+but is untested on other similarity metrics.) """)
+
   //// Input files
   var stopwords_file =
     ap.option[String]("stopwords-file",