Example usage for java.util LinkedHashMap get

List of usage examples for java.util LinkedHashMap get

Introduction

In this page you can find the example usage for java.util LinkedHashMap get.

Prototype

public V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:net.sf.maltcms.chromaui.project.spi.DBProjectFactory.java

private static void initGroups(LinkedHashSet<String> groups, Map<File, String> fileToGroup,
        LinkedHashMap<String, Set<File>> groupToFile) {
    groups.addAll(fileToGroup.values());
    for (String group : groups) {
        for (File key : fileToGroup.keySet()) {
            if (fileToGroup.get(key).equals(group)) {
                if (groupToFile.containsKey(group)) {
                    Set<File> s = groupToFile.get(group);
                    s.add(key);/*  ww w .ja v  a2 s . com*/
                } else {
                    Set<File> s = new LinkedHashSet<>();
                    s.add(key);
                    groupToFile.put(group, s);
                }

            }
        }
    }
}

From source file:de.tudarmstadt.ukp.dkpro.c4corpus.hadoop.statistics.vocabulary.TopNWordsCorrelation.java

/**
 * Computes Spearman correlation by comparing order of two corpora vocabularies
 *
 * @param goldCorpus  gold corpus//from ww  w  .  j a  v a2 s .com
 * @param otherCorpus other corpus
 * @param topN        how many entries from the gold corpus should be taken
 * @throws IOException I/O exception
 */
public static void spearmanCorrelation(File goldCorpus, File otherCorpus, int topN) throws IOException {
    LinkedHashMap<String, Integer> gold = loadCorpusToRankedVocabulary(new FileInputStream(goldCorpus));
    LinkedHashMap<String, Integer> other = loadCorpusToRankedVocabulary(new FileInputStream(otherCorpus));

    double[][] matrix = new double[topN][];

    if (gold.size() < topN) {
        throw new IllegalArgumentException(
                "topN (" + topN + ") cannot be greater than vocabulary size (" + gold.size() + ")");
    }

    Iterator<Map.Entry<String, Integer>> iterator = gold.entrySet().iterator();
    int counter = 0;
    while (counter < topN) {
        Map.Entry<String, Integer> next = iterator.next();
        String goldWord = next.getKey();
        Integer goldValue = next.getValue();

        // look-up position in other corpus
        Integer otherValue = other.get(goldWord);
        if (otherValue == null) {
            //                System.err.println("Word " + goldWord + " not found in the other corpus");
            otherValue = Integer.MAX_VALUE;
        }

        matrix[counter] = new double[2];
        matrix[counter][0] = goldValue;
        matrix[counter][1] = otherValue;

        counter++;
    }

    RealMatrix realMatrix = new Array2DRowRealMatrix(matrix);

    SpearmansCorrelation spearmansCorrelation = new SpearmansCorrelation(realMatrix);
    double pValue = spearmansCorrelation.getRankCorrelation().getCorrelationPValues().getEntry(0, 1);
    double correlation = spearmansCorrelation.getRankCorrelation().getCorrelationMatrix().getEntry(0, 1);

    System.out.println("Gold: " + goldCorpus.getName());
    System.out.println("Other: " + otherCorpus.getName());
    System.out.printf(Locale.ENGLISH, "Top N:\n%d\nCorrelation\n%.3f\np-value\n%.3f\n", topN, correlation,
            pValue);
}

From source file:net.sf.maltcms.chromaui.project.spi.DBProjectFactory.java

private static void initSampleGroups(LinkedHashSet<String> sampleGroups, Map<File, String> fileToSampleGroup,
        LinkedHashMap<String, Set<File>> groupToFile) {
    sampleGroups.addAll(fileToSampleGroup.values());
    for (String sampleGroup : sampleGroups) {
        for (File key : fileToSampleGroup.keySet()) {
            if (fileToSampleGroup.get(key).equals(sampleGroup)) {
                if (groupToFile.containsKey(sampleGroup)) {
                    Set<File> s = groupToFile.get(sampleGroup);
                    s.add(key);//from ww w.j  a v  a2s .com
                } else {
                    Set<File> s = new LinkedHashSet<>();
                    s.add(key);
                    groupToFile.put(sampleGroup, s);
                }

            }
        }
    }
}

From source file:aldenjava.opticalmapping.data.data.OptMapDataReader.java

private static LinkedHashMap<Integer, LinkedHashMap<String, DataNode>> getLabelMap(OptMapDataReader omdr)
        throws IOException {
    LinkedHashMap<Integer, LinkedHashMap<String, DataNode>> fragmentMapLabelMap = new LinkedHashMap<Integer, LinkedHashMap<String, DataNode>>();
    DataNode fragment;// w  w w .  j a va2 s .c  om
    while ((fragment = omdr.read()) != null) {
        LinkedHashMap<String, DataNode> fragmentMap;
        if ((fragmentMap = fragmentMapLabelMap.get(fragment.getTotalSegment())) == null) {
            fragmentMap = new LinkedHashMap<String, DataNode>();
            fragmentMapLabelMap.put(fragment.getTotalSegment(), fragmentMap);
        }
        fragmentMap.put(fragment.name, fragment);
    }
    omdr.close();
    return fragmentMapLabelMap;

}

From source file:com.cisco.dbds.utils.tims.TIMS.java

/**
 * Buildsearchxml./*from   w  w  w .ja  v a2s  . c o m*/
 *
 * @param cred the cred
 * @param testCaseID the test case id
 * @return true, if successful
 */
public static boolean buildsearchxml(LinkedHashMap cred, String testCaseID) {
    boolean status = true;
    String configID = cred.get("configID").toString();
    try {
        if (configID == null || configID == "") {
            status = false;
            System.out.println("configID shouldn't be null or blank.");
        }
        if (testCaseID == null || testCaseID == "") {
            status = false;
            System.out.println("Test Case ID shouldn't be null or blank");
        }
        xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
        xml = xml
                + "<Tims xsi:schemaLocation=\"http://tims.cisco.com/namespace http://tims.cisco.com/xsd/Tims.xsd\"\n";
        xml = xml + "xmlns=\"http://tims.cisco.com/namespace\"\n";
        xml = xml + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
        xml = xml + "xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n";
        xml = xml + "<ResultList>\n";
        xml = xml + "<ResultRange>last</ResultRange>\n";
        xml = xml + "<CaseID>" + testCaseID + "</CaseID>\n";
        xml = xml + "<ConfigID>" + configID + "</ConfigID>\n";
        xml = xml + "</ResultList>\n";
        xml = xml + "</Tims>";
        return status;
    } catch (Exception e) {
        e.printStackTrace();
        status = false;
        return status;
    }
}

From source file:com.act.lcms.db.analysis.StandardIonAnalysis.java

/**
 * This function gets all the best time windows from spectra in water and meoh media, so that they can analyzed
 * by the yeast media samples for snr analysis.
 * @param waterAndMeohSpectra A list of ions to best XZ value.
 * @return A map of ion to list of restricted time windows.
 *///from   w ww . j ava  2  s  .com
public static Map<String, List<Double>> getRestrictedTimeWindowsForIonsFromWaterAndMeOHMedia(
        List<LinkedHashMap<String, XZ>> waterAndMeohSpectra) {

    Map<String, List<Double>> ionToRestrictedTimeWindows = new HashMap<>();

    for (LinkedHashMap<String, XZ> entry : waterAndMeohSpectra) {
        for (String ion : entry.keySet()) {
            List<Double> restrictedTimes = ionToRestrictedTimeWindows.get(ion);
            if (restrictedTimes == null) {
                restrictedTimes = new ArrayList<>();
                ionToRestrictedTimeWindows.put(ion, restrictedTimes);
            }
            Double timeValue = entry.get(ion).getTime();
            restrictedTimes.add(timeValue);
        }
    }

    return ionToRestrictedTimeWindows;
}

From source file:dm_p2.DBSCAN.java

public static void internalValidation(LinkedHashMap<Integer, List<Double>> linkedMap,
        Map<Integer, Integer> ourMap) {
    int size = linkedMap.size();
    int n = ((size - 1) * (size)) / 2;

    double incidenceMatrix[] = new double[n];
    double distanceMatrix[] = new double[n];
    int k = 0;//from   w ww  .ja  v  a 2s  .  co m
    for (int i = 1; i <= size; i++) {
        for (int j = i + 1; j <= size; j++) {
            if (ourMap.get(i) == ourMap.get(j)) {
                incidenceMatrix[k] = 1;
            } else {
                incidenceMatrix[k] = 0;
            }

            distanceMatrix[k] = euclidianDistance(linkedMap.get(i), linkedMap.get(j));
            k++;
        }
    }
    PearsonsCorrelation pc = new PearsonsCorrelation();

    System.out.println(
            "Internal Index Validation : Correlation = " + pc.correlation(incidenceMatrix, distanceMatrix));

}

From source file:com.sat.spvgt.utils.tims.TIMS.java

/**
 * Buildsearchxml./*from  w ww. j  a v  a 2s.  c om*/
 * 
 * @param cred
 *            the cred
 * @param testCaseID
 *            the test case id
 * @return true, if successful
 */
public static boolean buildsearchxml(LinkedHashMap<String, String> cred, String testCaseID) {
    boolean status = true;
    String configID = cred.get("configID").toString();
    try {
        if (configID == null || configID == "") {
            status = false;
            System.out.println("configID shouldn't be null or blank.");
        }
        if (testCaseID == null || testCaseID == "") {
            status = false;
            System.out.println("Test Case ID shouldn't be null or blank");
        }
        xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
        xml = xml
                + "<Tims xsi:schemaLocation=\"http://tims.cisco.com/namespace http://tims.cisco.com/xsd/Tims.xsd\"\n";
        xml = xml + "xmlns=\"http://tims.cisco.com/namespace\"\n";
        xml = xml + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
        xml = xml + "xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n";
        xml = xml + "<ResultList>\n";
        xml = xml + "<ResultRange>last</ResultRange>\n";
        xml = xml + "<CaseID>" + testCaseID + "</CaseID>\n";
        xml = xml + "<ConfigID>" + configID + "</ConfigID>\n";
        xml = xml + "</ResultList>\n";
        xml = xml + "</Tims>";
        return status;
    } catch (Exception e) {
        e.printStackTrace();
        status = false;
        return status;
    }
}

From source file:com.cisco.dbds.utils.tims.TIMS.java

/**
 * Buildupdatexml./*  www  . jav  a 2  s  .c o  m*/
 *
 * @param cred the cred
 * @param result the result
 * @return true, if successful
 */
public static boolean buildupdatexml(LinkedHashMap cred, String result) {

    boolean status = true;

    String configID = cred.get("configID").toString();
    String usrID = cred.get("userID").toString();
    String tokenv = cred.get("token").toString();
    String sw = cred.get("sw").toString();
    String platform = cred.get("platform").toString();
    String brwtype = cred.get("brwtype").toString();
    String brwversion = cred.get("brwversion").toString();
    System.out.println("browser details:" + brwtype + brwversion);
    try {

        if (configID == null || configID == "") {
            status = false;
            System.out.println("configID shouldn't be null or blank.");
        }
        if (trID == null || trID == "") {
            status = false;
            System.out.println("Test Result ID shouldn't be null or blank");
        }
        if (result == null || result == "") {
            status = false;
            System.out.println("Result shouldn't be null or blank");
        }
        if (!(result.equals("passed") | result.equals("failed")

                | result.equals("blocked") | result.equals("dropped")

                | result.equals("passx") | result.equals("pending"))) {

            System.out.println("Invalid Status value");
            return false;
        }

        xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
        xml = xml
                + "<Tims xsi:schemaLocation=\"http://tims.cisco.com/namespace http://tims.cisco.com/xsd/Tims.xsd\"\n";
        xml = xml + "xmlns=\"http://tims.cisco.com/namespace\"\n";
        xml = xml + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
        xml = xml + "xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n";
        xml = xml + "<Credential user=\"" + usrID + "\" token=\"" + tokenv + "\"/>\n";
        xml = xml + "<ID>" + trID + "</ID>\n";

        xml = xml + "<ListFieldValue editoperator=\"set\">\n";
        xml = xml + "<FieldName>Status</FieldName>\n";
        xml = xml + "<Value>" + result + "</Value>\n";
        xml = xml + "</ListFieldValue>\n";

        xml = xml + "<ListFieldValue editoperator=\"set\">\n";
        xml = xml + "<FieldName>Tested by</FieldName>\n";
        xml = xml + "<Value>" + usrID + "</Value>\n";
        xml = xml + "</ListFieldValue>\n";

        /*xml=xml+"<ListFieldValue editoperator=\"set\">\n";
           xml=xml+"<FieldName>Software Version</FieldName>\n";
           xml=xml+"<Value>"+sw+"</Value>\n";   
        xml=xml+"</ListFieldValue>\n";*/

        xml = xml + "<ListFieldValue editoperator=\"set\">\n";
        xml = xml + "<FieldName>Platform</FieldName>\n";
        xml = xml + "<Value>" + platform + "</Value>\n";
        xml = xml + "</ListFieldValue>\n";

        xml = xml + "<TextFieldValue editoperator=\"set\">\n";
        xml = xml + "<FieldName>Browser Type</FieldName>\n";
        xml = xml + "<Value>" + brwtype + "</Value>\n";
        xml = xml + "</TextFieldValue>\n";

        xml = xml + "<TextFieldValue editoperator=\"set\">\n";
        xml = xml + "<FieldName>Browser Version</FieldName>\n";
        xml = xml + "<Value>" + brwversion + "</Value>\n";
        xml = xml + "</TextFieldValue>\n";

        xml = xml + "</Tims>\n";
        return status;

    } catch (Exception e) {

        e.printStackTrace();

        status = false;

        return status;

    }

}

From source file:com.cisco.dbds.utils.tims.TIMS.java

/**
 * Buildcreatexml.//  ww w.j ava  2s.c o m
 *
 * @param cred the cred
 * @param testCaseID the test case id
 * @param result the result
 * @param title the title
 * @return true, if successful
 */
public static boolean buildcreatexml(LinkedHashMap cred, String testCaseID, String result, String title) {

    boolean status = true;
    String userID = cred.get("userID").toString();
    String automationToken = cred.get("token").toString();
    String projectID = cred.get("projectID").toString();
    String configID = cred.get("configID").toString();

    try {
        if (userID == null || userID == "") {
            status = false;
            System.out.println("userID shouldn't be null or blank.");
        }
        if (automationToken == null || automationToken == "") {
            status = false;
            System.out.println("Automation Token shouldn't be null or blank.");
        }
        if (testCaseID == null || testCaseID == "") {
            status = false;
            System.out.println("Test Case ID shouldn't be null or blank");
        }
        if (configID == null || configID == "") {
            status = false;
            System.out.println("configID shouldn't be null or blank.");
        }

        xml = xml + "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
        xml = xml
                + "<Tims xsi:schemaLocation=\"http://tims.cisco.com/namespace http://tims.cisco.com/xsd/Tims.xsd\"\n";
        xml = xml + "xmlns=\"http://tims.cisco.com/namespace\"\n";
        xml = xml + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
        xml = xml + "xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n";
        xml = xml + "<Credential user=\"" + userID + "\" token=\"" + automationToken + "\"/>\n";
        xml = xml + "<Result xlink:href=\"http://tims.cisco.com/xml/" + testCaseID + "/entity.svc\">\n";

        xml = xml + "<Title><![CDATA[" + title + "]]></Title>\n";
        xml = xml + "<ListFieldValue multi-value=\"false\">\n";
        xml = xml + "<FieldName><![CDATA[Tested by]]>\n";
        xml = xml + "</FieldName>\n";
        xml = xml + "<Value><![CDATA[" + userID + "]]>\n";
        xml = xml + "</Value>\n";
        xml = xml + "<Value><![CDATA[shisuren]]>\n";
        xml = xml + "</Value>\n";
        xml = xml + "</ListFieldValue>\n";

        xml = xml + "<Owner>\n";
        xml = xml + "<UserID>\n" + userID + "\n</UserID>\n";
        xml = xml + "<Email>\n" + userID + "@cisco.com" + "\n</Email>\n";
        xml = xml + "</Owner>\n";
        xml = xml + "<Status>" + result + "</Status>\n";
        xml = xml + "<ConfigID xlink:href=\"http://tims.cisco.com/xml/" + configID + "/entity.svc\">" + configID
                + "</ConfigID>\n";
        xml = xml + "<CaseID xlink:href=\"http://tims.cisco.com/xml/" + testCaseID + "/entity.svc\">"
                + testCaseID + "</CaseID>\n";
        xml = xml + "</Result>\n";
        xml = xml + "</Tims>";

        return status;

    } catch (Exception e) {

        e.printStackTrace();

        status = false;

        return status;

    }

}