You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2011/11/11 09:53:56 UTC

svn commit: r1200777 - /incubator/opennlp/trunk/opennlp-maxent/src/main/java/opennlp/maxent/io/GISModelWriter.java

Author: joern
Date: Fri Nov 11 08:53:56 2011
New Revision: 1200777

URL: http://svn.apache.org/viewvc?rev=1200777&view=rev
Log:
OPENNLP-370 Now uses generics. Thanks to Aliaksandr Autayeu for providing a patch.

Modified:
    incubator/opennlp/trunk/opennlp-maxent/src/main/java/opennlp/maxent/io/GISModelWriter.java

Modified: incubator/opennlp/trunk/opennlp-maxent/src/main/java/opennlp/maxent/io/GISModelWriter.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-maxent/src/main/java/opennlp/maxent/io/GISModelWriter.java?rev=1200777&r1=1200776&r2=1200777&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-maxent/src/main/java/opennlp/maxent/io/GISModelWriter.java (original)
+++ incubator/opennlp/trunk/opennlp-maxent/src/main/java/opennlp/maxent/io/GISModelWriter.java Fri Nov 11 08:53:56 2011
@@ -87,12 +87,12 @@ public abstract class GISModelWriter ext
     // The sorting is done so that we actually can write this out more
     // compactly than as the entire list.
     ComparablePredicate[] sorted = sortValues();
-    List compressed = compressOutcomes(sorted);
+    List<List<ComparablePredicate>> compressed = compressOutcomes(sorted);
 
     writeInt(compressed.size());
 
     for (int i = 0; i < compressed.size(); i++) {
-      List a = (List) compressed.get(i);
+      List a = compressed.get(i);
       writeUTF(a.size() + a.get(0).toString());
     }
 
@@ -138,17 +138,17 @@ public abstract class GISModelWriter ext
     return sortPreds;
   }
 
-  protected List compressOutcomes(ComparablePredicate[] sorted) {
+  protected List<List<ComparablePredicate>> compressOutcomes(ComparablePredicate[] sorted) {
     ComparablePredicate cp = sorted[0];
-    List outcomePatterns = new ArrayList();
-    List newGroup = new ArrayList();
+    List<List<ComparablePredicate>> outcomePatterns = new ArrayList<List<ComparablePredicate>>();
+    List<ComparablePredicate> newGroup = new ArrayList<ComparablePredicate>();
     for (int i = 0; i < sorted.length; i++) {
       if (cp.compareTo(sorted[i]) == 0) {
         newGroup.add(sorted[i]);
       } else {
         cp = sorted[i];
         outcomePatterns.add(newGroup);
-        newGroup = new ArrayList();
+        newGroup = new ArrayList<ComparablePredicate>();
         newGroup.add(sorted[i]);
       }
     }