SynsetGenerator { public void initialize(){ if(LexUnitSynsetMappings.isEmpty()){ List<Synset> gnSynsets = gnet.getSynsets(); for(Synset gnSynset : gnSynsets){ de.tudarmstadt.ukp.lmf.model.semantics.Synset lmfSynset = new de.tudarmstadt.ukp.lmf.model.semantics.Synset(); lmfSynset.setId(getNewID()); MonolingualExternalRef mer = new MonolingualExternalRef(); mer.setExternalReference(Integer.toString(gnSynset.getId())); mer.setExternalSystem(resourceVersion + "_" + SYNSET); LinkedList<MonolingualExternalRef> mers = new LinkedList<MonolingualExternalRef>(); mers.add(mer); lmfSynset.setMonolingualExternalRefs(mers); lmfSynsetGNSynsetMappings.put(lmfSynset, gnSynset); gnSynsetLMFSynsetMappings.put(gnSynset, lmfSynset); String writtenText = gnSynset.getParaphrase(); if (writtenText != null && !writtenText.equals("") && !writtenText.equals(" ")) { List<Definition> definitions = new LinkedList<Definition>(); Definition definition = new Definition(); List<TextRepresentation> textRepresentations = new LinkedList<TextRepresentation>(); TextRepresentation textRepresentation = new TextRepresentation(); textRepresentation.setLanguageIdentifier(ELanguageIdentifier.GERMAN); textRepresentation.setWrittenText(writtenText); textRepresentations.add(textRepresentation); definition.setTextRepresentations(textRepresentations); definitions.add(definition); lmfSynset.setDefinitions(definitions); } for(LexUnit lu : gnSynset.getLexUnits()){ Sense sense = new Sense(); sense.setId(getNewSenseID()); LexUnitSynsetMappings.put(lu, lmfSynset); luSenseMappings.put(lu, sense); gnSynsetSenseMappings.put(gnSynset, sense); if(!synsetSenseMappings.containsKey(lmfSynset)){ LinkedList<Sense> temp = new LinkedList<Sense>(); synsetSenseMappings.put(lmfSynset, temp); } synsetSenseMappings.get(lmfSynset).add(sense); } } finalizeGeneration(); } } SynsetGenerator(GermaNet gnet, String resourceVersion); void initialize(); de.tudarmstadt.ukp.lmf.model.semantics.Synset getLMFSynset(LexUnit lu); Sense getSense(LexUnit lu); Sense getSense(Synset gnSynset); List<de.tudarmstadt.ukp.lmf.model.semantics.Synset> getSynsets(); static final String SYNSET; }
@Test public void testInitialize(){ synsetGenerator.initialize(); List<Synset> synsets = synsetGenerator.getSynsets(); assertFalse("No synsets created", synsets.isEmpty()); for(Synset synset : synsets){ assertNotNull("Synset should not be null", synset); List<MonolingualExternalRef> monolingualExternalRefs = synset.getMonolingualExternalRefs(); assertFalse(monolingualExternalRefs.isEmpty()); for(MonolingualExternalRef monolingualExternalRef : monolingualExternalRefs){ assertFalse(monolingualExternalRef == null); String externalSystem = monolingualExternalRef.getExternalSystem(); assertNotNull(externalSystem); assertEquals(externalSystem, "GermaNet 7.0 Synset-ID"); String externalReference = monolingualExternalRef.getExternalReference(); assertNotNull(externalReference); assertFalse(externalReference.replaceAll(" ", "").isEmpty()); } } }