Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  
  package eu.clarin.weblicht.wlfxb.tc.test;
  
 import java.util.Map;
 import org.junit.Test;

Author(s):
Yana Panchenko
 
 
     private static final String INPUT_FILE_WITHOUT_LAYER = "/data/tc-lexsem/tcf-before.xml";
     private static final String INPUT_FILE_WITH_LAYER = "/data/tc-lexsem/tcf-after.xml";
     private static final String EXPECTED_OUTPUT_FILE = "/data/tc-lexsem/output-expected.xml";
     private static final String OUTPUT_FILE = "/tmp/output.xml";
     private static final EnumSet<TextCorpusLayerTaglayersToReadBeforeLexSemAnnotation =
             EnumSet.of(.);
     private static final EnumSet<TextCorpusLayerTaglayersToReadAfterLexSemAnnotation =
             EnumSet.of(.,
     public static final Map<StringString[]> syno = new HashMap<StringString[]>();
     public static final Map<StringString[]> anto = new HashMap<StringString[]>();
     public static final Map<StringString[]> hypo = new HashMap<StringString[]>();
     public static final Map<StringString[]> hyper = new HashMap<StringString[]>();
 
     static {
         .put("essen"new String[]{"futtern""nehmen"});
         .put("essen"new String[]{"verhungern"});
         .put("essen"new String[]{"Art essen""EssensOrt spezifiziert""EssensZeit spezifiziert""acheln""aufessen""aufnehmen""einverleiben""essen mit Instrument""hermachen",
                     "stärken""vertilgen""wegessen"});
         .put("schmecken"new String[]{"abschmecken""gustieren""kosten""munden""probieren",
                     "versuchen""würzen"});
         .put("essen"new String[]{"verzehren"});
         .put("schmecken"new String[]{"Genuss essen""gut tun""guttun""perzipieren""wahrnehmen"});
     }
 
     @Test
     public void testRead() throws Exception {
         LexicalSemanticsLayer layer;
 
         layer = tc.getSynonymyLayer();
         Assert.assertEquals(1, layer.size());
         //Assert.assertEquals("GermaNet", layer.getSource());
         Assert.assertEquals(tc.getLemmasLayer().getLemma(1), layer.getLemmas(layer.getOrthform(0))[0]);
         Assert.assertEquals(layer.getOrthform(0), layer.getOrthform(tc.getLemmasLayer().getLemma(1)));
 
         layer = tc.getAntonymyLayer();
         Assert.assertEquals(1, layer.size());
         //Assert.assertEquals("GermaNet", layer.getSource());
         Assert.assertEquals(tc.getLemmasLayer().getLemma(1), layer.getLemmas(layer.getOrthform(0))[0]);
         Assert.assertEquals(layer.getOrthform(0), layer.getOrthform(tc.getLemmasLayer().getLemma(1)));
 
         layer = tc.getHyponymyLayer();
         Assert.assertEquals(2, layer.size());
         //Assert.assertEquals("GermaNet", layer.getSource());
         Assert.assertEquals(tc.getLemmasLayer().getLemma(1), layer.getLemmas(layer.getOrthform(0))[0]);
         Assert.assertEquals(layer.getOrthform(0), layer.getOrthform(tc.getLemmasLayer().getLemma(1)));
 
         layer = tc.getHyperonymyLayer();
         Assert.assertEquals(2, layer.size());
         //Assert.assertEquals("GermaNet", layer.getSource());
         Assert.assertEquals(tc.getLemmasLayer().getLemma(1), layer.getLemmas(layer.getOrthform(0))[0]);
         Assert.assertEquals(layer.getOrthform(0), layer.getOrthform(tc.getLemmasLayer().getLemma(1)));
     }
 
     @Test
     public void testReadWrite() throws Exception {
         ..println(tc);
         // create lexical semantics layers, empty at first
         //String source = "GermaNet";
         LexicalSemanticsLayer synonymy = tc.createSynonymyLayer();
         LexicalSemanticsLayer antonymy = tc.createAntonymyLayer();
         LexicalSemanticsLayer hyponymy = tc.createHyponymyLayer();
         LexicalSemanticsLayer hyperonymy = tc.createHyperonymyLayer();
         for (int i = 0; i < tc.getLemmasLayer().size(); i++) {
             Lemma lemma = tc.getLemmasLayer().getLemma(i);
             String[] synonyms = getSynonyms(lemma.getString());
             if (synonyms != null) {
                 // create and add synonyms to the lemma
                 synonymy.addOrthform(synonymslemma);
             }
             String[] antonyms = getAntonyms(lemma.getString());
             if (antonyms != null) {
                 // create and add antonyms to the lemma
                 antonymy.addOrthform(antonymslemma);
            }
            String[] hyponyms = getHyponyms(lemma.getString());
            if (hyponyms != null) {
                // create and add hyponyms to the lemma
                hyponymy.addOrthform(hyponymslemma);
            }
            String[] hyperonyms = getHyperonyms(lemma.getString());
            if (hyperonyms != null) {
                // create and add hyperonyms to the lemma
                hyperonymy.addOrthform(hyperonymslemma);
            }
        }
        // IMPORTANT close the streams!!!
        tc.close();
        ..println(tc);
        // compare output xml with expected xml
    }
    private String[] getSynonyms(String lemmaString) {
        return .get(lemmaString);
    }
    private String[] getAntonyms(String lemmaString) {
        return .get(lemmaString);
    }
    private String[] getHyponyms(String lemmaString) {
        return .get(lemmaString);
    }
    private String[] getHyperonyms(String lemmaString) {
        return .get(lemmaString);
    }
New to GrepCode? Check out our FAQ X