1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
package evaluation;
import Similarity.*;
import Similarity.sim_ling;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
//import de.uma.alignment.matcher.demo.DemoMatcher;
import eu.sealsproject.platform.res.domain.omt.IOntologyMatchingToolBridge;
import eu.sealsproject.platform.res.tool.api.ToolBridgeException;
import eu.sealsproject.platform.res.tool.api.ToolException;
import eu.sealsproject.platform.res.tool.api.ToolType;
import eu.sealsproject.platform.res.tool.impl.AbstractPlugin;
public class MatcherBridge extends AbstractPlugin implements IOntologyMatchingToolBridge {
/**
* Aligns to ontologies specified via their URL and retunrs the
* URL of the resulting alignment, which should be stored locally.
*
*/
public URL align(URL source, URL target)throws ToolBridgeException, ToolException {
//DemoMatcher demoMatcher;
sim_ling sim ;
try {
sim= new sim_ling(source.toURI(), target.toURI());
try {
String alignmentString = sim.align(source.toURI(), target.toURI());
try {
File alignmentFile = File.createTempFile("alignment", ".rdf");
FileWriter fw = new FileWriter(alignmentFile);
fw.write(alignmentString);
fw.flush();
fw.close();
return alignmentFile.toURI().toURL();
}
catch (IOException e) {
throw new ToolBridgeException("cannot create file for results", e);
}
}
catch (URISyntaxException e1) {
throw new ToolBridgeException("cannot convert the input param to URI");
}
}
catch (NumberFormatException e2) {
throw new ToolBridgeException("cannot read from configuration file", e2);
}
/*catch (IOException e3) {
throw new ToolBridgeException("cannot access configuration file", e3);
}*/
}
/**
* This functionality is not supported by the tool. In case
* it is invoked a ToolException is thrown.
*/
public URL align(URL source, URL target, URL inputAlignment)
throws ToolBridgeException, ToolException {
throw new ToolException("functionaility of called method is not supported");
}
/**
* In our case the DemoMatcher can be executed on the fly. In case
* prerequesites are required it can be checked here.
*/
public boolean canExecute() {
return true;
}
/**
* The DemoMatcher is an ontology matching tool. SEALS supports the
* evaluation of different tool types like e.g., reasoner and storage systems.
*/
public ToolType getType() {
return ToolType.OntologyMatchingTool;
}
} |
Partager