From: <ku...@us...> - 2008-05-14 14:26:40
|
Revision: 840 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=840&view=rev Author: kurzum Date: 2008-05-14 07:26:34 -0700 (Wed, 14 May 2008) Log Message: ----------- quick hack Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java trunk/src/dl-learner/org/dllearner/kb/sparql/datastructure/InstanceNode.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-14 12:15:26 UTC (rev 839) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-14 14:26:34 UTC (rev 840) @@ -1067,9 +1067,10 @@ nrOfSolutions=candidatesStable.size(); int i=0; for(ExampleBasedNode n : candidatesStable.descendingSet()) { + if (n.getAccuracy(nrOfPositiveExamples, nrOfNegativeExamples)<1)break; logger.trace("best: "+n.getShortDescription(nrOfPositiveExamples, nrOfNegativeExamples, baseURI)); if(i==nrOfSolutions) - return ; + break ; i++; } Modified: trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-14 12:15:26 UTC (rev 839) +++ trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java 2008-05-14 14:26:34 UTC (rev 840) @@ -74,7 +74,9 @@ for(Description c : allowedConceptsInSubsumptionHierarchy) { // schauen, ob es mehrere allgemeinere Nachbarn gibt SortedSet<Description> moreGeneral = subsumptionHierarchyUp.get(c); - if(moreGeneral != null) { + //RBC + if(moreGeneral != null && moreGeneral.size()>0) { + System.out.println(moreGeneral); Description chosenParent = moreGeneral.first(); hierarchyDownNew.get(chosenParent).add(c); } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/datastructure/InstanceNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/datastructure/InstanceNode.java 2008-05-14 12:15:26 UTC (rev 839) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/datastructure/InstanceNode.java 2008-05-14 14:26:34 UTC (rev 840) @@ -60,6 +60,9 @@ Iterator<StringTuple> it = s.iterator(); while (it.hasNext()) { StringTuple t = (StringTuple) it.next(); + //RBC + if(!t.b.startsWith("http:"))continue; + // basically : if p is rdf:type then o is a class // else it is an instance try { Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java 2008-05-14 12:15:26 UTC (rev 839) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java 2008-05-14 14:26:34 UTC (rev 840) @@ -1,6 +1,7 @@ package org.dllearner.scripts; import java.net.URLEncoder; +import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -16,6 +17,7 @@ import org.dllearner.utilities.AutomaticExampleFinderSPARQL; import org.dllearner.utilities.ConfWriter; import org.dllearner.utilities.JenaResultSetConvenience; +import org.dllearner.utilities.LearnSparql; import org.dllearner.utilities.SetManipulation; import org.dllearner.utilities.SimpleClock; @@ -152,7 +154,8 @@ for (String string : tmpSet) { concepts.add("\""+string+"\""); } - + concepts.remove(concepts.first()); + concepts.remove(concepts.first()); //concepts.add("(\"http://dbpedia.org/class/yago/HeadOfState110164747\" AND (\"http://dbpedia.org/class/yago/Negotiator110351874\" AND \"http://dbpedia.org/class/yago/Representative110522035\"))"); //concepts.add("\"http://dbpedia.org/class/yago/Person100007846\""); //concepts.add("\"http://dbpedia.org/class/yago/FieldMarshal110086821\""); @@ -167,37 +170,46 @@ //HashMap<String, String> result2 = new HashMap<String, String>(); //System.out.println(concepts.first()); //logger.setLevel(Level.TRACE); - AutomaticExampleFinderSPARQL ae= new AutomaticExampleFinderSPARQL( se); - //System.out.println(new JenaResultSetConvenience(ae.queryConcept(concepts.first(), 0)).getStringListForVariable("?subject") );; - //System.out.println(new JenaResultSetConvenience(ae.queryConcept(concepts.first(), 0)).getStringListForVariable("?subject").size() );; - //ae.getSubClasses(concepts.first()); - //System.exit(0); - - ae.initDBpedia(concepts.first(), useRelated, useSuperClasses,useParallelClasses, poslimit, neglimit); + int i=0; + for (String oneConcept : concepts) { + if(i>=2)break; + i++; + AutomaticExampleFinderSPARQL ae= new AutomaticExampleFinderSPARQL( se); + useRelated = false; + useSuperClasses=true; + useParallelClasses=false; + poslimit=2; + neglimit=2; + ae.initDBpedia(concepts.first(), useRelated, useSuperClasses,useParallelClasses, poslimit, neglimit); + posExamples = ae.getPosExamples(); + negExamples = ae.getNegExamples(); + + // System.out.println(posExamples); + // System.out.println(negExamples); + + String tmp = concepts.first().replace("http://dbpedia.org/resource/Category:", "").replace("\"",""); + tmp = tmp.replace("http://dbpedia.org/class/yago/", ""); + tmp = tmp.replace("http://dbpedia.org/property/", ""); + String confname = ""; + try{ + confname = URLEncoder.encode(tmp, "UTF-8")+".conf"; + }catch (Exception e) {e.printStackTrace();} + // + //ConfWriter cf=new ConfWriter(); + //cf.addToStats("relearned concept: "+concepts.first()); + System.out.println(confname); + LearnSparql ls = new LearnSparql(); + TreeSet<String> igno = new TreeSet<String>(); + System.out.println(oneConcept); + //igno.add(oneConcept.replaceAll("\"", "")); + ls.learnDBpedia(posExamples, negExamples, "http://dbpedia.openlinksw.com:8890/sparql",igno,1); + System.out.println("AAAAAAAA"); + //System.exit(0); + //"relearned concept: "; + //cf.writeSPARQL(confname, posExamples, negExamples, url, new TreeSet<String>(),standardSettings,algorithm); + // - posExamples = ae.getPosExamples(); - negExamples = ae.getNegExamples(); - - System.out.println(posExamples); - System.out.println(negExamples); - //System.exit(0); - String tmp = concepts.first().replace("http://dbpedia.org/resource/Category:", "").replace("\"",""); - tmp = tmp.replace("http://dbpedia.org/class/yago/", ""); - tmp = tmp.replace("http://dbpedia.org/property/", ""); - String confname = ""; - try{ - confname = URLEncoder.encode(tmp, "UTF-8")+".conf"; - }catch (Exception e) {e.printStackTrace();} - // - ConfWriter cf=new ConfWriter(); - cf.addToStats("relearned concept: "+concepts.first()); - - //System.exit(0); - //"relearned concept: "; - cf.writeSPARQL(confname, posExamples, negExamples, url, new TreeSet<String>(),standardSettings,algorithm); - //new LearnSparql().learn(posExamples, negExamples, "http://dbpedia.openlinksw.com:8890/sparql", new TreeSet<String>()); - - + } } @@ -250,7 +262,8 @@ public static SortedSet<String> selectDBpediaConcepts(int number){ String query = "SELECT DISTINCT ?concept WHERE { \n" + - "[] a ?concept }\n"; + "[] a ?concept .FILTER (regex(str(?concept),'yago'))" + + " \n} LIMIT "+number+" \n"; String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); Modified: trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-14 12:15:26 UTC (rev 839) +++ trunk/src/dl-learner/org/dllearner/utilities/LearnSparql.java 2008-05-14 14:26:34 UTC (rev 840) @@ -21,8 +21,8 @@ - public void learn(SortedSet<String> posExamples,SortedSet<String> negExamples, - String uri, SortedSet<String> ignoredConcepts){ + public void learnDBpedia(SortedSet<String> posExamples,SortedSet<String> negExamples, + String uri, SortedSet<String> ignoredConcepts, int recursiondepth){ ComponentManager cm = ComponentManager.getInstance(); @@ -40,9 +40,9 @@ instances.addAll(negExamples); cm.applyConfigEntry(ks, "instances",instances); cm.applyConfigEntry(ks, "url",uri); - cm.applyConfigEntry(ks, "recursionDepth",1); - cm.applyConfigEntry(ks, "predefinedFilter",1); - cm.applyConfigEntry(ks, "predefinedEndpoint",1); + cm.applyConfigEntry(ks, "recursionDepth",recursiondepth); + cm.applyConfigEntry(ks, "predefinedFilter","YAGOSKOS"); + cm.applyConfigEntry(ks, "predefinedEndpoint","DBPEDIA"); //cm.applyConfigEntry(ks, "format","KB"); ks.init(); @@ -70,11 +70,12 @@ cm.applyConfigEntry(la,"useCardinalityRestrictions",false); cm.applyConfigEntry(la,"useNegation",false); cm.applyConfigEntry(la,"minExecutionTimeInSeconds",0); - cm.applyConfigEntry(la,"maxExecutionTimeInSeconds",900); - cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",999999); + cm.applyConfigEntry(la,"maxExecutionTimeInSeconds",10); + //cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",999999); cm.applyConfigEntry(la,"logLevel","TRACE"); //cm.applyConfigEntry(la,"quiet",false); + //System.out.println(ignoredConcepts.first());; if(ignoredConcepts.size()>0) cm.applyConfigEntry(la,"ignoredConcepts",ignoredConcepts); la.init(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |