From: <jen...@us...> - 2008-01-06 20:08:47
|
Revision: 346 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=346&view=rev Author: jenslehmann Date: 2008-01-06 12:08:33 -0800 (Sun, 06 Jan 2008) Log Message: ----------- fixed Tilos bug Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDIGConverter.java Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-06 18:47:12 UTC (rev 345) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-06 20:08:33 UTC (rev 346) @@ -82,9 +82,11 @@ StartGUI.myconfig.setFile(fc.getSelectedFile()); //save variable fileDisplay.setText(StartGUI.myconfig.getFile().toString()); System.out.println("Init KnowledgeSource after loading file ... show over output"); + System.out.println("test: " + StartGUI.myconfig.getFile().toURI().toString()); StartGUI.myconfig.getComponentManager().applyConfigEntry(StartGUI.myconfig.getKnowledgeSource(), "url", StartGUI.myconfig.getFile().toURI().toString()); StartGUI.myconfig.getKnowledgeSource().init(); - } + } + return; } // choose none Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-06 18:47:12 UTC (rev 345) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-06 20:08:33 UTC (rev 346) @@ -75,6 +75,7 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == digButton) { // DIG StartGUI.myconfig.setReasoner(StartGUI.myconfig.getComponentManager().reasoner(DIGReasoner.class, StartGUI.myconfig.getKnowledgeSource())); + System.out.println(StartGUI.myconfig.getKnowledgeSource()); StartGUI.myconfig.getReasoner().init(); //error System.out.println("test"); Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDIGConverter.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDIGConverter.java 2008-01-06 18:47:12 UTC (rev 345) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDIGConverter.java 2008-01-06 20:08:33 UTC (rev 346) @@ -26,64 +26,50 @@ public class OWLAPIDIGConverter { public static String getTellsString(URL file, OntologyFormat format, URI kbURI) { - // public static String getTellsString(URL file, URI kbURI){//throws OWLOntologyCreationException{ - String ret=""; - try{ - - /* Load an ontology from a physical URI */ - OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - //the next function could return an ontology - manager.loadOntologyFromPhysicalURI(file.toURI()); - - DIGTranslatorImpl dig=new DIGTranslatorImpl(manager); - Document doc=dig.createTellsDocument(kbURI.toString()); - dig.translateToDIG(manager.getOntologies(), doc, doc.getDocumentElement() ); - ret=xml2string(doc); - // }catch (Exception e) {e.printStackTrace();} - }catch (DIGReasonerException e) {e.printStackTrace();} - catch (OWLOntologyCreationException e) {e.printStackTrace();} - catch (URISyntaxException e) {e.printStackTrace();} - - // System.out.println(ret); - // System.exit(0); - - return ret; - } - - - //for convenience - /* - public static String getTellsString(String file, String kbURI){ - // String ret=""; - //try{ - // URL u=new URL(file); - // URI ui=new URI(kbURI); - return getTellsString(file, kbURI); - //}catch (MalformedURLException e) {e.printStackTrace();} - //catch (URISyntaxException e) {e.printStackTrace();} - // return ret; - }*/ - - public static String xml2string(Document d){ - // XML als String erzeugen (ziemlich umst�ndlich) - String tellString=""; + String ret = ""; try { - // transformer erzeugen mit identity transformation - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - // Quelle ist das DOM-Objekt - DOMSource source = new DOMSource( d ); - // Resultat ist ein OutputStream, leider kann man das Resultat nicht - // direkt als String bekommen - ByteArrayOutputStream os = new ByteArrayOutputStream(); - StreamResult result = new StreamResult( os ); - // Transformation ausf�hren - transformer.transform( source, result ); - // String aus OutputStream generieren - tellString = os.toString(); - + + // Load an ontology from a physical URI + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + // the next function could return an ontology + manager.loadOntologyFromPhysicalURI(file.toURI()); + + DIGTranslatorImpl dig = new DIGTranslatorImpl(manager); + Document doc = dig.createTellsDocument(kbURI.toString()); + dig.translateToDIG(manager.getOntologies(), doc, doc.getDocumentElement()); + ret = xml2string(doc); + + } catch (DIGReasonerException e) { + e.printStackTrace(); + } catch (OWLOntologyCreationException e) { + e.printStackTrace(); + } catch (URISyntaxException e) { + e.printStackTrace(); + } + + return ret; + } + + public static String xml2string(Document d) { + // XML als String erzeugen (ziemlich umst�ndlich) + String tellString = ""; + try { + // transformer erzeugen mit identity transformation + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + // Quelle ist das DOM-Objekt + DOMSource source = new DOMSource(d); + // Resultat ist ein OutputStream, leider kann man das Resultat nicht + // direkt als String bekommen + ByteArrayOutputStream os = new ByteArrayOutputStream(); + StreamResult result = new StreamResult(os); + // Transformation ausf�hren + transformer.transform(source, result); + // String aus OutputStream generieren + tellString = os.toString(); + } catch (TransformerConfigurationException e) { e.printStackTrace(); } catch (TransformerFactoryConfigurationError e) { @@ -93,31 +79,4 @@ } return tellString; } - - - -/*public static void main(String[] args) { - - try{ - - String inputOntology = "http://localhost/dllearner/ontologies/arch.owl"; - //String inputOntology = "http://localhost/dllearner/ontologies/ttttt.rdf"; - - OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - URL res = new URL("http://localhost:8081"); - HTTPReasonerImpl h=new HTTPReasonerImpl(manager); - h.setReasonerURL(res); - URL u=new URL(inputOntology); - String kb=(h.createKnowledgeBase()); - URI ui=new URI(kb); - System.out.println(getTellsString(u, ui)); - - System.out.println("Done"); - - } catch (Exception e) { - e.printStackTrace(); - } - - }*/ } - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |