Commits

dic...@c202-108.longhorn  committed b8da142

output results to file sorted by kldiv in article data format

  • Participants
  • Parent commits 92b6419

Comments (0)

Files changed (2)

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

           most_popular_document, mostpopdoc_links)
       else ""
 
-    "GeoCell(%s%s%s, %d documents(dist), %d documents(links), %d links)" format (
-      describe_location(), unfinished, contains,
-      word_dist_wrapper.num_docs_for_word_dist,
-      word_dist_wrapper.num_docs_for_links,
-      word_dist_wrapper.incoming_links)
+    "GeoCell(%s)" format (
+      describe_location()
+    )
   }
 
   // def __repr__() = {

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

 /**
  * General trait for classes representing result of evaluating a document.
  */
-trait EvaluationResult {
+abstract class EvaluationResult(val kldiv: Double) {
+  def this() = this(0d)
 }
 
 /**
     CellType <: GeoCell[CoordType, DocumentType]](
   document: DocumentType,
   pred_cell: CellType,
+  override val kldiv: Double,
   true_rank: Int
-) extends EvaluationResult {
+) extends EvaluationResult(kldiv) {
   val true_cell = pred_cell.cell_grid.find_best_cell_for_coord(document.coord)
   val num_docs_in_true_cell = true_cell.word_dist_wrapper.num_docs_for_word_dist
   val true_center = true_cell.get_center_coord()
 class SphereDocumentEvaluationResult(
   document: SphereDocument,
   pred_cell: SphereCell,
+  override val kldiv: Double,
   true_rank: Int
 ) extends DocumentEvaluationResult[SphereCoord, SphereDocument, SphereCell](
-  document, pred_cell, true_rank
+  document, pred_cell, kldiv, true_rank
 ) {
   val true_degdist = document.degree_distance_to_coord(true_center)
   val pred_degdist = document.degree_distance_to_coord(pred_center)
         get_computed_results()
       }
     val result =
-      new SphereDocumentEvaluationResult(document, pred_cells(0)._1, true_rank)
+      new SphereDocumentEvaluationResult(document, pred_cells(0)._1, pred_cells(0)._2, true_rank)
 
     val want_indiv_results =
       !driver.params.oracle_results && !driver.params.no_individual_results
     errprint("Ending operation at %s", curtimehuman())
     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")
+      }
+    } finally {
+      pw.close()
+    }
   }
 }
-