Search in sources :

Example 6 with THashMap

use of gnu.trove.map.hash.THashMap in project cogcomp-nlp by CogComp.

the class BrownClusters method printOovData.

public final void printOovData(Data data) {
    HashMap<String, Boolean> tokensHash = new HashMap<>();
    HashMap<String, Boolean> tokensHashIC = new HashMap<>();
    ArrayList<LinkedVector> sentences = new ArrayList<>();
    for (int docid = 0; docid < data.documents.size(); docid++) for (int sid = 0; sid < data.documents.get(docid).sentences.size(); sid++) sentences.add(data.documents.get(docid).sentences.get(sid));
    for (LinkedVector sentence : sentences) for (int j = 0; j < sentence.size(); j++) {
        String form = ((NEWord) sentence.get(j)).form;
        tokensHash.put(form, true);
        tokensHashIC.put(form.toLowerCase(), true);
    }
    for (THashMap<String, String> wordToPath : wordToPathByResource) {
        HashMap<String, Boolean> oovCaseSensitiveHash = new HashMap<>();
        HashMap<String, Boolean> oovAfterLowercasingHash = new HashMap<>();
        for (LinkedVector sentence : sentences) {
            for (int j = 0; j < sentence.size(); j++) {
                String form = ((NEWord) sentence.get(j)).form;
                if (!wordToPath.containsKey(form)) {
                    oovCaseSensitiveHash.put(form, true);
                }
                if ((!wordToPath.containsKey(form)) && (!wordToPath.containsKey(form.toLowerCase()))) {
                    oovAfterLowercasingHash.put(form.toLowerCase(), true);
                }
            }
        }
    }
}
Also used : LinkedVector(edu.illinois.cs.cogcomp.lbjava.parse.LinkedVector) HashMap(java.util.HashMap) THashMap(gnu.trove.map.hash.THashMap) ArrayList(java.util.ArrayList) NEWord(edu.illinois.cs.cogcomp.ner.LbjTagger.NEWord)

Aggregations

THashMap (gnu.trove.map.hash.THashMap)6 HashMap (java.util.HashMap)3 Method (org.spf4j.base.Method)3 ResourceConfigurator (edu.illinois.cs.cogcomp.core.resources.ResourceConfigurator)2 InFile (edu.illinois.cs.cogcomp.ner.IO.InFile)2 InvalidEndpointException (io.minio.errors.InvalidEndpointException)2 InvalidPortException (io.minio.errors.InvalidPortException)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStream (java.io.InputStream)2 StringTokenizer (java.util.StringTokenizer)2 Datastore (org.cogcomp.Datastore)2 DatastoreException (org.cogcomp.DatastoreException)2 LinkedVector (edu.illinois.cs.cogcomp.lbjava.parse.LinkedVector)1 NEWord (edu.illinois.cs.cogcomp.ner.LbjTagger.NEWord)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 TMap (gnu.trove.map.TMap)1 TIntObjectHashMap (gnu.trove.map.hash.TIntObjectHashMap)1 ArrayList (java.util.ArrayList)1