You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(120) |
Sep
(36) |
Oct
(116) |
Nov
(17) |
Dec
(44) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(143) |
Feb
(192) |
Mar
(74) |
Apr
(84) |
May
(105) |
Jun
(64) |
Jul
(49) |
Aug
(120) |
Sep
(159) |
Oct
(156) |
Nov
(51) |
Dec
(28) |
2009 |
Jan
(17) |
Feb
(55) |
Mar
(33) |
Apr
(57) |
May
(54) |
Jun
(28) |
Jul
(6) |
Aug
(16) |
Sep
(38) |
Oct
(30) |
Nov
(26) |
Dec
(52) |
2010 |
Jan
(7) |
Feb
(91) |
Mar
(65) |
Apr
(2) |
May
(14) |
Jun
(25) |
Jul
(38) |
Aug
(48) |
Sep
(80) |
Oct
(70) |
Nov
(75) |
Dec
(77) |
2011 |
Jan
(68) |
Feb
(53) |
Mar
(51) |
Apr
(35) |
May
(65) |
Jun
(101) |
Jul
(29) |
Aug
(230) |
Sep
(95) |
Oct
(49) |
Nov
(110) |
Dec
(63) |
2012 |
Jan
(41) |
Feb
(42) |
Mar
(25) |
Apr
(46) |
May
(51) |
Jun
(44) |
Jul
(45) |
Aug
(29) |
Sep
(12) |
Oct
(9) |
Nov
(17) |
Dec
(2) |
2013 |
Jan
(12) |
Feb
(14) |
Mar
(7) |
Apr
(16) |
May
(54) |
Jun
(27) |
Jul
(11) |
Aug
(5) |
Sep
(85) |
Oct
(27) |
Nov
(37) |
Dec
(32) |
2014 |
Jan
(8) |
Feb
(29) |
Mar
(5) |
Apr
(3) |
May
(22) |
Jun
(3) |
Jul
(4) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <sk...@us...> - 2008-10-26 20:29:21
|
Revision: 1432 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1432&view=rev Author: sknappe Date: 2008-10-26 20:29:18 +0000 (Sun, 26 Oct 2008) Log Message: ----------- new Ontology Script Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java Modified: trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java 2008-10-26 20:25:08 UTC (rev 1431) +++ trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java 2008-10-26 20:29:18 UTC (rev 1432) @@ -52,11 +52,11 @@ private static String dbUser; private static String dbPass; - private final String wikilinks = datasetDir + "pagelinks_en.nt"; - private final String labels = datasetDir + "articles_label_en.nt"; - private final String categories = datasetDir + "yago_en.nt"; - private final String categoriesNewOntology = datasetDir + "dbpedia-ontology-schema.nt"; - private final String categoriesNewOntology2 = datasetDir + "dbpedia-ontology-types.nt"; + private String wikilinks; + private String labels; + private String categories; + private String categoriesNewOntology; + private String categoriesNewOntology2; private static Connection con; @@ -70,6 +70,12 @@ dbUser = prefs.node("database").get("user", null); dbPass = prefs.node("database").get("pass", null); datasetDir = prefs.node("database").get("datasetDir", null); + + wikilinks = datasetDir + "pagelinks_en.nt"; + labels = datasetDir + "articles_label_en.nt"; + categories = datasetDir + "yago_en.nt"; + categoriesNewOntology = datasetDir + "dbpedia-ontology-schema.nt"; + categoriesNewOntology2 = datasetDir + "dbpedia-ontology-types.nt"; } private void calculateLinks() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-26 20:25:12
|
Revision: 1431 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1431&view=rev Author: sknappe Date: 2008-10-26 20:25:08 +0000 (Sun, 26 Oct 2008) Log Message: ----------- new Ontology Script Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java Modified: trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java 2008-10-26 20:22:32 UTC (rev 1430) +++ trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java 2008-10-26 20:25:08 UTC (rev 1431) @@ -65,7 +65,7 @@ // reading values from ini file String iniFile = "../src/dbpedia-navigator/settings.ini"; Preferences prefs = new IniFile(new File(iniFile)); - dbServer = prefs.node("database").get("name", null); + dbServer = prefs.node("database").get("server", null); dbName = prefs.node("database").get("name", null); dbUser = prefs.node("database").get("user", null); dbPass = prefs.node("database").get("pass", null); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-26 20:22:36
|
Revision: 1430 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1430&view=rev Author: sknappe Date: 2008-10-26 20:22:32 +0000 (Sun, 26 Oct 2008) Log Message: ----------- new Ontology Script Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java Modified: trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java 2008-10-26 20:20:54 UTC (rev 1429) +++ trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java 2008-10-26 20:22:32 UTC (rev 1430) @@ -63,7 +63,7 @@ public CalculatePageRank() throws BackingStoreException { // reading values from ini file - String iniFile = "src/dbpedia-navigator/settings.ini"; + String iniFile = "../src/dbpedia-navigator/settings.ini"; Preferences prefs = new IniFile(new File(iniFile)); dbServer = prefs.node("database").get("name", null); dbName = prefs.node("database").get("name", null); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-26 20:20:57
|
Revision: 1429 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1429&view=rev Author: sknappe Date: 2008-10-26 20:20:54 +0000 (Sun, 26 Oct 2008) Log Message: ----------- new Ontology Script Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java Modified: trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java 2008-10-26 19:46:33 UTC (rev 1428) +++ trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java 2008-10-26 20:20:54 UTC (rev 1429) @@ -321,15 +321,13 @@ } public static void main(String[] args) throws ClassNotFoundException,SQLException,BackingStoreException{ + CalculatePageRank cal=new CalculatePageRank(); Class.forName("com.mysql.jdbc.Driver"); - String url = - "jdbc:mysql://"+dbServer+":3306/"+dbName; - + "jdbc:mysql://"+dbServer+":3306/"+dbName; + con = DriverManager.getConnection( - url, dbUser, dbPass); - - CalculatePageRank cal=new CalculatePageRank(); + url, dbUser, dbPass); cal.calculateLinks(); cal.addLabels(); //cal.calculateCategories(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-26 19:46:41
|
Revision: 1428 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1428&view=rev Author: sknappe Date: 2008-10-26 19:46:33 +0000 (Sun, 26 Oct 2008) Log Message: ----------- new Ontology Script Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java Modified: trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java 2008-10-26 19:46:17 UTC (rev 1427) +++ trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java 2008-10-26 19:46:33 UTC (rev 1428) @@ -27,6 +27,7 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; +import java.sql.SQLException; import java.sql.Statement; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; @@ -45,18 +46,32 @@ */ public class CalculatePageRank { - private final String datasetDir = "src/dbpedia-navigator/data/"; + private static String datasetDir; + private static String dbServer; + private static String dbName; + private static String dbUser; + private static String dbPass; + private final String wikilinks = datasetDir + "pagelinks_en.nt"; private final String labels = datasetDir + "articles_label_en.nt"; private final String categories = datasetDir + "yago_en.nt"; private final String categoriesNewOntology = datasetDir + "dbpedia-ontology-schema.nt"; private final String categoriesNewOntology2 = datasetDir + "dbpedia-ontology-types.nt"; - private static String dbServer; - private static String dbName; - private static String dbUser; - private static String dbPass; + private static Connection con; + public CalculatePageRank() throws BackingStoreException + { + // reading values from ini file + String iniFile = "src/dbpedia-navigator/settings.ini"; + Preferences prefs = new IniFile(new File(iniFile)); + dbServer = prefs.node("database").get("name", null); + dbName = prefs.node("database").get("name", null); + dbUser = prefs.node("database").get("user", null); + dbPass = prefs.node("database").get("pass", null); + datasetDir = prefs.node("database").get("datasetDir", null); + } + private void calculateLinks() { try{ @@ -64,14 +79,6 @@ ResultSet rs; int number; - Class.forName("com.mysql.jdbc.Driver"); - - String url = - "jdbc:mysql://"+dbServer+":3306/"+dbName; - - Connection con = DriverManager.getConnection( - url, dbUser, dbPass); - stmt = con.createStatement(); BufferedReader in = new BufferedReader(new FileReader(wikilinks)); @@ -100,7 +107,6 @@ } in.close(); - con.close(); } catch (FileNotFoundException e) { System.out.println("File not found"); @@ -119,14 +125,6 @@ Statement stmt; ResultSet rs; - Class.forName("com.mysql.jdbc.Driver"); - - String url = - "jdbc:mysql://localhost:3306/navigator_db"; - - Connection con = DriverManager.getConnection( - url,"navigator", "dbpedia"); - stmt = con.createStatement(); BufferedReader in = new BufferedReader(new FileReader(labels)); @@ -155,7 +153,6 @@ } in.close(); - con.close(); } catch (FileNotFoundException e) { System.out.println("File not found"); @@ -173,14 +170,6 @@ try{ Statement stmt; - Class.forName("com.mysql.jdbc.Driver"); - - String url = - "jdbc:mysql://localhost:3306/navigator_db"; - - Connection con = DriverManager.getConnection( - url,"navigator", "dbpedia"); - stmt = con.createStatement(); BufferedReader in = new BufferedReader(new FileReader(categories)); @@ -224,7 +213,6 @@ } in.close(); - con.close(); } catch (FileNotFoundException e) { System.out.println("File not found"); @@ -242,14 +230,6 @@ try{ Statement stmt; - Class.forName("com.mysql.jdbc.Driver"); - - String url = - "jdbc:mysql://localhost:3306/navigator_db"; - - Connection con = DriverManager.getConnection( - url,"navigator", "dbpedia"); - stmt = con.createStatement(); BufferedReader in = new BufferedReader(new FileReader(categoriesNewOntology)); @@ -313,8 +293,6 @@ } in.close(); - - con.close(); } catch (FileNotFoundException e) { System.out.println("File not found"); @@ -332,40 +310,32 @@ try{ Statement stmt; - Class.forName("com.mysql.jdbc.Driver"); - - String url = - "jdbc:mysql://localhost:3306/navigator_db"; - - Connection con = DriverManager.getConnection( - url,"navigator", "dbpedia"); - stmt = con.createStatement(); stmt.executeUpdate("UPDATE articlecategories SET number=(SELECT number FROM rank WHERE articlecategories.name=rank.name)"); - - con.close(); + } catch (Exception e) { e.printStackTrace(); } } - public static void main(String[] args) throws BackingStoreException{ + public static void main(String[] args) throws ClassNotFoundException,SQLException,BackingStoreException{ + Class.forName("com.mysql.jdbc.Driver"); - // reading values from ini file - String iniFile = "src/dbpedia-navigator/settings.ini"; - Preferences prefs = new IniFile(new File(iniFile)); - dbServer = prefs.node("database").get("name", null); - dbName = prefs.node("database").get("name", null); - dbUser = prefs.node("database").get("user", null); - dbPass = prefs.node("database").get("pass", null); - + String url = + "jdbc:mysql://"+dbServer+":3306/"+dbName; + + con = DriverManager.getConnection( + url, dbUser, dbPass); + CalculatePageRank cal=new CalculatePageRank(); cal.calculateLinks(); cal.addLabels(); //cal.calculateCategories(); cal.calculateCategoriesNewOntology(); cal.copyNumbers(); + + con.close(); } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-26 19:46:26
|
Revision: 1427 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1427&view=rev Author: sknappe Date: 2008-10-26 19:46:17 +0000 (Sun, 26 Oct 2008) Log Message: ----------- added for database script Modified Paths: -------------- trunk/src/dbpedia-navigator/settings.ini.dist Modified: trunk/src/dbpedia-navigator/settings.ini.dist =================================================================== --- trunk/src/dbpedia-navigator/settings.ini.dist 2008-10-26 19:28:48 UTC (rev 1426) +++ trunk/src/dbpedia-navigator/settings.ini.dist 2008-10-26 19:46:17 UTC (rev 1427) @@ -17,4 +17,6 @@ ; the password of that user pass = dbpedia ; the name of the used database -name = navigator_db +name = navigator_db_new +; the name of the datasetDir for the CalculatePageRank Script +datasetDir = /mnt/sdb1/local_virtuoso_dbpedia_data_new/ \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-26 19:28:52
|
Revision: 1426 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1426&view=rev Author: sknappe Date: 2008-10-26 19:28:48 +0000 (Sun, 26 Oct 2008) Log Message: ----------- new Ontology Script Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java Modified: trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java 2008-10-24 13:38:01 UTC (rev 1425) +++ trunk/src/dl-learner/org/dllearner/scripts/CalculatePageRank.java 2008-10-26 19:28:48 UTC (rev 1426) @@ -49,6 +49,8 @@ private final String wikilinks = datasetDir + "pagelinks_en.nt"; private final String labels = datasetDir + "articles_label_en.nt"; private final String categories = datasetDir + "yago_en.nt"; + private final String categoriesNewOntology = datasetDir + "dbpedia-ontology-schema.nt"; + private final String categoriesNewOntology2 = datasetDir + "dbpedia-ontology-types.nt"; private static String dbServer; private static String dbName; @@ -181,8 +183,6 @@ stmt = con.createStatement(); - stmt.executeUpdate("ALTER TABLE rank DROP COLUMN category"); - BufferedReader in = new BufferedReader(new FileReader(categories)); String line; @@ -237,6 +237,96 @@ } } + private void calculateCategoriesNewOntology() + { + try{ + Statement stmt; + + Class.forName("com.mysql.jdbc.Driver"); + + String url = + "jdbc:mysql://localhost:3306/navigator_db"; + + Connection con = DriverManager.getConnection( + url,"navigator", "dbpedia"); + + stmt = con.createStatement(); + + BufferedReader in = new BufferedReader(new FileReader(categoriesNewOntology)); + + String line; + String[] split; + String name; + String label; + String pred; + int i=0; + boolean isClassLabel; + String className; + while ((line=in.readLine())!=null) + { + split=line.split(">"); + name=split[0].substring(1); + className=name.substring(name.lastIndexOf("/")+1,name.lastIndexOf("/")+2); + if (className.toLowerCase().equals(className)) + isClassLabel=false; + else + isClassLabel=true; + pred=split[1].substring(2); + if (pred.equals("http://www.w3.org/2000/01/rdf-schema#label")) + label=split[2].substring(split[2].indexOf("\"")+1, split[2].lastIndexOf("\"")); + else + label=split[2].substring(2); + if (pred.equals("http://www.w3.org/2000/01/rdf-schema#label")&&isClassLabel){ + try{ + stmt.executeUpdate("INSERT INTO categories (category,label) VALUES (\""+name+"\",\""+label+"\")"); + }catch(Exception e) + {} + } + else{ + if (pred.equals("http://www.w3.org/2000/01/rdf-schema#subClassOf")){ + try{ + stmt.executeUpdate("INSERT INTO classhierarchy (father,child) VALUES ('"+label+"','"+name+"')"); + }catch(Exception e) + {} + } + } + if (i%100000==0) System.out.println(i); + i++; + } + + in.close(); + + in = new BufferedReader(new FileReader(categoriesNewOntology2)); + + i=0; + while ((line=in.readLine())!=null) + { + split=line.split(">"); + name=split[0].substring(1); + label=split[2].substring(2); + try{ + stmt.executeUpdate("INSERT INTO articlecategories (name,category) VALUES ('"+name+"','"+label+"')"); + }catch(Exception e) + {} + if (i%100000==0) System.out.println(i); + i++; + } + + in.close(); + + con.close(); + } catch (FileNotFoundException e) + { + System.out.println("File not found"); + } catch (IOException e) + { + System.out.println("IOException"); + } catch (Exception e) + { + e.printStackTrace(); + } + } + private void copyNumbers() { try{ @@ -274,7 +364,8 @@ CalculatePageRank cal=new CalculatePageRank(); cal.calculateLinks(); cal.addLabels(); - cal.calculateCategories(); + //cal.calculateCategories(); + cal.calculateCategoriesNewOntology(); cal.copyNumbers(); } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-10-24 13:38:09
|
Revision: 1425 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1425&view=rev Author: heeroyuy Date: 2008-10-24 13:38:01 +0000 (Fri, 24 Oct 2008) Log Message: ----------- -added method that paints suggested concepts red that makes the ontology inconsistent Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-10-24 08:52:43 UTC (rev 1424) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-10-24 13:38:01 UTC (rev 1425) @@ -235,8 +235,9 @@ */ public void mouseClicked(MouseEvent m) { EvaluatedDescription eDescription = null; - String desc = view.getSuggestClassPanel().getSuggestList() - .getSelectedValue().toString(); + SuggestListItem item = (SuggestListItem) view.getSuggestClassPanel().getSuggestList() + .getSelectedValue(); + String desc = item.getValue(); if (model.getEvaluatedDescriptionList() != null) { for (Iterator<EvaluatedDescription> i = model .getEvaluatedDescriptionList().iterator(); i.hasNext();) { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-10-24 08:52:43 UTC (rev 1424) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-10-24 13:38:01 UTC (rev 1425) @@ -20,6 +20,7 @@ package org.dllearner.tools.protege; +import java.awt.Color; import java.net.URI; import java.util.HashSet; import java.util.Iterator; @@ -32,7 +33,6 @@ import javax.swing.DefaultListModel; import javax.swing.JCheckBox; -import org.dllearner.algorithms.SimpleSuggestionLearningAlgorithm; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; @@ -112,7 +112,6 @@ // This is the count of Concepts which you get after learning - // A Array of Concepts which the DL-Learner suggested private Description[] description; @@ -185,11 +184,6 @@ private Set<Individual> individual; - // This is a simple learning algorithm to get the first concepts before - // learning - - private SimpleSuggestionLearningAlgorithm test; - // The error message which is rendered when an error occured private String error; @@ -228,7 +222,6 @@ owlDescription = new HashSet<OWLDescription>(); positiv = new Vector<JCheckBox>(); negativ = new Vector<JCheckBox>(); - test = new SimpleSuggestionLearningAlgorithm(); ComponentManager.setComponentClasses(componenten); cm = ComponentManager.getInstance(); ds = new HashSet<OWLDescription>(); @@ -246,29 +239,34 @@ alreadyLearned = false; setKnowledgeSource(); setReasoner(); - SortedSet<Individual> pos = rs.getIndividuals(); - Set<Description> descri = test.getSimpleSuggestions(rs, pos); - int i = 0; - for (Iterator<Description> j = descri.iterator(); j.hasNext();) { - suggestModel.add(i, j.next()); - } - // suggestModel.add(0,test.getCurrentlyBestEvaluatedDescription(). - // getDescription - // ().toManchesterSyntaxString(editor.getOWLModelManager(). - // getActiveOntology().getURI().toString()+"#", null)); } /** * This method adds the solutions from the DL-Learner to the List Model. */ private void addToListModel() { - evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getMaxNrOfResultsModelData(), view.getPosAndNegSelectPanel().getMinAccuracyModelData(), true); + evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(view + .getPosAndNegSelectPanel().getMaxNrOfResultsModelData(), view + .getPosAndNegSelectPanel().getMinAccuracyModelData(), true); for (int j = 0; j < evalDescriptions.size(); j++) { - suggestModel.add(j, evalDescriptions.get(j) - .getDescription().toManchesterSyntaxString( - editor.getModelManager().getActiveOntology() - .getURI().toString() - + "#", null)); + System.out.println("KLICKEN: "+ evalDescriptions.get(j).getNotCoveredPositives()); + if (isConsistent(evalDescriptions.get(j))) { + suggestModel.add(j, new SuggestListItem(Color.GREEN, + evalDescriptions.get(j).getDescription() + .toManchesterSyntaxString( + editor.getModelManager() + .getActiveOntology().getURI() + .toString() + + "#", null))); + } else { + suggestModel.add(j, new SuggestListItem(Color.RED, + evalDescriptions.get(j).getDescription() + .toManchesterSyntaxString( + editor.getModelManager() + .getActiveOntology().getURI() + .toString() + + "#", null))); + } } } @@ -382,9 +380,12 @@ // TODO Auto-generated catch block e.printStackTrace(); } + System.out.println("3: " + + view.getPosAndNegSelectPanel().getMaxExecutionModelData()); cm.applyConfigEntry(la, "numberOfTrees", 100); cm.applyConfigEntry(la, "maxDepth", 5); - cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view.getPosAndNegSelectPanel().getMaxExecutionModelData()); + cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view + .getPosAndNegSelectPanel().getMaxExecutionModelData()); try { // initializes the learning algorithm la.init(); @@ -402,7 +403,8 @@ // start the algorithm and print the best concept found la.start(); description = new Description[la.getCurrentlyBestEvaluatedDescriptions( - view.getPosAndNegSelectPanel().getMaxNrOfResultsModelData()).size()]; + view.getPosAndNegSelectPanel().getMaxNrOfResultsModelData()) + .size()]; addToListModel(); // renders the errormessage view.renderErrorMessage(error); @@ -709,6 +711,15 @@ } /** + * This methode returns the Model for the suggested Concepts. + * + * @return DefaultListModel + */ + public DefaultListModel getSuggestModel() { + return suggestModel; + } + + /** * This method gets the old concept from checking the positive examples. */ private void setOldConceptOWLAPI() { @@ -742,7 +753,8 @@ * @param descript * Description learn by the DL-Learner */ - public void changeDLLearnerDescriptionsToOWLDescriptions(Description descript) { + public void changeDLLearnerDescriptionsToOWLDescriptions( + Description descript) { setNewConceptOWLAPI(descript); setOldConceptOWLAPI(); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); @@ -783,8 +795,20 @@ public boolean getAlreadyLearned() { return alreadyLearned; } + + private boolean isConsistent(EvaluatedDescription eDescription) { + boolean isConsistent = false; + if (eDescription.getNotCoveredPositives().isEmpty()) { + isConsistent = true; + } else { + isConsistent = false; + } + return isConsistent; + } + /** * This Method returns the URI of the currently loaded Ontology. + * * @return URI Ontology URI */ public URI getURI() { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-10-24 08:52:43 UTC (rev 1424) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-10-24 13:38:01 UTC (rev 1425) @@ -128,13 +128,14 @@ editingComponent = new JPanel(new BorderLayout()); editingComponent.add(tabbedPane); editingComponent.setPreferredSize(new Dimension(600, 520)); - + if(dllearner.getNrOfIndividuals()!=0) { if (label.equals("Equivalent classes")) { tabbedPane.add(SUGGEST_EQUIVALENT_CLASS_LABEL, dllearner); } if (label.equals("Superclasses")) { tabbedPane.add(SUGGEST_SUBCLASS_LABEL, dllearner); } + } tabbedPane.add(CLASS_EXPRESSION_EDITOR_LABEL, new JScrollPane(editor)); if (description == null || !description.isAnonymous()) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); @@ -515,7 +516,7 @@ /** * Returns the last added description. - * @return OWLDescriptio + * @return OWLDescription */ public OWLDescription getSollution() { return model.getSolution(); @@ -532,8 +533,15 @@ posPanel.unsetPosAndNegPanel(); learner.removeAll(); } - /** + * This method returns the nummers of Individuals present in the Ontology. + * @return int amount of Individuals in the Ontology + */ + public int getNrOfIndividuals() { + int counter = model.getPosVector().size(); + return counter; + } + /** * Renders the error message when an error occured. * @param s String */ Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-10-24 08:52:43 UTC (rev 1424) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-10-24 13:38:01 UTC (rev 1425) @@ -19,10 +19,12 @@ */ package org.dllearner.tools.protege; -import java.awt.Color; import java.awt.Dimension; -import javax.swing.*; +import javax.swing.DefaultListModel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; /** * This class is the panel for the suggest list. @@ -65,6 +67,7 @@ suggestPanel.add(descriptions); suggestScroll.setPreferredSize(new Dimension(490, 108)); suggestScroll.setViewportView(descriptions); + descriptions.setCellRenderer(new SuggestListCellRenderer()); add(suggestScroll); } @@ -83,7 +86,6 @@ * @param desc List model of descriptions made by the DL-Learner */ public void setSuggestList(DefaultListModel desc) { - descriptions.setForeground(Color.GREEN); descriptions.setModel(desc); } /** Added: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2008-10-24 13:38:01 UTC (rev 1425) @@ -0,0 +1,72 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.tools.protege; + +import java.awt.Color; +import java.awt.Component; + +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.ListCellRenderer; +/** + * This is the class that is responsible for the rendering of the + * concepts that are shown in the SuggestPanel. + * @author Christian Koetteritzsch + * + */ +public class SuggestListCellRenderer extends JLabel implements ListCellRenderer { + + private static final long serialVersionUID = 8040385703448641356L; + /** + * Construktor for the Cell Renderer for the Suggest List. + */ + public SuggestListCellRenderer() { + setOpaque(true); + } + + /** + * Renderer for the entries of the SuggestPanel. + * @param list JList + * @param value Object + * @param arg2 int + * @param arg4 boolean + * @param iss boolean boolean if current element is selected. + * @return Component Returns the currently rendered component of the suggest list + */ + public Component getListCellRendererComponent(JList list, Object value, + int arg2, boolean iss, boolean arg4) { + // Set the text and + // background color for rendering + setText(((SuggestListItem) value).getValue()); + setBackground(Color.WHITE); + setForeground(((SuggestListItem) value).getColor()); + // Set a border if the list + // item is selected + if (iss) { + setBorder(BorderFactory.createLineBorder(Color.GRAY, 2)); + } else { + setBorder(BorderFactory.createLineBorder(list.getBackground(), 2)); + } + + return this; + } + +} Added: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java 2008-10-24 13:38:01 UTC (rev 1425) @@ -0,0 +1,59 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.tools.protege; + +import java.awt.Color; +/** + * This Class represents an entry of the suggest list. + * @author Christian Koetteritzsch + * + */ +public class SuggestListItem { + + private Color color; + private String value; + /** + * Constructor for the SuggestListItem. + * @param c Color Color in which the text is painted. + * @param s String text that is shown. + */ + public SuggestListItem( + Color c, String s) { + color = c; + value = s; + } + + /** + * This method returns the color of the current list item. + * @return Color Color of the current list item + */ + public Color getColor() { + return color; + } + + /** + * This Method returns the text of the current list item. + * @return String Text of the current list item + */ + public String getValue() { + return value; + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-24 08:57:05
|
Revision: 1424 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1424&view=rev Author: sknappe Date: 2008-10-24 08:52:43 +0000 (Fri, 24 Oct 2008) Log Message: ----------- changed naturaldescription to use reasoner instead of sparql tasks Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryMaker.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java 2008-10-24 08:45:12 UTC (rev 1423) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java 2008-10-24 08:52:43 UTC (rev 1424) @@ -1,9 +1,14 @@ package org.dllearner.kb.sparql; +import java.util.Iterator; +import java.util.Set; import java.util.SortedSet; import org.apache.log4j.Logger; import org.dllearner.algorithms.gp.ADC; import org.dllearner.core.ComponentManager; +import org.dllearner.core.ReasoningMethodUnsupportedException; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DatatypeExactCardinalityRestriction; import org.dllearner.core.owl.DatatypeMaxCardinalityRestriction; import org.dllearner.core.owl.DatatypeMinCardinalityRestriction; @@ -11,6 +16,7 @@ import org.dllearner.core.owl.DatatypeValueRestriction; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.DescriptionVisitor; +import org.dllearner.core.owl.Entity; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; @@ -42,12 +48,12 @@ private String query=""; - private SPARQLTasks tasks; + private ReasoningService service; - public NaturalLanguageDescriptionConvertVisitor(String endpoint) + public NaturalLanguageDescriptionConvertVisitor(ReasoningService service) { //stack.push("subject"); - tasks=new SPARQLTasks(new Cache("cache"),SparqlEndpoint.getEndpointByName(endpoint)); + this.service=service; } private String getDescription() @@ -60,23 +66,42 @@ return query; } - public static String getNaturalLanguageDescription(Description description) + public static String getNaturalLanguageDescription(Description description, ReasoningService service) { - NaturalLanguageDescriptionConvertVisitor visitor=new NaturalLanguageDescriptionConvertVisitor("DBpedia"); + NaturalLanguageDescriptionConvertVisitor visitor=new NaturalLanguageDescriptionConvertVisitor(service); description.accept(visitor); String ret = visitor.getDescription(); return ret; } - public static String getNaturalLanguageDescription(String descriptionKBSyntax, String endpoint) throws ParseException + public static String getNaturalLanguageDescription(String descriptionKBSyntax, ReasoningService service) throws ParseException { Description d = KBParser.parseConcept(descriptionKBSyntax); - NaturalLanguageDescriptionConvertVisitor visitor=new NaturalLanguageDescriptionConvertVisitor(endpoint); + NaturalLanguageDescriptionConvertVisitor visitor=new NaturalLanguageDescriptionConvertVisitor(service); d.accept(visitor); String ret = visitor.getDescription(); return ret; } + private String getLabelFromReasoner(Entity ent) + { + String label; + try{ + Set<Constant> set=service.getLabel(ent); + if (set.size()>0){ + Iterator<Constant> iter=set.iterator(); + label=iter.next().getLiteral(); + } + else label=""; + } + catch (ReasoningMethodUnsupportedException e) + { + label=""; + } + + return label; + } + /** * Used for testing the Sparql Query converter. * @@ -110,7 +135,7 @@ //String conj="EXISTS \"http://xmlns.com/foaf/0.1/page\".<= 0 \"http://www.w3.org/2004/02/skos/core#subject\".TOP"; //String conj="(\"Male\" AND (\"hasDog\" = 18))"; ObjectValueRestriction rest=new ObjectValueRestriction(new ObjectProperty("hasAge"),new Individual("18")); - System.out.println(NaturalLanguageDescriptionConvertVisitor.getNaturalLanguageDescription(rest)); + //System.out.println(NaturalLanguageDescriptionConvertVisitor.getNaturalLanguageDescription(rest)); } catch (/*Parse*/Exception e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -131,8 +156,8 @@ */ public void visit(ObjectAllRestriction description) { logger.trace("ObjectAllRestriction"); - SortedSet<String> label=tasks.queryAsSet("SELECT ?label WHERE {<"+description.getRole().toString()+"> <http://www.w3.org/2000/01/rdf-schema#label> ?label}", "label"); - if (label.size()>0) query+="all "+label.first()+" are "; + String label=getLabelFromReasoner((ObjectProperty)description.getRole()); + if (label.length()>0) query+="all "+label+" are "; else query+="all "+description.getRole().toString().substring(description.getRole().toString().lastIndexOf("/")+1)+" are "; description.getChild(0).accept(this); logger.trace(description.getRole().toString()); @@ -144,8 +169,8 @@ */ public void visit(ObjectSomeRestriction description) { logger.trace("ObjectSomeRestriction"); - SortedSet<String> label=tasks.queryAsSet("SELECT ?label WHERE {<"+description.getRole().toString()+"> <http://www.w3.org/2000/01/rdf-schema#label> ?label}", "label"); - if (label.size()>0) query+="has "+label.first()+" which is "; + String label=getLabelFromReasoner((ObjectProperty)description.getRole()); + if (label.length()>0) query+="has "+label+" which is "; else query+="has "+description.getRole().toString().substring(description.getRole().toString().lastIndexOf("/")+1)+" which is "; description.getChild(0).accept(this); logger.trace(description.getRole().toString()); @@ -234,16 +259,16 @@ public void visit(ObjectValueRestriction description) { ObjectProperty op = (ObjectProperty) description.getRestrictedPropertyExpression(); Individual ind = description.getIndividual(); - SortedSet<String> label = tasks.queryAsSet("SELECT ?label WHERE {<"+ind.getName()+"> <http://www.w3.org/2000/01/rdf-schema#label> ?label}", "label"); + String label=getLabelFromReasoner(ind); String indLabel; - if (label.size()>0) - indLabel =label.first(); + if (label.length()>0) + indLabel =label; else indLabel =ind.getName(); - label = tasks.queryAsSet("SELECT ?label WHERE {<"+op.getName()+"> <http://www.w3.org/2000/01/rdf-schema#label> ?label}", "label"); + label=getLabelFromReasoner(op); String propLabel; - if (label.size()>0) - propLabel =label.first(); + if (label.length()>0) + propLabel =label; else propLabel =op.getName(); query += propLabel + " is " + indLabel; @@ -270,10 +295,10 @@ if (query.endsWith("and ")) query=query.substring(0, query.length()-5); if (query.endsWith("or ")) query=query.substring(0, query.length()-4); } - SortedSet<String> label=tasks.queryAsSet("SELECT ?label WHERE {<"+description.getName()+"> <http://www.w3.org/2000/01/rdf-schema#label> ?label}", "label"); - String l=label.first(); + //SortedSet<String> label=tasks.queryAsSet("SELECT ?label WHERE {<"+description.getName()+"> <http://www.w3.org/2000/01/rdf-schema#label> ?label}", "label"); + String l=getLabelFromReasoner(description); String l2=description.getName().substring(description.getName().lastIndexOf("/")+1, description.getName().length()).replace('_', ' '); - if (l.length()+5<l2.length()&&!l2.matches(".*[0-9]")) l=l2; + if ((l.length()==0)||(l.length()+5<l2.length()&&!l2.matches(".*[0-9]"))) l=l2; //replacements l=l.replaceAll("Cities", "City"); Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryMaker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryMaker.java 2008-10-24 08:45:12 UTC (rev 1423) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryMaker.java 2008-10-24 08:52:43 UTC (rev 1424) @@ -332,6 +332,7 @@ sqm.addPredicateFilter("http://www.w3.org/2000/01/rdf-schema#subClassOf"); sqm.addPredicateFilter("http://www.w3.org/2003/01/geo/wgs84_pos#lat"); sqm.addPredicateFilter("http://www.w3.org/2003/01/geo/wgs84_pos#long"); + sqm.addPredicateFilter("http://www.w3.org/2000/01/rdf-schema#label"); // pred.add("http://dbpedia.org/property/wikipage"); // pred.add("http://dbpedia.org/property/wikiPageUsesTemplate"); // pred.add("http://dbpedia.org/property/relatedInstance"); Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-10-24 08:45:12 UTC (rev 1423) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-10-24 08:52:43 UTC (rev 1424) @@ -54,6 +54,7 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningService; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; @@ -720,9 +721,11 @@ } @WebMethod - public String getNaturalDescription(String conceptString, String endpoint) throws ParseException { + public String getNaturalDescription(int id, String conceptString, String endpoint) throws ParseException, ClientNotKnownException { // call parser to parse concept - return NaturalLanguageDescriptionConvertVisitor.getNaturalLanguageDescription(conceptString, endpoint); + ClientState state = getState(id); + ReasoningService service = state.getReasoningService(); + return NaturalLanguageDescriptionConvertVisitor.getNaturalLanguageDescription(conceptString, service); } @WebMethod This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-24 08:47:53
|
Revision: 1423 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1423&view=rev Author: sknappe Date: 2008-10-24 08:45:12 +0000 (Fri, 24 Oct 2008) Log Message: ----------- changed behaviour for naturaldescriptions Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/main.wsdl Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-10-24 07:26:43 UTC (rev 1422) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-10-24 08:45:12 UTC (rev 1423) @@ -139,7 +139,7 @@ function getNaturalDescription($concept) { - return $this->client->getNaturalDescription($concept, $this->endpoint); + return $this->client->getNaturalDescription($this->id, $concept); } function getConceptDepth() Modified: trunk/src/dbpedia-navigator/main.wsdl =================================================================== --- trunk/src/dbpedia-navigator/main.wsdl 2008-10-24 07:26:43 UTC (rev 1422) +++ trunk/src/dbpedia-navigator/main.wsdl 2008-10-24 08:45:12 UTC (rev 1423) @@ -355,8 +355,9 @@ <part name="return" type="xsd:string"></part> </message> <message name="getNaturalDescription"> - <part name="arg0" type="xsd:string"></part> + <part name="arg0" type="xsd:int"></part> <part name="arg1" type="xsd:string"></part> + <part name="arg2" type="xsd:string"></part> </message> <message name="getNaturalDescriptionResponse"> <part name="return" type="xsd:string"></part> @@ -661,10 +662,11 @@ <output message="tns:SparqlRetrievalResponse"></output> <fault message="tns:ParseException" name="ParseException"></fault> </operation> - <operation name="getNaturalDescription" parameterOrder="arg0 arg1"> + <operation name="getNaturalDescription" parameterOrder="arg0 arg1 arg2"> <input message="tns:getNaturalDescription"></input> <output message="tns:getNaturalDescriptionResponse"></output> <fault message="tns:ParseException" name="ParseException"></fault> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> </operation> <operation name="getNegativeExamples" parameterOrder="arg0 arg1 arg2 arg3 arg4"> <input message="tns:getNegativeExamples"></input> @@ -1371,6 +1373,9 @@ <fault name="ParseException"> <soap:fault name="ParseException" use="literal"></soap:fault> </fault> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> </operation> <operation name="getNegativeExamples"> <soap:operation soapAction=""></soap:operation> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-10-24 07:26:53
|
Revision: 1422 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1422&view=rev Author: jenslehmann Date: 2008-10-24 07:26:43 +0000 (Fri, 24 Oct 2008) Log Message: ----------- - annotation support in core OWL library - added method to get rdfs:label from entities Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/core/owl/Individual.java trunk/src/dl-learner/org/dllearner/core/owl/KBElementVisitor.java trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java trunk/src/dl-learner/org/dllearner/core/owl/Property.java trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/tools/ore/RepairDialog.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/owl/Annotation.java trunk/src/dl-learner/org/dllearner/core/owl/ConstantAnnotation.java trunk/src/dl-learner/org/dllearner/core/owl/Entity.java trunk/src/dl-learner/org/dllearner/core/owl/LabelAnnotation.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-10-24 06:21:43 UTC (rev 1421) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -26,7 +26,6 @@ import java.util.Map; import java.util.NavigableSet; import java.util.Set; -import java.util.Stack; import java.util.TreeSet; import org.dllearner.core.ReasoningService; Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-10-24 06:21:43 UTC (rev 1421) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -28,6 +28,7 @@ import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.DatatypePropertyHierarchy; +import org.dllearner.core.owl.Entity; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; @@ -83,6 +84,11 @@ public Map<Individual, SortedSet<Constant>> getDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + // annotations (not strictly reasoning methods) + // [OWL API supports only annotations specified in a given ontology, which + // is uncomfortable to handle when several ontologies are loaded] + public Set<Constant> getLabel(Entity entity) throws ReasoningMethodUnsupportedException; + // some convenience methods public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; public Map<Individual, SortedSet<Boolean>> getBooleanDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-10-24 06:21:43 UTC (rev 1421) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -31,6 +31,7 @@ import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.DatatypePropertyHierarchy; +import org.dllearner.core.owl.Entity; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; @@ -112,6 +113,11 @@ throw new ReasoningMethodUnsupportedException(); } + public Set<Constant> getLabel(Entity entity) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-10-24 06:21:43 UTC (rev 1421) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -33,6 +33,7 @@ import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.DatatypePropertyHierarchy; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Entity; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; @@ -475,6 +476,16 @@ } } + public Set<Constant> getLabel(Entity entity) throws ReasoningMethodUnsupportedException { + try { + return reasoner.getLabel(entity); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) { reasoningStartTimeTmp = System.nanoTime(); Map<Individual, SortedSet<Individual>> result; Added: trunk/src/dl-learner/org/dllearner/core/owl/Annotation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Annotation.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/Annotation.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -0,0 +1,87 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.owl; + +import java.net.URI; +import java.util.Map; + +/** + * An annotation, e.g. rdfs:label "foo". + * + * @author Jens Lehmann + * + */ +public class Annotation implements KBElement { + + protected URI annotationURI; + protected KBElement annotationValue; + + public Annotation(URI annotationURI, KBElement annotationValue) { + this.annotationURI = annotationURI; + this.annotationValue = annotationValue; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#accept(org.dllearner.core.owl.KBElementVisitor) + */ + @Override + public void accept(KBElementVisitor visitor) { + visitor.visit(this); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#getLength() + */ + @Override + public int getLength() { + return 1 + annotationValue.getLength(); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#toKBSyntaxString(java.lang.String, java.util.Map) + */ + @Override + public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) { + return annotationURI + annotationValue.toKBSyntaxString(baseURI, prefixes); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) + */ + @Override + public String toString(String baseURI, Map<String, String> prefixes) { + return annotationURI + annotationValue.toString(baseURI, prefixes); + } + + /** + * @return the annotationURI + */ + public URI getAnnotationURI() { + return annotationURI; + } + + /** + * @return the annotationValue + */ + public KBElement getAnnotationValue() { + return annotationValue; + } + +} Added: trunk/src/dl-learner/org/dllearner/core/owl/ConstantAnnotation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ConstantAnnotation.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/ConstantAnnotation.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.owl; + +import java.net.URI; + +/** + * @author Jens Lehmann + * + */ +public class ConstantAnnotation extends Annotation { + + public ConstantAnnotation(URI annotationURI, Constant annotationValue) { + super(annotationURI, annotationValue); + } + + @Override + public Constant getAnnotationValue() { + return (Constant) annotationValue; + } + +} Added: trunk/src/dl-learner/org/dllearner/core/owl/Entity.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Entity.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/Entity.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.owl; + +/** + * Marker interface for classes, properties, individuals. + * + * @author Jens Lehmann + * + */ +public interface Entity extends NamedKBElement { + +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/Individual.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Individual.java 2008-10-24 06:21:43 UTC (rev 1421) +++ trunk/src/dl-learner/org/dllearner/core/owl/Individual.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -29,7 +29,7 @@ * @author Jens Lehmann * */ -public class Individual implements NamedKBElement, Comparable<Individual> { +public class Individual implements Entity, NamedKBElement, Comparable<Individual> { private String name; Modified: trunk/src/dl-learner/org/dllearner/core/owl/KBElementVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/KBElementVisitor.java 2008-10-24 06:21:43 UTC (rev 1421) +++ trunk/src/dl-learner/org/dllearner/core/owl/KBElementVisitor.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -43,4 +43,6 @@ void visit(UntypedConstant untypedConstant); + void visit(Annotation annotation); + } Added: trunk/src/dl-learner/org/dllearner/core/owl/LabelAnnotation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/LabelAnnotation.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/LabelAnnotation.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.owl; + +import java.net.URI; + +/** + * @author Jens Lehmann + * + */ +public class LabelAnnotation extends ConstantAnnotation { + + public LabelAnnotation(URI annotationURI, Constant annotationValue) { + super(annotationURI, annotationValue); + } + +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2008-10-24 06:21:43 UTC (rev 1421) +++ trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -30,7 +30,7 @@ * @author Jens Lehmann * */ -public class NamedClass extends Description implements NamedKBElement, Comparable<NamedClass> { +public class NamedClass extends Description implements Entity, NamedKBElement, Comparable<NamedClass> { String name; Modified: trunk/src/dl-learner/org/dllearner/core/owl/Property.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Property.java 2008-10-24 06:21:43 UTC (rev 1421) +++ trunk/src/dl-learner/org/dllearner/core/owl/Property.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -23,6 +23,6 @@ * @author Jens Lehmann * */ -public interface Property extends PropertyExpression, NamedKBElement { +public interface Property extends Entity, PropertyExpression, NamedKBElement { } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java 2008-10-24 06:21:43 UTC (rev 1421) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -1,16 +1,12 @@ package org.dllearner.kb.sparql; -import java.util.HashMap; import java.util.SortedSet; -import java.util.TreeSet; import org.apache.log4j.Logger; import org.dllearner.algorithms.gp.ADC; import org.dllearner.core.ComponentManager; -import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DatatypeExactCardinalityRestriction; import org.dllearner.core.owl.DatatypeMaxCardinalityRestriction; import org.dllearner.core.owl.DatatypeMinCardinalityRestriction; -import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.DatatypeSomeRestriction; import org.dllearner.core.owl.DatatypeValueRestriction; import org.dllearner.core.owl.Description; Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-10-24 06:21:43 UTC (rev 1421) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -51,6 +51,7 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.DoubleMaxValue; import org.dllearner.core.owl.DoubleMinValue; +import org.dllearner.core.owl.Entity; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; @@ -677,6 +678,11 @@ return rc.getRelatedValues(individual, datatypeProperty); } + @Override + public Set<Constant> getLabel(Entity entity) throws ReasoningMethodUnsupportedException { + return rc.getLabel(entity); + } + /* * (non-Javadoc) * Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-10-24 06:21:43 UTC (rev 1421) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -50,6 +50,7 @@ import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.DatatypePropertyHierarchy; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Entity; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.KB; import org.dllearner.core.owl.NamedClass; @@ -68,6 +69,7 @@ import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.inference.OWLReasoner; import org.semanticweb.owl.inference.OWLReasonerException; +import org.semanticweb.owl.model.OWLAnnotation; import org.semanticweb.owl.model.OWLClass; import org.semanticweb.owl.model.OWLConstant; import org.semanticweb.owl.model.OWLDataFactory; @@ -75,7 +77,9 @@ import org.semanticweb.owl.model.OWLDataRange; import org.semanticweb.owl.model.OWLDataType; import org.semanticweb.owl.model.OWLDescription; +import org.semanticweb.owl.model.OWLEntity; import org.semanticweb.owl.model.OWLIndividual; +import org.semanticweb.owl.model.OWLLabelAnnotation; import org.semanticweb.owl.model.OWLNamedObject; import org.semanticweb.owl.model.OWLObjectProperty; import org.semanticweb.owl.model.OWLOntology; @@ -733,25 +737,7 @@ } catch (OWLReasonerException e) { e.printStackTrace(); } - // convert data back to DL-Learner structures - SortedSet<Constant> is = new TreeSet<Constant>(); - for(OWLConstant oi : constants) { - // for typed constants we have to figure out the correct - // data type and value - if(oi instanceof OWLTypedConstant) { - Datatype dt = convertDatatype(((OWLTypedConstant)oi).getDataType()); - is.add(new TypedConstant(oi.getLiteral(),dt)); - // for untyped constants we have to figure out the value - // and language tag (if any) - } else { - OWLUntypedConstant ouc = (OWLUntypedConstant) oi; - if(ouc.hasLang()) - is.add(new UntypedConstant(ouc.getLiteral(), ouc.getLang())); - else - is.add(new UntypedConstant(ouc.getLiteral())); - } - } - return is; + return convertConstants(constants); } public Map<Individual, SortedSet<Double>> getDoubleValues(DatatypeProperty datatypeProperty) { @@ -907,6 +893,33 @@ } } + public static Set<Constant> convertConstants(Set<OWLConstant> constants) { + SortedSet<Constant> is = new TreeSet<Constant>(); + for(OWLConstant oi : constants) { + is.add(convertConstant(oi)); + } + return is; + } + + public static Constant convertConstant(OWLConstant constant) { + Constant c; + // for typed constants we have to figure out the correct + // data type and value + if(constant instanceof OWLTypedConstant) { + Datatype dt = convertDatatype(((OWLTypedConstant)constant).getDataType()); + c = new TypedConstant(constant.getLiteral(),dt); + // for untyped constants we have to figure out the value + // and language tag (if any) + } else { + OWLUntypedConstant ouc = (OWLUntypedConstant) constant; + if(ouc.hasLang()) + c = new UntypedConstant(ouc.getLiteral(), ouc.getLang()); + else + c = new UntypedConstant(ouc.getLiteral()); + } + return c; + } + public static Datatype convertDatatype(OWLDataType dataType) { URI uri = dataType.getURI(); if(uri.equals(Datatype.BOOLEAN.getURI())) @@ -927,6 +940,19 @@ return staticFactory.getOWLDataProperty(URI.create(datatypeProperty.getName())); } + private static OWLEntity getOWLAPIEntity(Entity entity) { + if(entity instanceof ObjectProperty) { + return staticFactory.getOWLObjectProperty(URI.create(entity.getName())); + } else if(entity instanceof DatatypeProperty) { + return staticFactory.getOWLDataProperty(URI.create(entity.getName())); + } else if(entity instanceof NamedClass) { + return staticFactory.getOWLClass(URI.create(entity.getName())); + } else if(entity instanceof OWLIndividual) { + return staticFactory.getOWLIndividual(URI.create(entity.getName())); + } + throw new Error("OWL API entity conversion for " + entity + " not supported."); + } + /** * Test * @@ -1037,5 +1063,18 @@ } - + @Override + @SuppressWarnings("all") + public Set<Constant> getLabel(Entity entity) { + OWLEntity owlEntity = getOWLAPIEntity(entity); + Set<OWLAnnotation> labelAnnotations = owlEntity.getAnnotations(owlAPIOntologies.get(0), URI.create("http://www.w3.org/2000/01/rdf-schema#label")); + Set<Constant> annotations = new HashSet<Constant>(); + for(OWLAnnotation label : labelAnnotations) { + OWLConstant c = ((OWLLabelAnnotation)label).getAnnotationValue(); + annotations.add(convertConstant(c)); + } + return annotations; + } + + } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/RepairDialog.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/RepairDialog.java 2008-10-24 06:21:43 UTC (rev 1421) +++ trunk/src/dl-learner/org/dllearner/tools/ore/RepairDialog.java 2008-10-24 07:26:43 UTC (rev 1422) @@ -102,6 +102,7 @@ final Component dialogd = this.getParent(); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { + @Override public void windowClosing(WindowEvent we) { if(allChanges.size() > 0){ if (JOptionPane.showConfirmDialog(dialogd, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-10-24 06:21:50
|
Revision: 1421 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1421&view=rev Author: jenslehmann Date: 2008-10-24 06:21:43 +0000 (Fri, 24 Oct 2008) Log Message: ----------- added reasoning methods getRelatedIndividuals + getRelatedValues Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-10-24 05:25:02 UTC (rev 1420) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-10-24 06:21:43 UTC (rev 1421) @@ -75,6 +75,10 @@ public SortedSet<Individual> retrieval(Description concept) throws ReasoningMethodUnsupportedException; + public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException; + + public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) throws ReasoningMethodUnsupportedException; public Map<Individual, SortedSet<Constant>> getDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-10-24 05:25:02 UTC (rev 1420) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-10-24 06:21:43 UTC (rev 1421) @@ -104,6 +104,14 @@ throw new ReasoningMethodUnsupportedException(); } + public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-10-24 05:25:02 UTC (rev 1420) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-10-24 06:21:43 UTC (rev 1421) @@ -28,6 +28,7 @@ import java.util.TreeSet; import org.apache.log4j.Logger; +import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.DatatypePropertyHierarchy; @@ -456,8 +457,24 @@ return result; } - // gibt zu einer Rolle alle Elemente zur�ck - // private, da es keine Standardoperation ist + public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { + try { + return reasoner.getRelatedIndividuals(individual, objectProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + try { + return reasoner.getRelatedValues(individual, datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) { reasoningStartTimeTmp = System.nanoTime(); Map<Individual, SortedSet<Individual>> result; Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-10-24 05:25:02 UTC (rev 1420) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-10-24 06:21:43 UTC (rev 1421) @@ -43,6 +43,7 @@ import org.dllearner.core.configurators.ComponentFactory; import org.dllearner.core.configurators.FastInstanceCheckerConfigurator; import org.dllearner.core.owl.BooleanValueRestriction; +import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.DatatypePropertyHierarchy; @@ -666,6 +667,16 @@ return opPos.get(atomicRole); } + @Override + public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { + return rc.getRelatedIndividuals(individual, objectProperty); + } + + @Override + public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + return rc.getRelatedValues(individual, datatypeProperty); + } + /* * (non-Javadoc) * Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-10-24 05:25:02 UTC (rev 1420) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-10-24 06:21:43 UTC (rev 1421) @@ -705,6 +705,55 @@ return map; } + @Override + public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) { + OWLIndividual ind = factory.getOWLIndividual(URI.create(individual.getName())); + OWLObjectProperty prop = getOWLAPIDescription(objectProperty); + Set<OWLIndividual> inds = null; + try { + inds = reasoner.getRelatedIndividuals(ind, prop); + } catch (OWLReasonerException e) { + e.printStackTrace(); + } + // convert data back to DL-Learner structures + SortedSet<Individual> is = new TreeSet<Individual>(); + for(OWLIndividual oi : inds) { + is.add(new Individual(oi.getURI().toString())); + } + return is; + } + + @Override + public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) { + OWLIndividual ind = factory.getOWLIndividual(URI.create(individual.getName())); + OWLDataProperty prop = getOWLAPIDescription(datatypeProperty); + Set<OWLConstant> constants = null; + try { + constants = reasoner.getRelatedValues(ind, prop); + } catch (OWLReasonerException e) { + e.printStackTrace(); + } + // convert data back to DL-Learner structures + SortedSet<Constant> is = new TreeSet<Constant>(); + for(OWLConstant oi : constants) { + // for typed constants we have to figure out the correct + // data type and value + if(oi instanceof OWLTypedConstant) { + Datatype dt = convertDatatype(((OWLTypedConstant)oi).getDataType()); + is.add(new TypedConstant(oi.getLiteral(),dt)); + // for untyped constants we have to figure out the value + // and language tag (if any) + } else { + OWLUntypedConstant ouc = (OWLUntypedConstant) oi; + if(ouc.hasLang()) + is.add(new UntypedConstant(ouc.getLiteral(), ouc.getLang())); + else + is.add(new UntypedConstant(ouc.getLiteral())); + } + } + return is; + } + public Map<Individual, SortedSet<Double>> getDoubleValues(DatatypeProperty datatypeProperty) { OWLDataProperty prop = getOWLAPIDescription(datatypeProperty); Map<Individual, SortedSet<Double>> map = new TreeMap<Individual, SortedSet<Double>>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Jen...@us...> - 2008-10-24 05:25:08
|
Revision: 1420 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1420&view=rev Author: JensLehmann Date: 2008-10-24 05:25:02 +0000 (Fri, 24 Oct 2008) Log Message: ----------- added more EL tests; fixed some bugs Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java trunk/src/dl-learner/org/dllearner/test/junit/ELDescriptionTreeTests.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-10-23 14:23:29 UTC (rev 1419) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-10-24 05:25:02 UTC (rev 1420) @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.NavigableSet; @@ -225,24 +226,24 @@ protected void updateSimulation(Set<ELDescriptionNode> nUpdate) { // create a stack and initialize it with the nodes to be updated - Stack<ELDescriptionNode> stack = new Stack<ELDescriptionNode>(); - stack.addAll(nUpdate); + LinkedList<ELDescriptionNode> list = new LinkedList<ELDescriptionNode>(); + list.addAll(nUpdate); - while(stack.size() != 0) { + while(list.size() != 0) { // take element from bottom of stack (to ensure that all nodes on the // same level are tested before any node of a lower level is tested) - ELDescriptionNode v = stack.peek(); // TODO: lookup whether peek is correct (had no Javadoc here) + ELDescriptionNode v = list.pollFirst(); // loop through all nodes on same level for(ELDescriptionNode w : levelNodeMapping.get(v.getLevel())) { if(!v.out.contains(w) && v.outSC1.contains(w) && checkSC2(v,w)) { extendSimulation(v,w); - stack.add(v.getParent()); - stack.add(w.getParent()); + list.add(v.getParent()); + list.add(w.getParent()); } if(!w.out.contains(v) && w.outSC1.contains(v) && checkSC2(w,v)) { extendSimulation(w,v); - stack.add(v.getParent()); - stack.add(w.getParent()); + list.add(v.getParent()); + list.add(w.getParent()); } } } Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDescriptionTreeTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDescriptionTreeTests.java 2008-10-23 14:23:29 UTC (rev 1419) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDescriptionTreeTests.java 2008-10-24 05:25:02 UTC (rev 1420) @@ -28,11 +28,14 @@ import org.dllearner.algorithms.el.ELDescriptionTreeComparator; import org.dllearner.algorithms.el.Simulation; import org.dllearner.algorithms.el.TreeTuple; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; +import org.dllearner.test.junit.TestOntologies.TestOntology; import org.dllearner.utilities.owl.ConceptTransformation; import org.junit.Test; @@ -47,10 +50,10 @@ @Test public void simulationTest() { + ReasoningService rs = TestOntologies.getTestOntology(TestOntology.EMPTY); Simulation s = new Simulation(); - // TODO we need to add background knowledge (possibly empty) - ELDescriptionTree tree1 = null; // new ELDescriptionTree(); - ELDescriptionTree tree2 = null; // new ELDescriptionTree(); + ELDescriptionTree tree1 = new ELDescriptionTree(rs); + ELDescriptionTree tree2 = new ELDescriptionTree(rs); ELDescriptionNode t1 = new ELDescriptionNode(tree1); ELDescriptionNode t2 = new ELDescriptionNode(tree2); TreeTuple tuple1 = new TreeTuple(t1,t2); @@ -65,11 +68,21 @@ } @Test + public void minimalityTest() throws ParseException, ComponentInitException { + ReasoningService rs = TestOntologies.getTestOntology(TestOntology.SIMPLE); + // the following should be recognized as non-minimal + Description d = KBParser.parseConcept("(human AND (EXISTS has.animal AND EXISTS has.TOP))"); + ConceptTransformation.cleanConcept(d); + ELDescriptionTree tree = new ELDescriptionTree(rs, d); + assertFalse(tree.isMinimal()); + } + + @Test public void cloneTest() throws ParseException { + ReasoningService rs = TestOntologies.getTestOntology(TestOntology.EMPTY); Description d = KBParser.parseConcept("(male AND (human AND EXISTS hasChild.(female AND EXISTS hasChild.male)))"); ConceptTransformation.cleanConcept(d); - // TODO needs to be updated (trees now require background knowledge) - ELDescriptionTree tree = null; // new ELDescriptionTree(rs, d); + ELDescriptionTree tree = new ELDescriptionTree(rs, d); ELDescriptionTree treeCloned = tree.clone(); ELDescriptionTreeComparator comparator = new ELDescriptionTreeComparator(); assertTrue(comparator.compare(tree, treeCloned) == 0); Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2008-10-23 14:23:29 UTC (rev 1419) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2008-10-24 05:25:02 UTC (rev 1420) @@ -24,23 +24,17 @@ import java.util.TreeSet; import org.dllearner.core.ComponentInitException; -import org.dllearner.core.ComponentManager; -import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.KB; -import org.dllearner.kb.KBFile; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; -import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.refinementoperators.ELDown; +import org.dllearner.test.junit.TestOntologies.TestOntology; import org.dllearner.utilities.Helper; import org.dllearner.utilities.owl.ConceptComparator; import org.dllearner.utilities.owl.ConceptTransformation; import org.junit.Test; -import static org.junit.Assert.*; - /** * Tests related to the EL downward refinement operator. * @@ -59,36 +53,12 @@ */ @Test public void refinementTest() throws ParseException, ComponentInitException { - ComponentManager cm = ComponentManager.getInstance(); + ReasoningService rs = TestOntologies.getTestOntology(TestOntology.SIMPLE); - // background knowledge - String kbString = ""; - kbString += "OPDOMAIN(hasChild) = human.\n"; - kbString += "OPRANGE(hasChild) = human.\n"; - kbString += "OPDOMAIN(hasPet) = human.\n"; - kbString += "OPRANGE(hasPet) = animal.\n"; - kbString += "Subrole(hasChild, has).\n"; - kbString += "Subrole(hasPet, has).\n"; - kbString += "bird SUB animal.\n"; - kbString += "cat SUB animal.\n"; - kbString += "(human AND animal) = BOTTOM.\n"; - KB kb = KBParser.parseKBFile(kbString); - // input description Description input = KBParser.parseConcept("(human AND EXISTS has.animal)"); - System.out.println("refining: " + input); + System.out.println("refining: " + input); - // create reasoner - KBFile source = new KBFile(kb); - ReasonerComponent rc = cm.reasoner(FastInstanceChecker.class, source); - ReasoningService rs = cm.reasoningService(rc); - source.init(); - rc.init(); - // TODO there shouldn't be a need to call this explicitly! - // (otherwise we get a NullPointerException, because the hierarchy is not created) - rs.prepareSubsumptionHierarchy(); - rs.prepareRoleHierarchy(); - // TODO For this test, we need to turn instance based disjoints // off! (We do not have any instances here.) ELDown operator = new ELDown(rs); @@ -129,9 +99,18 @@ // refinement must be in the set of desired refinements // assertTrue(refinements.size() == desired.size()); for(Description refinement : refinements) { - System.out.println(refinement); + boolean ok = desired.contains(refinement); + System.out.println(ok + ": " + refinement); // assertTrue(desired.contains(refinement)); } + + // generated by operator (and currently corresponding to its definition): + // false (http://localhost/foo#human AND EXISTS http://localhost/foo#has.(http://localhost/foo#animal AND http://localhost/foo#human + // false (http://localhost/foo#animal AND http://localhost/foo#human AND EXISTS http://localhost/foo#has.http://localhost/foo#animal + // solution: element of ncc should be tested for disjointness with any other candidate (here: animal and human) + + // edge added, but refinement not recognized as being minimal + // (http://localhost/foo#human AND EXISTS http://localhost/foo#has.http://localhost/foo#animal AND EXISTS http://localhost/foo#has.TOP) } } Added: trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2008-10-24 05:25:02 UTC (rev 1420) @@ -0,0 +1,84 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.test.junit; + +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.owl.KB; +import org.dllearner.kb.KBFile; +import org.dllearner.parser.KBParser; +import org.dllearner.parser.ParseException; +import org.dllearner.reasoning.FastInstanceChecker; + +/** + * Some ontologies to simplify unit tests. + * + * @author Jens Lehmann + * + */ +public final class TestOntologies { + + public enum TestOntology { EMPTY, SIMPLE }; + + public static ReasoningService getTestOntology(TestOntology ont) { + String kbString = ""; + + if(ont.equals(TestOntology.EMPTY)) { + // no background knowledge + } else if(ont.equals(TestOntology.SIMPLE)) { + // background knowledge used in EL paper + kbString += "OPDOMAIN(hasChild) = human.\n"; + kbString += "OPRANGE(hasChild) = human.\n"; + kbString += "OPDOMAIN(hasPet) = human.\n"; + kbString += "OPRANGE(hasPet) = animal.\n"; + kbString += "Subrole(hasChild, has).\n"; + kbString += "Subrole(hasPet, has).\n"; + kbString += "bird SUB animal.\n"; + kbString += "cat SUB animal.\n"; + kbString += "(human AND animal) = BOTTOM.\n"; + } + + try { + KB kb = KBParser.parseKBFile(kbString); + + // create reasoner + ComponentManager cm = ComponentManager.getInstance(); + KBFile source = new KBFile(kb); + ReasonerComponent rc = cm.reasoner(FastInstanceChecker.class, source); + ReasoningService rs = cm.reasoningService(rc); + source.init(); + rc.init(); + // TODO there shouldn't be a need to call this explicitly! + // (otherwise we get a NullPointerException, because the hierarchy is not created) + rs.prepareSubsumptionHierarchy(); + rs.prepareRoleHierarchy(); + return rs; + } catch(ParseException e) { + e.printStackTrace(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + + throw new Error("Test ontology could not be created."); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-23 14:23:33
|
Revision: 1419 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1419&view=rev Author: sknappe Date: 2008-10-23 14:23:29 +0000 (Thu, 23 Oct 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dbpedia-navigator/ajax_get_article.php Modified: trunk/src/dbpedia-navigator/ajax_get_article.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_article.php 2008-10-23 14:21:31 UTC (rev 1418) +++ trunk/src/dbpedia-navigator/ajax_get_article.php 2008-10-23 14:23:29 UTC (rev 1419) @@ -97,11 +97,11 @@ // give the link to the corresponding Wikipedia article if(isset($triples['http://xmlns.com/foaf/0.1/page'])) - $content .= '<p><img src="images/wikipedia_favicon.png" alt="Wikipedia" style="max-width:20px;" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0]['value'].'" onclick="window.open(\''.getPrintableURL($triples['http://xmlns.com/foaf/0.1/page'][0]['value']).'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view Wikipedia article</a>, '; - $content .= '<img src="images/dbpedia-favicon.ico" alt="DBpedia" style="max-width:20px;"/> <a href="'.$uri.'" onclick="window.open(\''.$uri.'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view DBpedia resource description</a>'; + $content .= '<p><img src="images/wikipedia_favicon.png" alt="Wikipedia" style="max-width:20px;" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0]['value'].'" onclick="window.open(\''.getPrintableURL($triples['http://xmlns.com/foaf/0.1/page'][0]['value']).'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');return false;">view Wikipedia article</a>, '; + $content .= '<img src="images/dbpedia-favicon.ico" alt="DBpedia" style="max-width:20px;"/> <a href="'.$uri.'" onclick="window.open(\''.$uri.'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');return false;">view DBpedia resource description</a>'; //display photo collection, if there is one if (isset($triples['http://dbpedia.org/property/hasPhotoCollection'])){ - $content.=', <img src="images/flickr.png" alt="Flickr" style="max-width:20px;" /> <a href="'.$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value'].'" onclick="window.open(\''.$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value'].'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view photo collection</a></p>'; + $content.=', <img src="images/flickr.png" alt="Flickr" style="max-width:20px;" /> <a href="'.$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value'].'" onclick="window.open(\''.$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value'].'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');return false;">view photo collection</a></p>'; } //display owl:sameAs properties This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-23 14:21:36
|
Revision: 1418 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1418&view=rev Author: sknappe Date: 2008-10-23 14:21:31 +0000 (Thu, 23 Oct 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dbpedia-navigator/helper_functions.php Modified: trunk/src/dbpedia-navigator/helper_functions.php =================================================================== --- trunk/src/dbpedia-navigator/helper_functions.php 2008-10-23 14:17:31 UTC (rev 1417) +++ trunk/src/dbpedia-navigator/helper_functions.php 2008-10-23 14:21:31 UTC (rev 1418) @@ -262,7 +262,7 @@ function get_triple_table($triples,$subjecttriples) { - if ((is_array($triples)&&count($triples)>0)||(is_array($subjecttriples)&&count($subjecttriples)>0){ + if ((is_array($triples)&&count($triples)>0)||(is_array($subjecttriples)&&count($subjecttriples)>0)){ $table = '<table border="0" style="width:100%;overflow:hidden"><tr><td><b>Predicate</b></td><td><b>Object/Subject</b></td></tr>'; $i=1; if (is_array($triples)&&count($triples)>0) foreach($triples as $predicate=>$object) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-23 14:17:41
|
Revision: 1417 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1417&view=rev Author: sknappe Date: 2008-10-23 14:17:31 +0000 (Thu, 23 Oct 2008) Log Message: ----------- bugfixes Modified Paths: -------------- trunk/src/dbpedia-navigator/ajax_get_article.php trunk/src/dbpedia-navigator/ajax_set_positives_and_negatives.php trunk/src/dbpedia-navigator/helper_functions.php trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/ajax_get_article.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_article.php 2008-10-23 08:44:58 UTC (rev 1416) +++ trunk/src/dbpedia-navigator/ajax_get_article.php 2008-10-23 14:17:31 UTC (rev 1417) @@ -65,7 +65,8 @@ $artTitle=$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]['value']; else $artTitle=urldecode(str_replace("_"," ",substr (strrchr ($uri, "/"), 1))); - + if (strpos($artTitle,'"')==strlen($artTitle)-1) $artTitle=substr($artTitle,0,strlen($artTitle)-1); + // display a picture if there is one if (isset($triples['http://dbpedia.org/property/imageCaption'])&&$triples['http://dbpedia.org/property/imageCaption'][0]['type']!='uri') $alt=$triples['http://dbpedia.org/property/imageCaption'][0]['value']; else if (isset($triples['http://dbpedia.org/property/caption'])&&$triples['http://dbpedia.org/property/caption'][0]['type']!='uri') $alt=$triples['http://dbpedia.org/property/caption'][0]['value']; @@ -96,11 +97,11 @@ // give the link to the corresponding Wikipedia article if(isset($triples['http://xmlns.com/foaf/0.1/page'])) - $content .= '<p><img src="images/wikipedia_favicon.png" alt="Wikipedia" style="max-width:20px;" /> <a href="#" onclick="window.open(\''.getPrintableURL($triples['http://xmlns.com/foaf/0.1/page'][0]['value']).'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view Wikipedia article</a>, '; - $content .= '<img src="images/dbpedia-favicon.ico" alt="DBpedia" style="max-width:20px;"/> <a href="#" onclick="window.open(\''.$uri.'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view DBpedia resource description</a>'; + $content .= '<p><img src="images/wikipedia_favicon.png" alt="Wikipedia" style="max-width:20px;" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0]['value'].'" onclick="window.open(\''.getPrintableURL($triples['http://xmlns.com/foaf/0.1/page'][0]['value']).'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view Wikipedia article</a>, '; + $content .= '<img src="images/dbpedia-favicon.ico" alt="DBpedia" style="max-width:20px;"/> <a href="'.$uri.'" onclick="window.open(\''.$uri.'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view DBpedia resource description</a>'; //display photo collection, if there is one if (isset($triples['http://dbpedia.org/property/hasPhotoCollection'])){ - $content.=', <img src="images/flickr.png" alt="Flickr" style="max-width:20px;" /> <a href="#" onclick="window.open(\''.$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value'].'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view photo collection</a></p>'; + $content.=', <img src="images/flickr.png" alt="Flickr" style="max-width:20px;" /> <a href="'.$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value'].'" onclick="window.open(\''.$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value'].'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view photo collection</a></p>'; } //display owl:sameAs properties Modified: trunk/src/dbpedia-navigator/ajax_set_positives_and_negatives.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_set_positives_and_negatives.php 2008-10-23 08:44:58 UTC (rev 1416) +++ trunk/src/dbpedia-navigator/ajax_set_positives_and_negatives.php 2008-10-23 14:17:31 UTC (rev 1417) @@ -22,6 +22,7 @@ $query="SELECT label FROM rank WHERE name='$pos' LIMIT 1"; $res=$databaseConnection->query($query); $result=$databaseConnection->nextEntry($res); + if (strlen($result['label'])<=0) $ptemp[$pos]=urldecode(str_replace("_"," ",substr (strrchr ($pos, "/"), 1))); $ptemp[$pos]=$result['label']; } @@ -30,6 +31,7 @@ $query="SELECT label FROM rank WHERE name='$neg' LIMIT 1"; $res=$databaseConnection->query($query); $result=$databaseConnection->nextEntry($res); + if (strlen($result['label'])<=0) $ntemp[$neg]=urldecode(str_replace("_"," ",substr (strrchr ($neg, "/"), 1))); $ntemp[$neg]=$result['label']; } Modified: trunk/src/dbpedia-navigator/helper_functions.php =================================================================== --- trunk/src/dbpedia-navigator/helper_functions.php 2008-10-23 08:44:58 UTC (rev 1416) +++ trunk/src/dbpedia-navigator/helper_functions.php 2008-10-23 14:17:31 UTC (rev 1417) @@ -30,8 +30,10 @@ function subjectToURI($subject) { //if the subject is already a URI return it - if (strpos($subject,"http://dbpedia.org/resource/")===0) - return $subject; + if (strpos($subject,"http://dbpedia.org/resource/")===0){ + $part=substr (strrchr ($subject, "/"), 1); + return substr($subject,0,strlen($subject)-strlen($part)).urlencode($part); + } //delete whitespaces at beginning and end $subject=trim($subject); //get first letters big @@ -260,87 +262,90 @@ function get_triple_table($triples,$subjecttriples) { - $table = '<table border="0" style="width:100%;overflow:hidden"><tr><td><b>Predicate</b></td><td><b>Object/Subject</b></td></tr>'; - $i=1; - foreach($triples as $predicate=>$object) { - $number=count($object); - if ($i>0) $backgroundcolor="eee"; - else $backgroundcolor="ffffff"; - $table .= '<tr style="background-color:#'.$backgroundcolor.';"><td><a href="'.$predicate.'" target="_blank">'.nicePredicate($predicate).'</a></td>'; - $table .= '<td>'; - if ($number>1) $table.='<ul>'; - $k=1; - foreach($object as $element) { - if ($k>3) $display=" style=\"display:none\""; - else $display=""; - if ($element['type']=="uri"){ - if (strpos($element['value'],"http://dbpedia.org/resource/")===0&&substr_count($element['value'],"/")==4&&strpos($element['value'],"Template:")!=28){ - $label=str_replace('_',' ',substr($element['value'],28)); - if (strlen($label)>60) $label=substr($label,0,60).'...'; - if ($number>1) $table.='<li'.$display.'>'; - $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');">'.urldecode($label).'</a>'; - if ($number>1) $table.='</li>'; + if ((is_array($triples)&&count($triples)>0)||(is_array($subjecttriples)&&count($subjecttriples)>0){ + $table = '<table border="0" style="width:100%;overflow:hidden"><tr><td><b>Predicate</b></td><td><b>Object/Subject</b></td></tr>'; + $i=1; + if (is_array($triples)&&count($triples)>0) foreach($triples as $predicate=>$object) { + $number=count($object); + if ($i>0) $backgroundcolor="eee"; + else $backgroundcolor="ffffff"; + $table .= '<tr style="background-color:#'.$backgroundcolor.';"><td><a href="'.$predicate.'" target="_blank">'.nicePredicate($predicate).'</a></td>'; + $table .= '<td>'; + if ($number>1) $table.='<ul>'; + $k=1; + foreach($object as $element) { + if ($k>3) $display=" style=\"display:none\""; + else $display=""; + if ($element['type']=="uri"){ + if (strpos($element['value'],"http://dbpedia.org/resource/")===0&&substr_count($element['value'],"/")==4&&strpos($element['value'],"Template:")!=28){ + $label=str_replace('_',' ',substr($element['value'],28)); + if (strlen($label)>60) $label=substr($label,0,60).'...'; + if ($number>1) $table.='<li'.$display.'>'; + $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');">'.urldecode($label).'</a>'; + if ($number>1) $table.='</li>'; + } + else{ + if ($number>1) $table.='<li'.$display.'>'; + $label=urldecode($element['value']); + if (strlen($label)>60) $label=substr($label,0,60).'...'; + $table .= '<a href="'.$element['value'].'" target="_blank">'.$label.'</a>'; + if ($number>1) $table.='</li>'; + } } else{ if ($number>1) $table.='<li'.$display.'>'; - $label=urldecode($element['value']); - if (strlen($label)>60) $label=substr($label,0,60).'...'; - $table .= '<a href="'.$element['value'].'" target="_blank">'.$label.'</a>'; + $table .= $element['value']; if ($number>1) $table.='</li>'; } + $k++; } - else{ - if ($number>1) $table.='<li'.$display.'>'; - $table .= $element['value']; - if ($number>1) $table.='</li>'; - } - $k++; + if ($number>3) $table.='<a href="javascript:none()" onclick="toggleAttributes(this)"><img src="images/arrow_down.gif"/> show</a>'; + if ($number>1) $table.='</ul>'; + $table .= '</td>'; + $i*=-1; } - if ($number>3) $table.='<a href="javascript:none()" onclick="toggleAttributes(this)"><img src="images/arrow_down.gif"/> show</a>'; - if ($number>1) $table.='</ul>'; - $table .= '</td>'; - $i*=-1; - } - foreach($subjecttriples as $predicate=>$object) { - $number=count($object); - if ($i>0) $backgroundcolor="eee"; - else $backgroundcolor="ffffff"; - $table .= '<tr style="background-color:#'.$backgroundcolor.';"><td><a href="'.$predicate.'" target="_blank">is '.nicePredicate($predicate).' of </a></td>'; - $table .= '<td>'; - if ($number>1) $table.='<ul>'; - $k=1; - foreach($object as $element) { - if ($k>3) $display=" style=\"display:none\""; - else $display=""; - if ($element['type']=="uri"){ - if (strpos($element['value'],"http://dbpedia.org/resource/")===0&&substr_count($element['value'],"/")==4&&strpos($element['value'],"Template:")!=28){ - $label=str_replace('_',' ',substr($element['value'],28)); - if (strlen($label)>60) $label=substr($label,0,60).'...'; - if ($number>1) $table.='<li'.$display.'>'; - $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');">'.urldecode($label).'</a>'; - if ($number>1) $table.='</li>'; + if (is_array($subjecttriples)&&count($subjecttriples)>0) foreach($subjecttriples as $predicate=>$object) { + $number=count($object); + if ($i>0) $backgroundcolor="eee"; + else $backgroundcolor="ffffff"; + $table .= '<tr style="background-color:#'.$backgroundcolor.';"><td><a href="'.$predicate.'" target="_blank">is '.nicePredicate($predicate).' of </a></td>'; + $table .= '<td>'; + if ($number>1) $table.='<ul>'; + $k=1; + foreach($object as $element) { + if ($k>3) $display=" style=\"display:none\""; + else $display=""; + if ($element['type']=="uri"){ + if (strpos($element['value'],"http://dbpedia.org/resource/")===0&&substr_count($element['value'],"/")==4&&strpos($element['value'],"Template:")!=28){ + $label=str_replace('_',' ',substr($element['value'],28)); + if (strlen($label)>60) $label=substr($label,0,60).'...'; + if ($number>1) $table.='<li'.$display.'>'; + $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');">'.urldecode($label).'</a>'; + if ($number>1) $table.='</li>'; + } + else{ + if ($number>1) $table.='<li'.$display.'>'; + $label=urldecode($element['value']); + if (strlen($label)>60) $label=substr($label,0,60).'...'; + $table .= '<a href="'.$element['value'].'" target="_blank">'.$label.'</a>'; + if ($number>1) $table.='</li>'; + } } else{ if ($number>1) $table.='<li'.$display.'>'; - $label=urldecode($element['value']); - if (strlen($label)>60) $label=substr($label,0,60).'...'; - $table .= '<a href="'.$element['value'].'" target="_blank">'.$label.'</a>'; + $table .= $element['value']; if ($number>1) $table.='</li>'; } + $k++; } - else{ - if ($number>1) $table.='<li'.$display.'>'; - $table .= $element['value']; - if ($number>1) $table.='</li>'; - } - $k++; + if ($number>3) $table.='<a href="javascript:none()" onclick="toggleAttributes(this)"><img src="images/arrow_down.gif"/> show</a>'; + if ($number>1) $table.='</ul>'; + $table .= '</td>'; + $i*=-1; } - if ($number>3) $table.='<a href="javascript:none()" onclick="toggleAttributes(this)"><img src="images/arrow_down.gif"/> show</a>'; - if ($number>1) $table.='</ul>'; - $table .= '</td>'; - $i*=-1; + $table .= '</table>'; } - $table .= '</table>'; + else $table="No Tripel left."; return $table; } Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-10-23 08:44:58 UTC (rev 1416) +++ trunk/src/dbpedia-navigator/index.php 2008-10-23 14:17:31 UTC (rev 1417) @@ -18,11 +18,26 @@ $onLoad="onLoad=\"document.getElementById('label').focus();"; if (isset($_GET['positives'])||isset($_GET['negatives'])) $onLoad.="setPositivesAndNegatives('positives=".@$_GET['positives']."&negatives=".@$_GET['negatives']."');"; else if (isset($_SESSION['positives'])||isset($_SESSION['negatives'])) $onLoad.="setPositivesAndNegatives('positives=".$_SESSION['positives']."&negatives=".$_SESSION['negatives']."');"; -if (isset($_GET['showArticle'])) $onLoad.="get_article('label=".$_GET['showArticle']."&cache=-1');"; -else if (isset($_GET['search'])) $onLoad.="search_it('label=".$_GET['search']."&number=10');"; -else if (isset($_GET['showClass'])) $onLoad.="get_class('class=http://dbpedia.org/class/yago/".$_GET['showClass']."&cache=-1');"; -else if (isset($_GET['searchInstances'])) $onLoad.="getSubjectsFromCategory('category=http://dbpedia.org/class/yago/".$_GET['searchInstances']."&number=10');"; -else if (isset($_GET['searchConceptInstances'])) $onLoad.="getSubjectsFromConcept('kb=".htmlentities(urldecode($_GET['concept']))."&number=10');"; +if (isset($_GET['showArticle'])){ + session_unset(); + $onLoad.="get_article('label=".$_GET['showArticle']."&cache=-1');"; +} +else if (isset($_GET['search'])){ + session_unset(); + $onLoad.="search_it('label=".$_GET['search']."&number=10');"; +} +else if (isset($_GET['showClass'])){ + session_unset(); + $onLoad.="get_class('class=http://dbpedia.org/class/yago/".$_GET['showClass']."&cache=-1');"; +} +else if (isset($_GET['searchInstances'])){ + session_unset(); + $onLoad.="getSubjectsFromCategory('category=http://dbpedia.org/class/yago/".$_GET['searchInstances']."&number=10');"; +} +else if (isset($_GET['searchConceptInstances'])){ + session_unset(); + $onLoad.="getSubjectsFromConcept('kb=".htmlentities(urldecode($_GET['concept']))."&number=10');"; +} else if (isset($_SESSION['currentArticle'])){ $onLoad.="get_article('label=&cache=".$_SESSION['currentArticle']."');"; } @@ -86,14 +101,14 @@ <div class="box" id="credits"> <p>DBpedia Navigator is powered by ... <br /> - <a href="http://dl-learner.org">DL-Learner</a><br /> - <a href="http//dbpedia.org">DBpedia</a><br/> - <a href="http://virtuoso.openlinksw.com/wiki/main/">OpenLink Virtuoso</a><br /> - ... and implemented by <a href="http://jens-lehmann.org">Jens Lehmann</a> and - Sebastian Knappe at the <a href="http:/aksw.org">AKSW</a> research group (University of Leipzig).</p> + <a href="http://dl-learner.org" target="_blank">DL-Learner</a><br /> + <a href="http//dbpedia.org" target="_blank">DBpedia</a><br/> + <a href="http://virtuoso.openlinksw.com/wiki/main/" target="_blank">OpenLink Virtuoso</a><br /> + ... and implemented by <a href="http://jens-lehmann.org" target="_blank">Jens Lehmann</a> and + Sebastian Knappe at the <a href="http:/aksw.org" target="_blank">AKSW</a> research group (University of Leipzig).</p> - <a href="http://www.w3.org/2004/OWL/"><img src="images/sw-owl-green.png" alt="OWL logo" /></a> - <a href="http://www.w3.org/2001/sw/DataAccess/"><img src="images/sw-sparql-green.png" alt="SPARQL logo"/></a> + <a href="http://www.w3.org/2004/OWL/" target="_blank"><img src="images/sw-owl-green.png" alt="OWL logo" /></a> + <a href="http://www.w3.org/2001/sw/DataAccess/" target="_blank"><img src="images/sw-sparql-green.png" alt="SPARQL logo"/></a> </div> </div><!-- END leftSidebar --> @@ -152,45 +167,12 @@ $uri = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; echo '<div><a href="http://validator.w3.org/check?uri='.$uri.'"'; - echo '><img src="images/valid-xhtml10.png" alt="valid XHTML 1.0" /></a>'."\n"; + echo ' target="_blank"><img src="images/valid-xhtml10.png" alt="valid XHTML 1.0" /></a>'."\n"; echo '<a href="http://jigsaw.w3.org/css-validator/validator?uri='.$uri.'"'; - echo '><img src="images/valid-css.png" alt="valid CSS" /></a></div>'."\n"; + echo ' target="_blank"><img src="images/valid-css.png" alt="valid CSS" /></a></div>'."\n"; ?> - </div> - <p><a href='rebuild.php'>rebuild [restart session and redownload WSDL file (for debugging)]</a></p> + </div> </div> - -<div id="todo"> -<b>ToDo:</b> -<ul style="float:left"> - <li>Get learning component fast.</li> - <li>Get local DBpedia SPARQL endpoint working (next DBpedia release expected at the endof January and then every - two months, so it would be nice to have a script based partly automated or at least documented solution for - creating a DBpedia mirror).</li> - <li>Improve stability: Fix sometimes occurring PHP errors and warnings (check PHP error log).</li> - <li>For each result, display a "+" which shows more information about the concept in an overlay box, e.g. its - Description Logic or OWL syntax, its classification accuracy on the examples, and which - examples it classifies (in-)correctly.</li> - <li>Create a small number of test cases (e.g. 3), which can be used to verify that DBpedia Navigator is - working in typical scenarios (in particular cases where concepts with length greater one are learned).</li> - <li>Make DBpedia Navigator RESTful, e.g. URLs $base/showArticle/$URL for displaying an article; - $base/search/$phrase for searching; $base/listInstances/$complexClass for listing the instances of - a learned. Maybe session variables (in particuar the selected positive and negative examples) can - also be given, e.g. $base/search/$phrase?positives=[$URL1,$URL2,$URL3]&negatives=[$URL4]. The supported - URI design should be briefly documented (e.g. on a dbpedia.org wiki page). A good URI design allows - easier external access (just give someone a link instead of saying exactly which actions have to be done to - get to a state), simplifies debugging the application, and may be of use for creating further - features.</li> - <li>[if possible] When expensive SPARQL queries or learning problems have been posed, there should be - some way to abandon these if the user has already switched to doing something else. Example: The user - has added 3 positive and 1 negative examples. This is executed as a learning problem, but has no solution (so - DL-Learner would run forever unless we pose some internal time limit). The user adds another negative example a - second later, so instead of letting the previous learning problem run for a long time (and needing much resources), - it should be stopped by DBpedia Navigator.</li> - <li>[if possible] Find an easy way to validate HTML/JS in AJAX applications.</li> -</ul> -</div> - </body> </html> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-23 08:47:39
|
Revision: 1416 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1416&view=rev Author: sknappe Date: 2008-10-23 08:44:58 +0000 (Thu, 23 Oct 2008) Log Message: ----------- ObjectValueRestrictions should work Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java 2008-10-23 08:43:03 UTC (rev 1415) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java 2008-10-23 08:44:58 UTC (rev 1416) @@ -6,9 +6,11 @@ import org.apache.log4j.Logger; import org.dllearner.algorithms.gp.ADC; import org.dllearner.core.ComponentManager; +import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DatatypeExactCardinalityRestriction; import org.dllearner.core.owl.DatatypeMaxCardinalityRestriction; import org.dllearner.core.owl.DatatypeMinCardinalityRestriction; +import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.DatatypeSomeRestriction; import org.dllearner.core.owl.DatatypeValueRestriction; import org.dllearner.core.owl.Description; @@ -110,9 +112,10 @@ } System.out.println("Finished");*/ //String conj="EXISTS \"http://xmlns.com/foaf/0.1/page\".<= 0 \"http://www.w3.org/2004/02/skos/core#subject\".TOP"; - String conj="(\"Male\" AND (\"hasDog\" = 18))"; - System.out.println(NaturalLanguageDescriptionConvertVisitor.getNaturalLanguageDescription(conj, "DBPEDIA")); - } catch (ParseException e) { + //String conj="(\"Male\" AND (\"hasDog\" = 18))"; + ObjectValueRestriction rest=new ObjectValueRestriction(new ObjectProperty("hasAge"),new Individual("18")); + System.out.println(NaturalLanguageDescriptionConvertVisitor.getNaturalLanguageDescription(rest)); + } catch (/*Parse*/Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -236,9 +239,17 @@ ObjectProperty op = (ObjectProperty) description.getRestrictedPropertyExpression(); Individual ind = description.getIndividual(); SortedSet<String> label = tasks.queryAsSet("SELECT ?label WHERE {<"+ind.getName()+"> <http://www.w3.org/2000/01/rdf-schema#label> ?label}", "label"); - String indLabel =label.first(); + String indLabel; + if (label.size()>0) + indLabel =label.first(); + else + indLabel =ind.getName(); label = tasks.queryAsSet("SELECT ?label WHERE {<"+op.getName()+"> <http://www.w3.org/2000/01/rdf-schema#label> ?label}", "label"); - String propLabel =label.first(); + String propLabel; + if (label.size()>0) + propLabel =label.first(); + else + propLabel =op.getName(); query += propLabel + " is " + indLabel; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Jen...@us...> - 2008-10-23 08:44:04
|
Revision: 1415 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1415&view=rev Author: JensLehmann Date: 2008-10-23 08:43:03 +0000 (Thu, 23 Oct 2008) Log Message: ----------- EL refinement ctd. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2008-10-23 07:41:02 UTC (rev 1414) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2008-10-23 08:43:03 UTC (rev 1415) @@ -71,11 +71,11 @@ // simulation information (list or set?) protected Set<ELDescriptionNode> in = new HashSet<ELDescriptionNode>(); - private Set<ELDescriptionNode> inSC1 = new HashSet<ELDescriptionNode>(); - private Set<ELDescriptionNode> inSC2 = new HashSet<ELDescriptionNode>(); + protected Set<ELDescriptionNode> inSC1 = new HashSet<ELDescriptionNode>(); + protected Set<ELDescriptionNode> inSC2 = new HashSet<ELDescriptionNode>(); protected Set<ELDescriptionNode> out = new HashSet<ELDescriptionNode>(); - private Set<ELDescriptionNode> outSC1 = new HashSet<ELDescriptionNode>(); - private Set<ELDescriptionNode> outSC2 = new HashSet<ELDescriptionNode>(); + protected Set<ELDescriptionNode> outSC1 = new HashSet<ELDescriptionNode>(); + protected Set<ELDescriptionNode> outSC2 = new HashSet<ELDescriptionNode>(); /** * Constructs an EL description tree with empty root label. @@ -98,7 +98,7 @@ tree.rootNode = this; tree.addNodeToLevel(this, level); - // TODO simulation update + // TODO simulation initialization } public ELDescriptionNode(ELDescriptionNode parentNode, ObjectProperty parentProperty, NavigableSet<NamedClass> label) { @@ -126,16 +126,16 @@ } - if(inSC1.contains(w) && checkSC2(this, w)) { - extendSimulation(this, w); + if(inSC1.contains(w) && tree.checkSC2(this, w)) { + tree.extendSimulation(this, w); update.add(w.parent); } } // loop over all nodes in out set for(ELDescriptionNode w : out) { - if(!checkSC1(this, w)) { - shrinkSimulation(this, w); + if(!tree.checkSC1(this, w)) { + tree.shrinkSimulation(this, w); update.add(w.parent); } } @@ -299,16 +299,16 @@ Set<ELDescriptionNode> tmp = Helper.difference(nodes, in); for(ELDescriptionNode w : tmp) { // we only need to recompute SC2 - if(inSC1.contains(w) && checkSC2(this, w)) { - extendSimulation(this, w); + if(inSC1.contains(w) && tree.checkSC2(this, w)) { + tree.extendSimulation(this, w); update.add(w.parent); } } // loop over all nodes in out set for(ELDescriptionNode w : out) { - if(!checkSC1(this, w)) { - shrinkSimulation(this, w); + if(!tree.checkSC1(this, w)) { + tree.shrinkSimulation(this, w); update.add(w.parent); } } @@ -316,89 +316,36 @@ // apply updates recursively top-down tree.updateSimulation(update); } - - // SC satisfied if both SC1 and SC2 satisfied - private boolean checkSC(ELDescriptionNode node1, ELDescriptionNode node2) { - return checkSC1(node1, node2) && checkSC2(node1, node2); - } - - // tests simulation condition 1 (SC1) - private boolean checkSC1(ELDescriptionNode node1, ELDescriptionNode node2) { - return isSublabel(node1.label, node2.label); - } - - private boolean isSublabel(NavigableSet<NamedClass> subLabel, NavigableSet<NamedClass> superLabel) { - // implemented according to definition in article - // (TODO can probably be done more efficiently) - for(NamedClass nc : superLabel) { - if(!containsSubclass(nc, subLabel)) { - return false; - } - } - return true; - } - - private boolean containsSubclass(NamedClass superClass, NavigableSet<NamedClass> label) { - for(NamedClass nc : label) { - if(tree.subsumptionHierarchy.isSubclassOf(nc, superClass)) { - return true; - } - } - return false; - } - - // tests simulation condition 2 (SC2) - private boolean checkSC2(ELDescriptionNode node1, ELDescriptionNode node2) { - List<ELDescriptionEdge> edges1 = node1.getEdges(); - List<ELDescriptionEdge> edges2 = node2.getEdges(); + + public void refineEdge(int edgeNumber, ObjectProperty op) { + edges.get(edgeNumber).setLabel(op); - for(ELDescriptionEdge edge : edges1) { - // try to find an edge satisfying SC2 in the set - if(!checkSC2Edge(edge, edges2)) { - return false; + // compute the nodes, which need to be updated + Set<ELDescriptionNode> update = new TreeSet<ELDescriptionNode>(); + + // loop over all nodes on the same level, which are not in the in set + Set<ELDescriptionNode> nodes = tree.getNodesOnLevel(level); + Set<ELDescriptionNode> tmp = Helper.difference(nodes, in); + for(ELDescriptionNode w : tmp) { + // we only need to recompute SC1 + if(inSC2.contains(w) && tree.checkSC1(this, w)) { + tree.extendSimulation(this, w); + update.add(w.parent); } } - return true; - } - - // check whether edges contains an element satisfying SC2 - private boolean checkSC2Edge(ELDescriptionEdge edge, List<ELDescriptionEdge> edges) { - ObjectProperty op1 = edge.getLabel(); - ELDescriptionNode node1 = edge.getTree(); - - for(ELDescriptionEdge edge2 : edges) { - ObjectProperty op2 = edge2.getLabel(); - // we first check the condition on the properties - if(tree.roleHierarchy.isSubpropertyOf(op1, op2)) { - // check condition on simulations of referred nodes - ELDescriptionNode node2 = edge2.getTree(); - if(node1.in.contains(node2) || node2.in.contains(node1)) { - // we found a node satisfying the condition, so we can return - return true; - } + // loop over all nodes in out set + for(ELDescriptionNode w : out) { + if(!tree.checkSC2(this, w)) { + tree.shrinkSimulation(this, w); + update.add(w.parent); } } - // none of the edges in the set satisfies the 2nd simulation criterion - // wrt. the first edge - return false; + // apply updates recursively top-down + tree.updateSimulation(update); } - - // adds (node1,node2) to simulation, takes care of all helper sets - private void extendSimulation(ELDescriptionNode node1, ELDescriptionNode node2) { - node1.out.add(node2); - node2.in.add(node1); - // TODO: SC1, SC2 sets ? - } - // removes (node1,node2) from simulation, takes care of all helper sets - private void shrinkSimulation(ELDescriptionNode node1, ELDescriptionNode node2) { - node1.out.remove(node2); - node2.in.remove(node1); - // TODO: SC1, SC2 sets ? - } - /** * Gets the label of this node. Do not modify the returned object, * but use the provided methods instead! @@ -443,4 +390,8 @@ } return str; } + + public ELDescriptionNode getParent() { + return parent; + } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-10-23 07:41:02 UTC (rev 1414) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-10-23 08:43:03 UTC (rev 1415) @@ -23,7 +23,9 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.NavigableSet; import java.util.Set; +import java.util.Stack; import java.util.TreeSet; import org.dllearner.core.ReasoningService; @@ -222,16 +224,118 @@ } protected void updateSimulation(Set<ELDescriptionNode> nUpdate) { -// for(ELDescriptionNode node : nodes) { -// -// } - Set<ELDescriptionNode> update; - while(nUpdate.size() != 0) { - update = nUpdate; // TODO: clone - + // create a stack and initialize it with the nodes to be updated + Stack<ELDescriptionNode> stack = new Stack<ELDescriptionNode>(); + stack.addAll(nUpdate); + + while(stack.size() != 0) { + // take element from bottom of stack (to ensure that all nodes on the + // same level are tested before any node of a lower level is tested) + ELDescriptionNode v = stack.peek(); // TODO: lookup whether peek is correct (had no Javadoc here) + // loop through all nodes on same level + for(ELDescriptionNode w : levelNodeMapping.get(v.getLevel())) { + if(!v.out.contains(w) && v.outSC1.contains(w) && checkSC2(v,w)) { + extendSimulation(v,w); + stack.add(v.getParent()); + stack.add(w.getParent()); + } + if(!w.out.contains(v) && w.outSC1.contains(v) && checkSC2(w,v)) { + extendSimulation(w,v); + stack.add(v.getParent()); + stack.add(w.getParent()); + } + } } } + // SC satisfied if both SC1 and SC2 satisfied + public boolean checkSC(ELDescriptionNode node1, ELDescriptionNode node2) { + return checkSC1(node1, node2) && checkSC2(node1, node2); + } + + // tests simulation condition 1 (SC1) + public boolean checkSC1(ELDescriptionNode node1, ELDescriptionNode node2) { + return isSublabel(node1.getLabel(), node2.getLabel()); + } + + private boolean isSublabel(NavigableSet<NamedClass> subLabel, NavigableSet<NamedClass> superLabel) { + // implemented according to definition in article + // (TODO can probably be done more efficiently) + for(NamedClass nc : superLabel) { + if(!containsSubclass(nc, subLabel)) { + return false; + } + } + return true; + } + + private boolean containsSubclass(NamedClass superClass, NavigableSet<NamedClass> label) { + for(NamedClass nc : label) { + if(subsumptionHierarchy.isSubclassOf(nc, superClass)) { + return true; + } + } + return false; + } + + // tests simulation condition 2 (SC2) + public boolean checkSC2(ELDescriptionNode node1, ELDescriptionNode node2) { + List<ELDescriptionEdge> edges1 = node1.getEdges(); + List<ELDescriptionEdge> edges2 = node2.getEdges(); + + for(ELDescriptionEdge edge : edges1) { + // try to find an edge satisfying SC2 in the set + if(!checkSC2Edge(edge, edges2)) { + return false; + } + } + + return true; + } + + // check whether edges contains an element satisfying SC2 + private boolean checkSC2Edge(ELDescriptionEdge edge, List<ELDescriptionEdge> edges) { + ObjectProperty op1 = edge.getLabel(); + ELDescriptionNode node1 = edge.getTree(); + + for(ELDescriptionEdge edge2 : edges) { + ObjectProperty op2 = edge2.getLabel(); + // we first check the condition on the properties + if(roleHierarchy.isSubpropertyOf(op1, op2)) { + // check condition on simulations of referred nodes + ELDescriptionNode node2 = edge2.getTree(); + if(node1.in.contains(node2) || node2.in.contains(node1)) { + // we found a node satisfying the condition, so we can return + return true; + } + } + } + + // none of the edges in the set satisfies the 2nd simulation criterion + // wrt. the first edge + return false; + } + + // adds (node1,node2) to simulation, takes care of all helper sets + public void extendSimulation(ELDescriptionNode node1, ELDescriptionNode node2) { + node1.out.add(node2); + node1.outSC1.add(node2); + node1.outSC2.add(node2); + node2.in.add(node1); + node2.inSC1.add(node1); + node2.inSC2.add(node1); + } + + // removes (node1,node2) from simulation, takes care of all helper sets + public void shrinkSimulation(ELDescriptionNode node1, ELDescriptionNode node2) { + node1.out.remove(node2); + node1.outSC1.remove(node2); + node1.outSC2.remove(node2); + node2.in.remove(node1); + node2.inSC1.remove(node1); + node2.inSC2.remove(node1); + } + @Override public ELDescriptionTree clone() { // create a new reference tree Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown.java 2008-10-23 07:41:02 UTC (rev 1414) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown.java 2008-10-23 08:43:03 UTC (rev 1415) @@ -259,9 +259,9 @@ // clone operation ELDescriptionTree clonedTree = tree.clone(); // find cloned edge and replace its label - ELDescriptionEdge clonedEdge = clonedTree.getNode(position).getEdges().get(edgeNumber); - clonedEdge.setLabel(op2); - // TODO simulation update + clonedTree.getNode(position).refineEdge(edgeNumber, op2); +// ELDescriptionEdge clonedEdge = clonedTree.getNode(position).getEdges().get(edgeNumber); +// clonedEdge.setLabel(op2); refinements.add(clonedTree); } Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2008-10-23 07:41:02 UTC (rev 1414) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2008-10-23 08:43:03 UTC (rev 1415) @@ -34,6 +34,7 @@ import org.dllearner.parser.ParseException; import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.refinementoperators.ELDown; +import org.dllearner.utilities.Helper; import org.dllearner.utilities.owl.ConceptComparator; import org.dllearner.utilities.owl.ConceptTransformation; import org.junit.Test; @@ -75,6 +76,7 @@ // input description Description input = KBParser.parseConcept("(human AND EXISTS has.animal)"); + System.out.println("refining: " + input); // create reasoner KBFile source = new KBFile(kb); @@ -114,14 +116,21 @@ } // perform refinement and compare solutions + long startTime = System.nanoTime(); Set<Description> refinements = operator.refine(input); + long runTime = System.nanoTime() - startTime; + System.out.println("Refinement step took " + Helper.prettyPrintNanoSeconds(runTime, true, true) + "."); + startTime = System.nanoTime(); + refinements = operator.refine(input); + runTime = System.nanoTime() - startTime; + System.out.println("Identical 2nd refinement step took " + Helper.prettyPrintNanoSeconds(runTime, true, true) + "."); // number of refinements has to be correct and each produced // refinement must be in the set of desired refinements // assertTrue(refinements.size() == desired.size()); for(Description refinement : refinements) { System.out.println(refinement); - assertTrue(desired.contains(refinement)); +// assertTrue(desired.contains(refinement)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-23 07:41:08
|
Revision: 1414 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1414&view=rev Author: sknappe Date: 2008-10-23 07:41:02 +0000 (Thu, 23 Oct 2008) Log Message: ----------- no learning, if there is no change in examples Modified Paths: -------------- trunk/src/dbpedia-navigator/ajax_get_article.php trunk/src/dbpedia-navigator/js/ajax.js Modified: trunk/src/dbpedia-navigator/ajax_get_article.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_article.php 2008-10-23 07:30:04 UTC (rev 1413) +++ trunk/src/dbpedia-navigator/ajax_get_article.php 2008-10-23 07:41:02 UTC (rev 1414) @@ -362,19 +362,24 @@ $_SESSION['nextArticle']++; //Add Positives to Session + $noChange="false"; if (!isset($_SESSION['positive'])){ $array=array($uri => $artTitle); $_SESSION['positive']=$array; } else{ $array=$_SESSION['positive']; - $array[$uri]=$artTitle; - if (count($array)>10){ - foreach ($array as $key=>$value){ - unset($array[$key]); - break; + if (!isset($array[$uri])){ + $array[$uri]=$artTitle; + if (count($array)>10){ + foreach ($array as $key=>$value){ + unset($array[$key]); + break; + } } } + else + $noChange="true"; $_SESSION['positive']=$array; } @@ -393,19 +398,24 @@ $uri=$_SESSION['articles'][$fromCache]['uri']; //Add Positives to Session + $noChange="false"; if (!isset($_SESSION['positive'])){ $array=array($uri => $artTitle); $_SESSION['positive']=$array; } else{ $array=$_SESSION['positive']; - $array[$uri]=$artTitle; - if (count($array)>10){ - foreach ($array as $key=>$value){ - unset($array[$key]); - break; + if (!isset($array[$uri])){ + $array[$uri]=$artTitle; + if (count($array)>10){ + foreach ($array as $key=>$value){ + unset($array[$key]); + break; + } } } + else + $noChange="true"; $_SESSION['positive']=$array; } } @@ -431,6 +441,8 @@ print '$$$'; print $interests[1]; print '$$$'; + print $noChange; + print '$$$'; print $lat; print '$$$'; print $long; Modified: trunk/src/dbpedia-navigator/js/ajax.js =================================================================== --- trunk/src/dbpedia-navigator/js/ajax.js 2008-10-23 07:30:04 UTC (rev 1413) +++ trunk/src/dbpedia-navigator/js/ajax.js 2008-10-23 07:41:02 UTC (rev 1414) @@ -59,10 +59,10 @@ document.getElementById('lastarticles').innerHTML=response[2]; document.getElementById('Positives').innerHTML=response[3]; document.getElementById('Negatives').innerHTML=response[4]; - if (response[5].length>0&&response[6].length>0) - loadGoogleMap(response[5],response[6],''+response[1]); + if (response[6].length>0&&response[7].length>0) + loadGoogleMap(response[6],response[7],''+response[1]); document.getElementById('LastArticlesBox').style.display='block'; - learnConcept(); + if (response[5]=="false") learnConcept(); }else setTimeout("search_it('label='+document.getElementById('label').value+'&number=10')",2000); generateURL(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-23 07:30:10
|
Revision: 1413 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1413&view=rev Author: sknappe Date: 2008-10-23 07:30:04 +0000 (Thu, 23 Oct 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java 2008-10-23 07:29:44 UTC (rev 1412) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java 2008-10-23 07:30:04 UTC (rev 1413) @@ -272,7 +272,7 @@ l=l.replaceAll("Cities", "City"); l=l.replaceAll("Players", "Player"); - l=l.replaceAll("([^-0\040])([A-Z])([^A-Z])", "$1 $2$3"); + l=l.replaceAll("([^-\040])([A-Z])([^A-Z])", "$1 $2$3"); if (l.toLowerCase().startsWith("a")||l.toLowerCase().startsWith("e")||l.toLowerCase().startsWith("i")||l.toLowerCase().startsWith("o")||l.toLowerCase().startsWith("u")) query+="an "+l; else query+="a "+l; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-23 07:29:53
|
Revision: 1412 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1412&view=rev Author: sknappe Date: 2008-10-23 07:29:44 +0000 (Thu, 23 Oct 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dbpedia-navigator/helper_functions.php Modified: trunk/src/dbpedia-navigator/helper_functions.php =================================================================== --- trunk/src/dbpedia-navigator/helper_functions.php 2008-10-23 07:20:51 UTC (rev 1411) +++ trunk/src/dbpedia-navigator/helper_functions.php 2008-10-23 07:29:44 UTC (rev 1412) @@ -9,7 +9,7 @@ $final=''; $offset=0; - preg_match_all("/[^-0\040]([A-Z])[^A-Z]/",$res,$treffer,PREG_OFFSET_CAPTURE); + preg_match_all("/[^-\040]([A-Z])[^A-Z]/",$res,$treffer,PREG_OFFSET_CAPTURE); foreach ($treffer[1] as $treff){ if ($res[$treff[1]-1]!=' '&&$res[$treff[1]-1]!='-'&&$treff[1]!=0){ $final.=substr($res,$offset,$treff[1]-$offset).' '; @@ -278,7 +278,7 @@ $label=str_replace('_',' ',substr($element['value'],28)); if (strlen($label)>60) $label=substr($label,0,60).'...'; if ($number>1) $table.='<li'.$display.'>'; - $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');return false;">'.urldecode($label).'</a>'; + $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');">'.urldecode($label).'</a>'; if ($number>1) $table.='</li>'; } else{ @@ -317,7 +317,7 @@ $label=str_replace('_',' ',substr($element['value'],28)); if (strlen($label)>60) $label=substr($label,0,60).'...'; if ($number>1) $table.='<li'.$display.'>'; - $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');return false;">'.urldecode($label).'</a>'; + $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');">'.urldecode($label).'</a>'; if ($number>1) $table.='</li>'; } else{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-23 07:20:56
|
Revision: 1411 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1411&view=rev Author: sknappe Date: 2008-10-23 07:20:51 +0000 (Thu, 23 Oct 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dbpedia-navigator/helper_functions.php Modified: trunk/src/dbpedia-navigator/helper_functions.php =================================================================== --- trunk/src/dbpedia-navigator/helper_functions.php 2008-10-23 07:20:30 UTC (rev 1410) +++ trunk/src/dbpedia-navigator/helper_functions.php 2008-10-23 07:20:51 UTC (rev 1411) @@ -21,8 +21,8 @@ $res=$final; //replacements - $res=str_replace('cities','City',$res); $res=str_replace('Cities','City',$res); + $res=str_replace('Players','Player',$res); return $res; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-23 07:20:36
|
Revision: 1410 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1410&view=rev Author: sknappe Date: 2008-10-23 07:20:30 +0000 (Thu, 23 Oct 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java 2008-10-23 07:11:53 UTC (rev 1409) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/NaturalLanguageDescriptionConvertVisitor.java 2008-10-23 07:20:30 UTC (rev 1410) @@ -269,8 +269,8 @@ if (l.length()+5<l2.length()&&!l2.matches(".*[0-9]")) l=l2; //replacements - l=l.replaceAll("cities", "City"); l=l.replaceAll("Cities", "City"); + l=l.replaceAll("Players", "Player"); l=l.replaceAll("([^-0\040])([A-Z])([^A-Z])", "$1 $2$3"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-10-23 07:11:58
|
Revision: 1409 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1409&view=rev Author: sknappe Date: 2008-10-23 07:11:53 +0000 (Thu, 23 Oct 2008) Log Message: ----------- Bugfix Modified Paths: -------------- trunk/src/dbpedia-navigator/helper_functions.php Modified: trunk/src/dbpedia-navigator/helper_functions.php =================================================================== --- trunk/src/dbpedia-navigator/helper_functions.php 2008-10-23 07:11:01 UTC (rev 1408) +++ trunk/src/dbpedia-navigator/helper_functions.php 2008-10-23 07:11:53 UTC (rev 1409) @@ -9,7 +9,7 @@ $final=''; $offset=0; - preg_match_all("/[^-0\040A-Z]([A-Z])/",$res,$treffer,PREG_OFFSET_CAPTURE); + preg_match_all("/[^-0\040]([A-Z])[^A-Z]/",$res,$treffer,PREG_OFFSET_CAPTURE); foreach ($treffer[1] as $treff){ if ($res[$treff[1]-1]!=' '&&$res[$treff[1]-1]!='-'&&$treff[1]!=0){ $final.=substr($res,$offset,$treff[1]-$offset).' '; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |