edu.stanford.nlp.util.Generics



Project stanfordnlp/CoreNLP in file .../src.edu.stanford.nlp.classify.GeneralDataset.java (2013-08-19)
@@ -9,6 +9,7 @@ import edu.stanford.nlp.ling.Datum;
 import edu.stanford.nlp.ling.RVFDatum;
 import edu.stanford.nlp.stats.ClassicCounter;
 import edu.stanford.nlp.stats.Counter;
+import edu.stanford.nlp.util.Generics;
 import edu.stanford.nlp.util.HashIndex;
 import edu.stanford.nlp.util.Index;
 import edu.stanford.nlp.util.Pair;
@@ -288,7 +289,7 @@ public abstract class GeneralDataset<L, F>  implements Serializable, Iterable<RV
   			subset.add(this.getDatum(datumNum));
   		}
   	} else {
-  		Set<Integer> indicedSampled = new HashSet<Integer>();
+  		Set<Integer> indicedSampled = Generics.newHashSet();
   		while (subset.size() < sampleSize) {
   			int datumNum = rand.nextInt(this.size());
   			if (!indicedSampled.contains(datumNum)) {
Project stanfordnlp/CoreNLP in file ...6/src.edu.stanford.nlp.classify.KNNClassifier.java (2013-08-19)
@@ -6,6 +6,7 @@ import edu.stanford.nlp.ling.Datum;
 import edu.stanford.nlp.ling.RVFDatum;
 import edu.stanford.nlp.stats.*;
 import edu.stanford.nlp.util.CollectionValuedMap;
+import edu.stanford.nlp.util.Generics;
 
 /**
  * A simple k-NN classifier, with the options of using unit votes, or weighted votes (by 
@@ -25,7 +26,7 @@ public class KNNClassifier<K,V> implements Classifier<K, V> {
   private static final long serialVersionUID = 7115357548209007944L;
   private boolean weightedVotes = false; // whether this is a weighted vote (by sim), or not
   private CollectionValuedMap<K, Counter<V>> instances = new CollectionValuedMap<K, Counter<V>>();
-  private Map<Counter<V>, K> classLookup = new HashMap<Counter<V>, K>();
+  private Map<Counter<V>, K> classLookup = Generics.newHashMap();
   private boolean l2Normalize = false;
   int k = 0;
 
Project stanfordnlp/CoreNLP in file ...6/src.edu.stanford.nlp.ie.pascal.AcronymModel.java (2013-08-19)
@@ -2,6 +2,9 @@ package edu.stanford.nlp.ie.pascal;
 
 import java.util.*;
 import java.io.*;
+
+import edu.stanford.nlp.util.Generics;
+
  /**
   * Scores Pascal challenge workshop information templates.
   * This score reflects which fields are present/absent, how well acronyms
@@ -133,7 +136,7 @@ public class AcronymModel implements RelationalModel {
   private double computeProb(String wsname, String wsacronym, String confname,
                             String confacronym, String wsurl, String confurl){
 
-    HashSet<String> presentFields = new HashSet<String>();
+    Set<String> presentFields = Generics.newHashSet();
     if( wsname != null && !wsname.equals("null") && !wsname.equals("") )
       presentFields.add("workshopname");
     if( wsacronym != null && !wsacronym.equals("null") && !wsacronym.equals(""))
Project stanfordnlp/CoreNLP in file ...international.arabic.parsesegment.JointParser.java (2013-08-19)
@@ -12,6 +12,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.zip.GZIPInputStream;
 
+import edu.stanford.nlp.util.Generics;
 import edu.stanford.nlp.util.PropertiesUtils;
 import edu.stanford.nlp.util.StringUtils;
 
@@ -36,7 +37,7 @@ public final class JointParser {
     return classUsage.toString();
   }
   private static Map<String, Integer> optionArgDefs() {
-    Map<String, Integer> optionArgDefs = new HashMap<String,Integer>();
+    Map<String, Integer> optionArgDefs = Generics.newHashMap();
     optionArgDefs.put("v", 0);
     optionArgDefs.put("t", 1);
     optionArgDefs.put("l", 1);
Project stanfordnlp/CoreNLP in file ....parser.lexparser.ChineseSimWordAvgDepGrammar.java (2013-08-19)
@@ -10,6 +10,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import edu.stanford.nlp.stats.ClassicCounter;
+import edu.stanford.nlp.util.Generics;
 import edu.stanford.nlp.util.Index;
 import edu.stanford.nlp.util.Pair;
 import edu.stanford.nlp.util.Triple;
@@ -46,7 +47,7 @@ public class ChineseSimWordAvgDepGrammar extends MLEDependencyGrammar {
   }
 
   public Map<Pair<Integer, String>, List<Triple<Integer, String, Double>>> getMap(String filename) {
-    Map<Pair<Integer, String>, List<Triple<Integer, String, Double>>> hashMap = new HashMap<Pair<Integer, String>, List<Triple<Integer, String, Double>>>();
+    Map<Pair<Integer, String>, List<Triple<Integer, String, Double>>> hashMap = Generics.newHashMap();
     try {
       BufferedReader wordMapBReader = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "UTF-8"));