public IOntologyGraph map() {
Set<IRI> commonIRISet = SetHelper.INSTANCE.setIntersection(firstGraph.getConceptUris(),
secondGraph.getConceptUris());
for (IRI uri : commonIRISet) {
IOntologyConcept first = firstGraph.getUriToConcept().get(uri);
IOntologyConcept second = secondGraph.getUriToConcept().get(uri);
bind(first, second, SAME_URI);
}
Set<Synset> commonSynsetSet = SetHelper.INSTANCE.setIntersection(firstGraph.getSynsets(), secondGraph.getSynsets());
for (Synset synset : commonSynsetSet) {
for (IOntologyConcept first : firstGraph.getSynsetToConcept().get(synset)) {
for (IOntologyConcept second : secondGraph.getSynsetToConcept().get(synset)) {
bind(first, second, SAME_SYNSET);
}
}
}
Set<String> commonLabelSet = SetHelper.INSTANCE.setIntersection(firstGraph.getConceptLabels(),
secondGraph.getConceptLabels());
LexicalOrSynsetConceptComparator conceptComparator = new LexicalOrSynsetConceptComparator();
for (String label : commonLabelSet) {
for (IOntologyConcept first : firstGraph.getLabelToConcept().get(label)) {
for (IOntologyConcept second : secondGraph.getLabelToConcept().get(label)) {
if (tryToBind(conceptComparator, first, second, getBindFactors())) {
break;
}
}
}
}
firstConcepts.addAll(secondConcepts);
logger.log("binded ontologies");
Set<IOntologyConcept> roots = SetHelper.INSTANCE.setUnion(firstGraph.getRoots(), SetHelper.INSTANCE.setIntersection(secondGraph.getRoots(), secondConcepts));
HashMap<IRI, IOntologyConcept> uriToConcept = new HashMap<IRI, IOntologyConcept>(firstGraph.getUriToConcept());
for (IOntologyConcept second : secondConcepts) {
uriToConcept.put(second.getUri(), second);
}
return new OntologyGraph(roots, uriToConcept, null, null, null);
}