Example usage for org.apache.commons.collections4.map MultiValueMap entrySet

List of usage examples for org.apache.commons.collections4.map MultiValueMap entrySet

Introduction

In this page you can find the example usage for org.apache.commons.collections4.map MultiValueMap entrySet.

Prototype

@Override
public Set<Entry<K, Object>> entrySet() 

Source Link

Document

NOTE: the returned Entry objects will contain as value a Collection of all values that are mapped to the given key.

Usage

From source file:pltag.runtime.LexiconTest.java

@Test
public void testLexiconUnlexEntriesWithSLabel() {
    Map<String, String> map = new HashMap();
    Lexicon lexicon = parser.getLexicon();
    MultiValueMap<String, ElementaryStringTree> col = lexicon.getLexEntriesContaining("S");
    for (Entry<String, Object> entry : col.entrySet()) {
        for (ElementaryStringTree tree : (Collection<ElementaryStringTree>) entry.getValue()) {
            TreeState ts = new TreeState(tree, (short) 0, 1);
            map.put(tree.getUnlexStruct(1),
                    String.format("%s;%s", ts.getFringe(), ts.getFutureFringe().getFringe()));
            //                System.out.println(String.format("%s\t%s\t%s ; %s", entry.getKey(), tree.getUnlexStruct(1), ts.getFringe(), ts.getFutureFringe().getFringe()));                
        }/*ww  w.  j a va2 s  .co  m*/
    }

    for (Entry<String, String> e : map.entrySet()) {
        // filter only trees with NPs
        String tree = e.getKey().trim();
        String fringes[] = e.getValue().trim().split(";");
        String curFringe = fringes[0];
        String futureFringes = fringes[1];
        if (tree.contains("NP") && tree.startsWith("(S^null_0 (NP^0_0 (:^0_0 *^0_0))")) {
            //if(!curFringe.startsWith("[][S^-1_0@t:0L:?] : NP^0_-1@t:0L:?")) // filter out [][S]:NP cases in (trivial)
            {
                //if(futureFringes.contains("[S^0_0@t:0L:?] : NP^0_-1@t:0L:?")) // S - NP subj elsewhere in the tree
                System.out.println(tree + " ||| " + e.getValue());
            }
        }
    }
}