java.util.HashSetedu.stanford.nlp.util.Generics



Project stanfordnlp/CoreNLP in file ...international.french.scripts.MWEFrequencyDist.java (2013-08-19)
@@ -7,7 +7,6 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.UnsupportedEncodingException;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -21,6 +20,7 @@ import edu.stanford.nlp.trees.international.french.FrenchTreeReaderFactory;
 import edu.stanford.nlp.trees.tregex.TregexParseException;
 import edu.stanford.nlp.trees.tregex.TregexMatcher;
 import edu.stanford.nlp.trees.tregex.TregexPattern;
+import edu.stanford.nlp.util.Generics;
 
 /**
  * Prints a frequency distribution of MWEs in French.
@@ -40,7 +40,7 @@ public final class MWEFrequencyDist {
     
     final File treeFile = new File(args[0]);
     TwoDimensionalCounter<String,String> mweLabelToString = new TwoDimensionalCounter<String,String>();
-    Set<String> uniquePOSSequences = new HashSet<String>();
+    Set<String> uniquePOSSequences = Generics.newHashSet();
     
     try {
       BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(treeFile), "UTF-8"));
Project stanfordnlp/CoreNLP in file ...nternational.morph.MorphoFeatureSpecification.java (2013-08-19)
@@ -2,11 +2,11 @@ package edu.stanford.nlp.international.morph;
 
 import java.io.Serializable;
 
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.regex.Pattern;
 
+import edu.stanford.nlp.util.Generics;
 import edu.stanford.nlp.util.Pair;
 
 /**
@@ -37,7 +37,7 @@ public abstract class MorphoFeatureSpecification implements Serializable {
   protected final Set<MorphoFeatureType> activeFeatures;
   
   public MorphoFeatureSpecification() {
-    activeFeatures = new HashSet<MorphoFeatureType>();
+    activeFeatures = Generics.newHashSet();
   }
   
   public void activate(MorphoFeatureType feat) {
Project stanfordnlp/CoreNLP in file ....stanford.nlp.parser.lexparser.FactoredParser.java (2013-08-19)
@@ -30,7 +30,6 @@ import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 
@@ -50,6 +49,7 @@ import edu.stanford.nlp.trees.TreeTransformer;
 import edu.stanford.nlp.trees.Treebank;
 import edu.stanford.nlp.trees.TreebankLanguagePack;
 import edu.stanford.nlp.util.Function;
+import edu.stanford.nlp.util.Generics;
 import edu.stanford.nlp.util.HashIndex;
 import edu.stanford.nlp.util.Index;
 import edu.stanford.nlp.util.Pair;
@@ -138,7 +138,7 @@ public class FactoredParser {
     // System.out.println(tlpParams.getClass());
     TreebankLanguagePack tlp = op.tlpParams.treebankLanguagePack();
 
-    op.trainOptions.sisterSplitters = new HashSet<String>(Arrays.asList(op.tlpParams.sisterSplitters()));
+    op.trainOptions.sisterSplitters = Generics.newHashSet(Arrays.asList(op.tlpParams.sisterSplitters()));
     //    BinarizerFactory.TreeAnnotator.setTreebankLang(tlpParams);
     PrintWriter pw = op.tlpParams.pw();
 
Project stanfordnlp/CoreNLP in file ...rd.nlp.parser.lexparser.LinearGrammarSmoother.java (2013-08-19)
@@ -1,12 +1,12 @@
 package edu.stanford.nlp.parser.lexparser;
 
 import java.util.Arrays;
-import java.util.HashSet;
 import java.util.Set;
 
 import edu.stanford.nlp.stats.ClassicCounter;
 import edu.stanford.nlp.stats.Counter;
 import edu.stanford.nlp.util.Function;
+import edu.stanford.nlp.util.Generics;
 import edu.stanford.nlp.util.Index;
 import edu.stanford.nlp.util.Pair;
 
@@ -29,7 +29,7 @@ public class LinearGrammarSmoother implements Function<Pair<UnaryGrammar,BinaryG
   // Do not include @ in this list! @ marks synthetic nodes!
   // Stole these from PennTreebankLanguagePack
   private final String[] annotationIntroducingChars = {"-", "=", "|", "#", "^", "~", "_"};
-  private final Set<String> annoteChars = new HashSet<String>(Arrays.asList(annotationIntroducingChars));
+  private final Set<String> annoteChars = Generics.newHashSet(Arrays.asList(annotationIntroducingChars));
 
   private final TrainOptions trainOptions;
 
Project stanfordnlp/CoreNLP in file ....edu.stanford.nlp.parser.metrics.TsarfatyEval.java (2013-08-19)
@@ -2,7 +2,6 @@ package edu.stanford.nlp.parser.metrics;
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
@@ -18,6 +17,7 @@ import edu.stanford.nlp.trees.LabeledScoredConstituentFactory;
 import edu.stanford.nlp.trees.Tree;
 import edu.stanford.nlp.trees.TreeTransformer;
 import edu.stanford.nlp.trees.Treebank;
+import edu.stanford.nlp.util.Generics;
 
 /**
  * Character level segmentation and tagging metric from (Tsarfaty, 2006). For evaluating parse
@@ -42,7 +42,7 @@ public class TsarfatyEval extends AbstractEval {
 
   @Override
   protected Set<?> makeObjects(Tree tree) {
-    Set<Constituent> deps = new HashSet<Constituent>();
+    Set<Constituent> deps = Generics.newHashSet();
     if(tree != null) extractDeps(tree, 0, deps);
     return deps;
   }