Commits

Ben Wing committed c3769ca

Eliminate need for hard-to-understand contravariance marking

Comments (0)

Files changed (2)

src/main/scala/opennlp/textgrounder/geolocate/SphereEvaluation.scala

   driver: GeolocateDocumentTypeDriver
 ) extends RankedCellGridEvaluator[
   SphereCoord, SphereDocument, SphereCell, SphereCellGrid,
-  RankedSphereDocumentEvaluationResult
+  SphereDocumentEvaluationResult
 ](strategy, stratname, driver) {
   def create_grouped_eval_stats(driver: GridLocateDriver,
     cell_grid: SphereCellGrid, results_by_range: Boolean) =
-    new GroupedSphereDocumentEvalStats(driver,
-      cell_grid, results_by_range, is_ranked = true)
+    new GroupedSphereDocumentEvalStats(
+      driver, cell_grid, results_by_range, is_ranked = true)
   def create_cell_evaluation_result(document: SphereDocument,
       pred_cell: SphereCell, true_rank: Int) =
     new RankedSphereDocumentEvaluationResult(document, pred_cell, true_rank)
   val num_nearest_neighbors = driver.params.num_nearest_neighbors
 
   def print_individual_result(doctag: String, document: SphereDocument,
-      result: RankedSphereDocumentEvaluationResult,
+      result: SphereDocumentEvaluationResult,
       pred_cells: Array[(SphereCell, Double)]) {
     errprint("%s:Document %s:", doctag, document)
     // errprint("%s:Document distribution: %s", doctag, document.dist)
     errprint("%s:  %d types, %f tokens",
       doctag, document.dist.num_word_types, document.dist.num_word_tokens)
-    errprint("%s:  true cell at rank: %s", doctag, result.true_rank)
+    errprint("%s:  true cell at rank: %s", doctag,
+      result.asInstanceOf[RankedSphereDocumentEvaluationResult].true_rank)
     errprint("%s:  true cell: %s", doctag, result.true_cell)
     for (i <- 0 until 5) {
       errprint("%s:  Predicted cell (at rank %s, kl-div %s): %s",
   mean_shift_max_stddev, mean_shift_max_iterations) {
   def create_grouped_eval_stats(driver: GridLocateDriver,
     cell_grid: SphereCellGrid, results_by_range: Boolean) =
-    new GroupedSphereDocumentEvalStats(driver,
-      cell_grid, results_by_range, is_ranked = false)
+    new GroupedSphereDocumentEvalStats(
+      driver, cell_grid, results_by_range, is_ranked = false)
   def create_coord_evaluation_result(document: SphereDocument,
       cell_grid: SphereCellGrid, pred_coord: SphereCoord) =
     new CoordSphereDocumentEvaluationResult(document, cell_grid, pred_coord)

src/main/scala/opennlp/textgrounder/gridlocate/Evaluation.scala

   TDoc <: DistDocument[TCoord],
   TCell <: GeoCell[TCoord, TDoc],
   TGrid <: CellGrid[TCoord, TDoc, TCell],
-  /* The following - sign is necessary (indicating contravariance) because of
-     the use of subclasses like RankedSphereDocumentEvaluationResult in
-     RankedSphereCellGridEvaluator, whereas GroupedSphereDocumentEvalStats
-     merely uses SphereDocumentEvaluationResult. */
-  -TEvalRes <: DocumentEvaluationResult[TCoord, TDoc, TCell, TGrid]
+  TEvalRes <: DocumentEvaluationResult[TCoord, TDoc, TCell, TGrid]
 ](
   driver_stats: ExperimentDriverStats,
   cell_grid: TGrid,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.