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: <jen...@us...> - 2008-09-27 07:48:22
|
Revision: 1283 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1283&view=rev Author: jenslehmann Date: 2008-09-27 07:48:14 +0000 (Sat, 27 Sep 2008) Log Message: ----------- - working hasValue support (frequency threshold currently at 3) - use refexamples.useHasValueConstructor = true to turn on hasValue support (turned off by default) - provided examples in semantic_bible folder Modified Paths: -------------- trunk/examples/semantic_bible/hasvalue_example.conf trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java Added Paths: ----------- trunk/examples/semantic_bible/hasvalue_simple.conf trunk/examples/semantic_bible/hasvalue_simple.kb Modified: trunk/examples/semantic_bible/hasvalue_example.conf =================================================================== --- trunk/examples/semantic_bible/hasvalue_example.conf 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/examples/semantic_bible/hasvalue_example.conf 2008-09-27 07:48:14 UTC (rev 1283) @@ -1,11 +1,10 @@ /** - * It should learn ethnicity hasValue Jewish, but does not work for some reason. + * Learns ethnicity hasValue Jewish (+ potentially something more e.g. Man AND ethnicity hasValue Jewish). */ -import("../NTNcombined.owl"); +import("NTNcombined.owl"); -// reasoner = owlAPIReasoner; -owlAPIReasoner.reasonerType = pellet; +refexamples.useHasValueConstructor = true; +"http://semanticbible.org/ns/2006/NTNames#Hezron" +"http://semanticbible.org/ns/2006/NTNames#Jehoshaphat" Added: trunk/examples/semantic_bible/hasvalue_simple.conf =================================================================== --- trunk/examples/semantic_bible/hasvalue_simple.conf (rev 0) +++ trunk/examples/semantic_bible/hasvalue_simple.conf 2008-09-27 07:48:14 UTC (rev 1283) @@ -0,0 +1,11 @@ +import("hasvalue_simple.kb"); + +reasoner = owlAPIReasoner; +refexamples.useHasValueConstructor = true; + ++a ++b ++c +-e +-f + Added: trunk/examples/semantic_bible/hasvalue_simple.kb =================================================================== --- trunk/examples/semantic_bible/hasvalue_simple.kb (rev 0) +++ trunk/examples/semantic_bible/hasvalue_simple.kb 2008-09-27 07:48:14 UTC (rev 1283) @@ -0,0 +1,9 @@ +knows(a,d). +knows(b,d). +knows(c,d). +knows(e,a). +knows(f,b). + +// TODO bug: apparently there are problems if no class is present in the background ontology, +// so we need to add one +person(a). Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -115,6 +115,7 @@ private boolean improveSubsumptionHierarchy = true; private boolean useAllConstructor = CommonConfigOptions.useAllConstructorDefault; private boolean useExistsConstructor = CommonConfigOptions.useExistsConstructorDefault; + private boolean useHasValueConstructor = CommonConfigOptions.useHasValueConstructorDefault; private boolean useCardinalityRestrictions = CommonConfigOptions.useCardinalityRestrictionsDefault; private boolean useNegation = CommonConfigOptions.useNegationDefault; private boolean useBooleanDatatypes = CommonConfigOptions.useBooleanDatatypesDefault; @@ -190,6 +191,7 @@ options.add(CommonConfigOptions.ignoredRoles()); options.add(CommonConfigOptions.useAllConstructor()); options.add(CommonConfigOptions.useExistsConstructor()); + options.add(CommonConfigOptions.useHasValueConstructor()); options.add(CommonConfigOptions.useCardinalityRestrictions()); options.add(CommonConfigOptions.useNegation()); options.add(CommonConfigOptions.useBooleanDatatypes()); @@ -254,6 +256,8 @@ useAllConstructor = (Boolean) entry.getValue(); } else if(name.equals("useExistsConstructor")) { useExistsConstructor = (Boolean) entry.getValue(); + } else if(name.equals("useHasValueConstructor")) { + useHasValueConstructor = (Boolean) entry.getValue(); } else if(name.equals("useCardinalityRestrictions")) { useCardinalityRestrictions = (Boolean) entry.getValue(); } else if(name.equals("useNegation")) { @@ -365,6 +369,7 @@ applyExistsFilter, useAllConstructor, useExistsConstructor, + useHasValueConstructor, useCardinalityRestrictions, useNegation, useBooleanDatatypes, Modified: trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -40,6 +40,7 @@ //public static boolean improveSubsumptionHierarchyDefault = true; public static boolean useAllConstructorDefault = true; public static boolean useExistsConstructorDefault = true; + public static boolean useHasValueConstructorDefault = true; public static boolean useCardinalityRestrictionsDefault = true; public static boolean useNegationDefault = true; public static boolean useBooleanDatatypesDefault = true; @@ -101,6 +102,10 @@ return new BooleanConfigOption("useExistsConstructor", "specifies whether the existential concept constructor is used in the learning algorithm",useExistsConstructorDefault); } + public static BooleanConfigOption useHasValueConstructor() { + return new BooleanConfigOption("useHasValueConstructor", "specifies whether the hasValue constructor is used in the learning algorithm",useHasValueConstructorDefault); + } + public static BooleanConfigOption useCardinalityRestrictions() { return new BooleanConfigOption("useCardinalityRestrictions", "specifies whether CardinalityRestrictions is used in the learning algorithm",useCardinalityRestrictionsDefault); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -23,7 +23,7 @@ /** * Restricts the value of an object property to a single individual - * (corresponds to owl:hasValue). + * (corresponds to owl:hasValue) * * @author Jens Lehmann * @@ -42,8 +42,7 @@ */ @Override public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { - // TODO Auto-generated method stub - return null; + return restrictedPropertyExpression.toString(baseURI, prefixes) + " value " + value.toString(baseURI, prefixes); } /* (non-Javadoc) @@ -51,7 +50,6 @@ */ @Override public int getArity() { - // TODO Auto-generated method stub return 0; } @@ -59,21 +57,18 @@ * @see org.dllearner.core.owl.KBElement#getLength() */ public int getLength() { - // TODO Auto-generated method stub - return 0; + return 3; } /* (non-Javadoc) * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - // TODO Auto-generated method stub - return null; + return restrictedPropertyExpression.toString(baseURI, prefixes) + " hasValue " + value.toString(baseURI, prefixes); } public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) { - // TODO Auto-generated method stub - return null; + return restrictedPropertyExpression.toKBSyntaxString(baseURI, prefixes) + " hasValue " + value.toKBSyntaxString(baseURI, prefixes); } public Individual getIndividual() { Modified: trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -27,7 +27,7 @@ */ public abstract class Restriction extends Description { - PropertyExpression restrictedPropertyExpression; + protected PropertyExpression restrictedPropertyExpression; public Restriction(PropertyExpression restrictedPropertyExpression) { this.restrictedPropertyExpression = restrictedPropertyExpression; Modified: trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -27,7 +27,7 @@ */ public abstract class ValueRestriction extends Restriction { - KBElement value; + protected KBElement value; public ValueRestriction(PropertyExpression propertyExpression, KBElement value) { super(propertyExpression); Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -253,7 +253,7 @@ Logger rootLogger = Logger.getRootLogger(); rootLogger.removeAllAppenders(); rootLogger.addAppender(consoleAppender); - rootLogger.setLevel(Level.TRACE); + rootLogger.setLevel(Level.DEBUG); File file = null; if (args.length > 0) Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-09-26 21:16:59 UTC (rev 1282) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-09-27 07:48:14 UTC (rev 1283) @@ -150,8 +150,6 @@ private Map<DatatypeProperty,List<Double>> splits = new TreeMap<DatatypeProperty,List<Double>>(); private int maxNrOfSplits = 10; - // experimental support for hasValue - private boolean useHasValue = false; // data structure for a simple frequent pattern matching preprocessing phase private int frequencyThreshold = 3; private Map<ObjectProperty, Map<Individual, Integer>> valueFrequency = new HashMap<ObjectProperty, Map<Individual, Integer>>(); @@ -166,6 +164,7 @@ private boolean applyExistsFilter = true; private boolean useAllConstructor = true; private boolean useExistsConstructor = true; + private boolean useHasValueConstructor = false; private boolean useCardinalityRestrictions = true; private boolean useNegation = true; private boolean useBooleanDatatypes = true; @@ -181,16 +180,17 @@ // private Map<NamedClass,Map<NamedClass,Boolean>> notABMeaningful = new TreeMap<NamedClass,Map<NamedClass,Boolean>>(); public RhoDRDown(ReasoningService reasoningService) { - this(reasoningService, true, true, true, true, true, true, true, true, null); + this(reasoningService, true, true, true, true, true, true, true, true, true, null); } public RhoDRDown(ReasoningService reasoningService, boolean applyAllFilter, boolean applyExistsFilter, boolean useAllConstructor, - boolean useExistsConstructor,boolean useCardinalityRestrictions,boolean useNegation, boolean useBooleanDatatypes, boolean useDoubleDatatypes, NamedClass startClass) { + boolean useExistsConstructor, boolean useHasValueConstructor, boolean useCardinalityRestrictions,boolean useNegation, boolean useBooleanDatatypes, boolean useDoubleDatatypes, NamedClass startClass) { this.rs = reasoningService; this.applyAllFilter = applyAllFilter; this.applyExistsFilter = applyExistsFilter; this.useAllConstructor = useAllConstructor; this.useExistsConstructor = useExistsConstructor; + this.useHasValueConstructor = useHasValueConstructor; this.useCardinalityRestrictions = useCardinalityRestrictions; this.useNegation = useNegation; this.useBooleanDatatypes = useBooleanDatatypes; @@ -204,7 +204,7 @@ opDomains.put(op, rs.getDomain(op)); opRanges.put(op, rs.getRange(op)); - if(useHasValue) { + if(useHasValueConstructor) { // init Map<Individual, Integer> opMap = new TreeMap<Individual, Integer>(); valueFrequency.put(op, opMap); @@ -229,7 +229,7 @@ // after threshold is reached) Set<Individual> frequentInds = new TreeSet<Individual>(); for(Individual i : opMap.keySet()) { - if(opMap.get(i) > frequencyThreshold) { + if(opMap.get(i) >= frequencyThreshold) { frequentInds.add(i); } } @@ -455,12 +455,12 @@ } // rule 4: EXISTS r.TOP => EXISTS r.{value} - if(useHasValue && description.getChild(0) instanceof Thing) { + if(useHasValueConstructor && description.getChild(0) instanceof Thing) { // watch out for frequent patterns Set<Individual> frequentInds = frequentValues.get(role); if(frequentInds != null) { for(Individual ind : frequentInds) { - ObjectValueRestriction ovr = new ObjectValueRestriction(ar, ind); + ObjectValueRestriction ovr = new ObjectValueRestriction((ObjectProperty)role, ind); refinements.add(ovr); } } @@ -661,8 +661,11 @@ boolean maxDoubleOccurence = false; // rule 2: min restrictions at most once boolean minDoubleOccurence = false; - // rule 3: no double boolean datatypes + // rule 3: no double occurences of boolean datatypes TreeSet<DatatypeProperty> occuredDP = new TreeSet<DatatypeProperty>(); + // rule 4: no double occurences of hasValue restrictions + TreeSet<ObjectProperty> occuredVR = new TreeSet<ObjectProperty>(); + for(Description child : intersection.getChildren()) { if(child instanceof DatatypeSomeRestriction) { DataRange dr = ((DatatypeSomeRestriction)child).getDataRange(); @@ -683,6 +686,10 @@ // return false if the boolean property exists already if(!occuredDP.add(dp)) return false; + } else if(child instanceof ObjectValueRestriction) { + ObjectProperty op = (ObjectProperty) ((ObjectValueRestriction)child).getRestrictedPropertyExpression(); + if(!occuredVR.add(op)) + return false; } // System.out.println(child.getClass()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-26 21:17:08
|
Revision: 1282 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1282&view=rev Author: kurzum Date: 2008-09-26 21:16:59 +0000 (Fri, 26 Sep 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java Modified: trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java 2008-09-26 21:13:44 UTC (rev 1281) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java 2008-09-26 21:16:59 UTC (rev 1282) @@ -182,11 +182,12 @@ String content = ""; dir = StringFormatter.checkIfDirEndsOnSlashAndRemove(dir); Files.mkdir(dir); + String div = (System.currentTimeMillis() % 10000) + ""; try{ int i=0; for(TableColumn c:t.getColumns()){ String header = URLEncoder.encode(c.getHeader(),"UTF-8"); - String columnFileName = dir+File.separator+t.getTableName()+(i++)+header+column; + String columnFileName = dir+File.separator+t.getTableName()+(i++)+header+div+column; c.serialize(new File(columnFileName)); //Files.writeObjectToFile(c, new File(filename)); content += columnFileName+System.getProperty("line.separator"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-26 21:13:55
|
Revision: 1281 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1281&view=rev Author: kurzum Date: 2008-09-26 21:13:44 +0000 (Fri, 26 Sep 2008) Log Message: ----------- schedule experiments Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 21:11:00 UTC (rev 1280) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 21:13:44 UTC (rev 1281) @@ -251,7 +251,7 @@ EvaluatedDescription onOnto = reEvaluateDescription( bestDescription.getDescription(), retrieved, posEx, negEx); - logger.warn(onOnto.getDescription().toManchesterSyntaxString(null, null)); + logger.warn(onOnto.getDescription().toKBSyntaxString()); logger.warn(onOnto.getAccuracy()); accOnOnto.addNumber(onOnto.getAccuracy()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-26 21:11:06
|
Revision: 1280 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1280&view=rev Author: kurzum Date: 2008-09-26 21:11:00 +0000 (Fri, 26 Sep 2008) Log Message: ----------- schedule experiments Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 20:28:57 UTC (rev 1279) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 21:11:00 UTC (rev 1280) @@ -159,6 +159,10 @@ /*finished experiments: * SPARQL_10s * SPARQL_1000_CONCEPT_TESTS + * running: + * NORMAL_1000_CONCEPT_TESTS + * SPARQL_10000_CONCEPT_TESTS + * NORMAL_10000_CONCEPT_TESTS * * */ @@ -167,13 +171,16 @@ //if(exp.equals(Experiments.NORMAL_10000_CONCEPT_TESTS))continue; //if(exp.equals(Experiments.SPARQL_100s))continue; //if(exp.toString().contains("SPARQL"))continue; - if(exp.equals(Experiments.NORMAL_1000_CONCEPT_TESTS))conductExperiment(exp); - if(exp.equals(Experiments.SPARQL_10000_CONCEPT_TESTS))conductExperiment(exp); - if(exp.equals(Experiments.NORMAL_10000_CONCEPT_TESTS))conductExperiment(exp); - //System.exit(0); + if(exp.equals(Experiments.NORMAL_10s))conductExperiment(exp); + if(exp.equals(Experiments.SPARQL_100s))conductExperiment(exp); + if(exp.equals(Experiments.NORMAL_100s))conductExperiment(exp); + //~ if(exp.equals(Experiments.NORMAL_1000_CONCEPT_TESTS))conductExperiment(exp); + //~ if(exp.equals(Experiments.SPARQL_10000_CONCEPT_TESTS))conductExperiment(exp); + //~ if(exp.equals(Experiments.NORMAL_10000_CONCEPT_TESTS))conductExperiment(exp); + } } - //conductExperiment(0); + // write JaMON report in HTML file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-26 20:29:03
|
Revision: 1279 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1279&view=rev Author: kurzum Date: 2008-09-26 20:28:57 +0000 (Fri, 26 Sep 2008) Log Message: ----------- server commit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 20:24:32 UTC (rev 1278) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 20:28:57 UTC (rev 1279) @@ -156,13 +156,20 @@ }else{ + /*finished experiments: + * SPARQL_10s + * SPARQL_1000_CONCEPT_TESTS + * + * */ + for (Experiments exp : Experiments.values()) { //if(exp.equals(Experiments.SPARQL_10000_CONCEPT_TESTS))continue; //if(exp.equals(Experiments.NORMAL_10000_CONCEPT_TESTS))continue; //if(exp.equals(Experiments.SPARQL_100s))continue; //if(exp.toString().contains("SPARQL"))continue; - if(exp.equals(Experiments.SPARQL_10s))conductExperiment(exp); - if(exp.equals(Experiments.SPARQL_1000_CONCEPT_TESTS))conductExperiment(exp); + if(exp.equals(Experiments.NORMAL_1000_CONCEPT_TESTS))conductExperiment(exp); + if(exp.equals(Experiments.SPARQL_10000_CONCEPT_TESTS))conductExperiment(exp); + if(exp.equals(Experiments.NORMAL_10000_CONCEPT_TESTS))conductExperiment(exp); //System.exit(0); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-26 20:24:39
|
Revision: 1278 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1278&view=rev Author: kurzum Date: 2008-09-26 20:24:32 +0000 (Fri, 26 Sep 2008) Log Message: ----------- server commit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/NT2RDF.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java Modified: trunk/src/dl-learner/org/dllearner/scripts/NT2RDF.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/NT2RDF.java 2008-09-26 19:35:49 UTC (rev 1277) +++ trunk/src/dl-learner/org/dllearner/scripts/NT2RDF.java 2008-09-26 20:24:32 UTC (rev 1278) @@ -29,11 +29,12 @@ public static void main(String[] args) { - // String ontopath=args[0]; - String ontopath = "examples/semantic_bible/NTNcombined.nt"; + String ontopath=args[0]; + //String ontopath = "examples/semantic_bible/NTNcombined.nt"; // String ontopath = "examples/semantic_bible/test.nt"; convertNT2RDF(ontopath); + } /** Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 19:35:49 UTC (rev 1277) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 20:24:32 UTC (rev 1278) @@ -154,16 +154,17 @@ - } + }else{ - for (Experiments exp : Experiments.values()) { - //if(exp.equals(Experiments.SPARQL_10000_CONCEPT_TESTS))continue; - //if(exp.equals(Experiments.NORMAL_10000_CONCEPT_TESTS))continue; - //if(exp.equals(Experiments.SPARQL_100s))continue; - //if(exp.toString().contains("SPARQL"))continue; - if(exp.equals(Experiments.SPARQL_10s))conductExperiment(exp); - if(exp.equals(Experiments.SPARQL_1000_CONCEPT_TESTS))conductExperiment(exp); - //System.exit(0); + for (Experiments exp : Experiments.values()) { + //if(exp.equals(Experiments.SPARQL_10000_CONCEPT_TESTS))continue; + //if(exp.equals(Experiments.NORMAL_10000_CONCEPT_TESTS))continue; + //if(exp.equals(Experiments.SPARQL_100s))continue; + //if(exp.toString().contains("SPARQL"))continue; + if(exp.equals(Experiments.SPARQL_10s))conductExperiment(exp); + if(exp.equals(Experiments.SPARQL_1000_CONCEPT_TESTS))conductExperiment(exp); + //System.exit(0); + } } //conductExperiment(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-26 19:35:56
|
Revision: 1277 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1277&view=rev Author: kurzum Date: 2008-09-26 19:35:49 +0000 (Fri, 26 Sep 2008) Log Message: ----------- server commit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 19:30:02 UTC (rev 1276) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 19:35:49 UTC (rev 1277) @@ -175,7 +175,9 @@ //total.printAndSet("Finished"); logger.warn(total.getAndSet("Finished")); if(flawInExperiment){ - logger.error("There were exceptions"); + logger.error("There were exceptions, see log"); + }else{ + logger.warn("The experiment finished without any flaws"); } //logger.warn("Finished"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-26 19:30:16
|
Revision: 1276 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1276&view=rev Author: kurzum Date: 2008-09-26 19:30:02 +0000 (Fri, 26 Sep 2008) Log Message: ----------- serverCommit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-26 18:39:03 UTC (rev 1275) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-26 19:30:02 UTC (rev 1276) @@ -27,8 +27,6 @@ import java.util.LinkedList; import java.util.List; import java.util.TreeSet; -import java.util.concurrent.Callable; -import java.util.concurrent.FutureTask; import org.apache.log4j.Logger; import org.dllearner.core.KnowledgeSource; @@ -76,15 +74,15 @@ public class SparqlKnowledgeSource extends KnowledgeSource { //RBC - private static final boolean debug = true; + private static final boolean debug = false; - private static final boolean threaded = debug && true ; + //private static final boolean threaded = debug && true ; // tupleaquisitor //private static final boolean debugUseImprovedTupleAquisitor = debug && false; // switches // sysex - private static final boolean debugExitAfterExtraction = debug && true; // switches + private static final boolean debugExitAfterExtraction = debug && false; // switches private SparqlKnowledgeSourceConfigurator configurator; @@ -261,17 +259,34 @@ // the actual extraction is started here Monitor extractionTime = JamonMonitorLogger.getTimeMonitor(SparqlKnowledgeSource.class, "total extraction time").start(); List<Node> seedNodes=new ArrayList<Node>(); - if(!threaded){ + + //if(!threaded){ seedNodes = m.extract(configurator.getInstances()); - }else{ + /*}else{ + int maxPoolSize = configurator.getInstances().size(); + ThreadPoolExecutor ex = new ThreadPoolExecutor(5,maxPoolSize,1,TimeUnit.SECONDS,new ArrayBlockingQueue<Runnable>(100)); + List<FutureTask<Node>> tasks = new ArrayList<FutureTask<Node>>(); + for (String uri : configurator.getInstances()) { - System.out.println("making future task"); - FutureTask<Node> f = new FutureTask<Node>(new ExtractOneInstance(m,uri)); - seedNodes.add(f.get()); - System.out.println("finished FutureTask "+seedNodes.size()); + + ExtractOneInstance e = new ExtractOneInstance(m,uri); + + FutureTask<Node> ft = new FutureTask<Node>(e); + ex.submit(ft); + tasks.add(ft); + //System.out.println(f.get()); + //seedNodes.add(f.get()); + //System.out.println("finished FutureTask "+seedNodes.size()); } - } + for(FutureTask<Node> ft : tasks){ + //System.out.println(ft.get()); + //System.out.println("aaa"); + seedNodes.add(ft.get()); + + } + }*/ extractionTime.stop(); + fragment = m.getOWLAPIOntologyForNodes(seedNodes, configurator.getSaveExtractedFragment()); @@ -302,7 +317,7 @@ return null; } - private class ExtractOneInstance extends Thread implements Callable{ + /*private class ExtractOneInstance implements Callable{ Manager m; Node n; String uri; @@ -313,15 +328,13 @@ this.uri = uri; } - @Override - public void run(){ - n = m.extractOneURI(uri); - } + public Node call(){ - return n; + System.out.println("funky"); + return m.extractOneURI(uri); } - } + }*/ /* * (non-Javadoc) Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 18:39:03 UTC (rev 1275) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 19:30:02 UTC (rev 1276) @@ -74,7 +74,7 @@ public class SemanticBibleComparison { private static boolean onJensMachine = false; - private static int nrOfFilesInExperiment = (onJensMachine)?1:1; + private static int nrOfFilesInExperiment = (onJensMachine)?1:200; private static ReasoningService reasoningService; @@ -161,7 +161,8 @@ //if(exp.equals(Experiments.NORMAL_10000_CONCEPT_TESTS))continue; //if(exp.equals(Experiments.SPARQL_100s))continue; //if(exp.toString().contains("SPARQL"))continue; - conductExperiment(exp); + if(exp.equals(Experiments.SPARQL_10s))conductExperiment(exp); + if(exp.equals(Experiments.SPARQL_1000_CONCEPT_TESTS))conductExperiment(exp); //System.exit(0); } //conductExperiment(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-26 18:39:06
|
Revision: 1275 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1275&view=rev Author: kurzum Date: 2008-09-26 18:39:03 +0000 (Fri, 26 Sep 2008) Log Message: ----------- server commit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-26 18:35:02 UTC (rev 1274) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-26 18:39:03 UTC (rev 1275) @@ -265,8 +265,10 @@ seedNodes = m.extract(configurator.getInstances()); }else{ for (String uri : configurator.getInstances()) { + System.out.println("making future task"); FutureTask<Node> f = new FutureTask<Node>(new ExtractOneInstance(m,uri)); seedNodes.add(f.get()); + System.out.println("finished FutureTask "+seedNodes.size()); } } extractionTime.stop(); Modified: trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java 2008-09-26 18:35:02 UTC (rev 1274) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java 2008-09-26 18:39:03 UTC (rev 1275) @@ -186,7 +186,7 @@ int i=0; for(TableColumn c:t.getColumns()){ String header = URLEncoder.encode(c.getHeader(),"UTF-8"); - String columnFileName = dir+File.separator+t.getTableName()+header+(i++)+column; + String columnFileName = dir+File.separator+t.getTableName()+(i++)+header+column; c.serialize(new File(columnFileName)); //Files.writeObjectToFile(c, new File(filename)); content += columnFileName+System.getProperty("line.separator"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-26 18:35:09
|
Revision: 1274 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1274&view=rev Author: kurzum Date: 2008-09-26 18:35:02 +0000 (Fri, 26 Sep 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java 2008-09-26 17:25:48 UTC (rev 1273) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java 2008-09-26 18:35:02 UTC (rev 1274) @@ -57,9 +57,9 @@ public Node extractOneURI(String uri) { - logger.info("Start extracting: "+uri); + //logger.info("Start extracting: "+uri); Node n = extractionAlgorithm.expandNode(uri, configuration.getTupelAquisitor()); - logger.info("Finished extracting: "+uri ); + //logger.info("Finished extracting: "+uri ); seedNodes.add(n); return n; } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-26 17:25:48 UTC (rev 1273) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-26 18:35:02 UTC (rev 1274) @@ -27,6 +27,8 @@ import java.util.LinkedList; import java.util.List; import java.util.TreeSet; +import java.util.concurrent.Callable; +import java.util.concurrent.FutureTask; import org.apache.log4j.Logger; import org.dllearner.core.KnowledgeSource; @@ -61,6 +63,7 @@ import org.dllearner.utilities.statistics.SimpleClock; import org.semanticweb.owl.model.OWLOntology; +import com.jamonapi.Monitor; import com.jamonapi.MonitorFactory; /** @@ -72,13 +75,16 @@ */ public class SparqlKnowledgeSource extends KnowledgeSource { + //RBC + private static final boolean debug = true; - private static final boolean debug = false; + private static final boolean threaded = debug && true ; + // tupleaquisitor //private static final boolean debugUseImprovedTupleAquisitor = debug && false; // switches // sysex - private static final boolean debugExitAfterExtraction = debug && false; // switches + private static final boolean debugExitAfterExtraction = debug && true; // switches private SparqlKnowledgeSourceConfigurator configurator; @@ -227,7 +233,7 @@ public void init() { logger.info("SparqlModul: Collecting Ontology"); SimpleClock totalTime = new SimpleClock(); - SimpleClock extractionTime = new SimpleClock(); + //SimpleClock extractionTime = new SimpleClock(); logger.trace(getURL()); logger.trace(getSparqlEndpoint()); @@ -253,14 +259,23 @@ try { // the actual extraction is started here - - extractionTime.setTime(); - List<Node> seedNodes = m.extract(configurator.getInstances()); + Monitor extractionTime = JamonMonitorLogger.getTimeMonitor(SparqlKnowledgeSource.class, "total extraction time").start(); + List<Node> seedNodes=new ArrayList<Node>(); + if(!threaded){ + seedNodes = m.extract(configurator.getInstances()); + }else{ + for (String uri : configurator.getInstances()) { + FutureTask<Node> f = new FutureTask<Node>(new ExtractOneInstance(m,uri)); + seedNodes.add(f.get()); + } + } + extractionTime.stop(); + fragment = m.getOWLAPIOntologyForNodes(seedNodes, configurator.getSaveExtractedFragment()); - extractionTime.printAndSet("extraction needed"); - logger.info("Finished collecting Fragment"); + logger.info("Finished collecting fragment. needed "+extractionTime.getLastValue()+" ms"); + ontologyFragmentURL = m.getPhysicalOntologyURL(); nrOfExtractedAxioms = configuration.getOwlAPIOntologyCollector().getNrOfExtractedAxioms(); @@ -280,6 +295,31 @@ System.exit(0); } } + + public List<Node> extractParallel(){ + return null; + } + + private class ExtractOneInstance extends Thread implements Callable{ + Manager m; + Node n; + String uri; + + private ExtractOneInstance(Manager m, String uri){ + super(); + this.m = m; + this.uri = uri; + } + + @Override + public void run(){ + n = m.extractOneURI(uri); + } + + public Node call(){ + return n; + } + } /* * (non-Javadoc) Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 17:25:48 UTC (rev 1273) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 18:35:02 UTC (rev 1274) @@ -73,6 +73,9 @@ public class SemanticBibleComparison { + private static boolean onJensMachine = false; + private static int nrOfFilesInExperiment = (onJensMachine)?1:1; + private static ReasoningService reasoningService; private static Logger logger = Logger.getRootLogger(); @@ -143,13 +146,22 @@ List<String> l = getFiles(); analyzeFiles(l); + if(onJensMachine){ + conductExperiment(Experiments.NORMAL_10s); + conductExperiment(Experiments.NORMAL_100s); + conductExperiment(Experiments.NORMAL_1000_CONCEPT_TESTS); + conductExperiment(Experiments.NORMAL_10000_CONCEPT_TESTS); + + + + } + for (Experiments exp : Experiments.values()) { //if(exp.equals(Experiments.SPARQL_10000_CONCEPT_TESTS))continue; //if(exp.equals(Experiments.NORMAL_10000_CONCEPT_TESTS))continue; //if(exp.equals(Experiments.SPARQL_100s))continue; - //if(exp.equals(Experiments.NORMAL_100s))continue; + //if(exp.toString().contains("SPARQL"))continue; conductExperiment(exp); - reinitStat(); //System.exit(0); } //conductExperiment(0); @@ -175,12 +187,12 @@ List<String> confs = getFiles(); ComponentManager cm =ComponentManager.getInstance(); - int count = 1; + int count = 0; for (String filename : confs) { SimpleClock oneExperiment = new SimpleClock(); - if (count == 2){break;} + if (count == nrOfFilesInExperiment){break;} - logger.warn("****"+exp+" "+count +" from file "+filename); + logger.warn("****"+exp+" "+(count+1) +" from file "+filename); // read the file and get the examples File f = new File(exampleDir+filename); @@ -246,17 +258,17 @@ cm.freeAllComponents(); - fillTable(exp, count); + fillTable(exp, (count+1)); - logger.warn(exp+" "+count+ " " +oneExperiment.getAndSet("")+"****" ); + logger.warn(exp+" "+(count+1)+ " " +oneExperiment.getAndSet("")+"****" ); count++; }//end for }catch (Exception e) { e.printStackTrace(); flawInExperiment = true; } - - } + reinitStat(); + }//endconduct public static void analyzeFiles(List<String> l){ int countDoublettes = 0; Modified: trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java 2008-09-26 17:25:48 UTC (rev 1273) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java 2008-09-26 18:35:02 UTC (rev 1274) @@ -22,6 +22,7 @@ import java.io.File; import java.io.Serializable; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; @@ -177,17 +178,18 @@ } public static void serializeColumns(Table t, String dir, String tableFile){ - String column = "column"; + String column = ".column"; String content = ""; dir = StringFormatter.checkIfDirEndsOnSlashAndRemove(dir); Files.mkdir(dir); try{ int i=0; for(TableColumn c:t.getColumns()){ - String filename = dir+File.separator+t.getTableName()+column+(i++); - c.serialize(new File(filename)); + String header = URLEncoder.encode(c.getHeader(),"UTF-8"); + String columnFileName = dir+File.separator+t.getTableName()+header+(i++)+column; + c.serialize(new File(columnFileName)); //Files.writeObjectToFile(c, new File(filename)); - content += filename+System.getProperty("line.separator"); + content += columnFileName+System.getProperty("line.separator"); } Files.createFile(new File(tableFile), content); // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-09-26 17:25:57
|
Revision: 1273 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1273&view=rev Author: jenslehmann Date: 2008-09-26 17:25:48 +0000 (Fri, 26 Sep 2008) Log Message: ----------- implemented hasValue support including simple frequent pattern preprocessing (not working yet) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptComparator.java Added Paths: ----------- trunk/examples/semantic_bible/hasvalue_example.conf Added: trunk/examples/semantic_bible/hasvalue_example.conf =================================================================== --- trunk/examples/semantic_bible/hasvalue_example.conf (rev 0) +++ trunk/examples/semantic_bible/hasvalue_example.conf 2008-09-26 17:25:48 UTC (rev 1273) @@ -0,0 +1,20 @@ +/** + * It should learn ethnicity hasValue Jewish, but does not work for some reason. + */ + +import("../NTNcombined.owl"); + +// reasoner = owlAPIReasoner; +owlAPIReasoner.reasonerType = pellet; + ++"http://semanticbible.org/ns/2006/NTNames#Hezron" ++"http://semanticbible.org/ns/2006/NTNames#Jehoshaphat" ++"http://semanticbible.org/ns/2006/NTNames#Judah" ++"http://semanticbible.org/ns/2006/NTNames#Jorim" ++"http://semanticbible.org/ns/2006/NTNames#Neri" + +-"http://semanticbible.org/ns/2006/NTNames#Hierapolis" +-"http://semanticbible.org/ns/2006/NTNames#Iconium" +-"http://semanticbible.org/ns/2006/NTNames#Joda" +-"http://semanticbible.org/ns/2006/NTNames#JohntheBaptist" +-"http://semanticbible.org/ns/2006/NTNames#Philip" Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-26 16:30:40 UTC (rev 1272) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-26 17:25:48 UTC (rev 1273) @@ -63,6 +63,7 @@ import org.dllearner.core.owl.ObjectPropertyExpression; import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.ObjectValueRestriction; import org.dllearner.core.owl.SubsumptionHierarchy; import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.Union; @@ -428,6 +429,11 @@ } } return true; + } else if (description instanceof ObjectValueRestriction) { + Individual i = ((ObjectValueRestriction)description).getIndividual(); + ObjectProperty op = (ObjectProperty) ((ObjectValueRestriction)description).getRestrictedPropertyExpression(); + + return opPos.get(op).get(individual).contains(i); } else if (description instanceof BooleanValueRestriction) { DatatypeProperty dp = ((BooleanValueRestriction) description) .getRestrictedPropertyExpresssion(); Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java 2008-09-26 16:30:40 UTC (rev 1272) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java 2008-09-26 17:25:48 UTC (rev 1273) @@ -36,6 +36,7 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.DescriptionVisitor; import org.dllearner.core.owl.DoubleMinValue; +import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Negation; @@ -44,6 +45,7 @@ import org.dllearner.core.owl.ObjectExactCardinalityRestriction; import org.dllearner.core.owl.ObjectMaxCardinalityRestriction; import org.dllearner.core.owl.ObjectMinCardinalityRestriction; +import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.ObjectValueRestriction; import org.dllearner.core.owl.SimpleDoubleDataRange; @@ -60,6 +62,7 @@ import org.semanticweb.owl.model.OWLDataRange; import org.semanticweb.owl.model.OWLDataType; import org.semanticweb.owl.model.OWLDescription; +import org.semanticweb.owl.model.OWLIndividual; import org.semanticweb.owl.model.OWLObjectProperty; import org.semanticweb.owl.model.OWLTypedConstant; import org.semanticweb.owl.vocab.OWLRestrictedDataRangeFacetVocabulary; @@ -227,8 +230,10 @@ * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.ObjectValueRestriction) */ public void visit(ObjectValueRestriction description) { - // TODO Auto-generated method stub - throw new Error("OWLAPIDescriptionConverter: not implemented"); + OWLObjectProperty role = factory.getOWLObjectProperty( + URI.create(((ObjectProperty)description.getRestrictedPropertyExpression()).getName())); + OWLIndividual i = factory.getOWLIndividual(URI.create(description.getIndividual().getName())); + stack.push(factory.getOWLObjectValueRestriction(role, i)); } /* (non-Javadoc) Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-09-26 16:30:40 UTC (rev 1272) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-09-26 17:25:48 UTC (rev 1273) @@ -19,6 +19,7 @@ */ package org.dllearner.refinementoperators; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -54,6 +55,7 @@ import org.dllearner.core.owl.ObjectPropertyExpression; import org.dllearner.core.owl.ObjectQuantorRestriction; import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.ObjectValueRestriction; import org.dllearner.core.owl.SubsumptionHierarchy; import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.Union; @@ -148,6 +150,14 @@ private Map<DatatypeProperty,List<Double>> splits = new TreeMap<DatatypeProperty,List<Double>>(); private int maxNrOfSplits = 10; + // experimental support for hasValue + private boolean useHasValue = false; + // data structure for a simple frequent pattern matching preprocessing phase + private int frequencyThreshold = 3; + private Map<ObjectProperty, Map<Individual, Integer>> valueFrequency = new HashMap<ObjectProperty, Map<Individual, Integer>>(); + // data structure with identified frequent values + private Map<ObjectProperty, Set<Individual>> frequentValues = new HashMap<ObjectProperty, Set<Individual>>(); + // staistics public long mComputationTimeNs = 0; public long topComputationTimeNs = 0; @@ -193,7 +203,46 @@ for(ObjectProperty op : rs.getObjectProperties()) { opDomains.put(op, rs.getDomain(op)); opRanges.put(op, rs.getRange(op)); + + if(useHasValue) { + // init + Map<Individual, Integer> opMap = new TreeMap<Individual, Integer>(); + valueFrequency.put(op, opMap); + + // sets ordered by corresponding individual (which we ignore) + Collection<SortedSet<Individual>> fillerSets = rs.getRoleMembers(op).values(); + for(SortedSet<Individual> fillerSet : fillerSets) { + for(Individual i : fillerSet) { +// System.out.println("op " + op + " i " + i); + Integer value = opMap.get(i); + + if(value != null) { + opMap.put(i, value+1); + } else { + opMap.put(i, 1); + } + } + } + + // keep only frequent patterns (TODO it would be slightly + // more efficient if we stop adding to valueFrequency + // after threshold is reached) + Set<Individual> frequentInds = new TreeSet<Individual>(); + for(Individual i : opMap.keySet()) { + if(opMap.get(i) > frequencyThreshold) { + frequentInds.add(i); + } + } + frequentValues.put(op, frequentInds); + + } + } + + // we do not need the temporary set anymore and let the + // garbage collector take care of it + valueFrequency = null; + for(DatatypeProperty dp : rs.getDatatypeProperties()) { dpDomains.put(dp, rs.getDomain(dp)); } @@ -405,6 +454,18 @@ } } + // rule 4: EXISTS r.TOP => EXISTS r.{value} + if(useHasValue && description.getChild(0) instanceof Thing) { + // watch out for frequent patterns + Set<Individual> frequentInds = frequentValues.get(role); + if(frequentInds != null) { + for(Individual ind : frequentInds) { + ObjectValueRestriction ovr = new ObjectValueRestriction(ar, ind); + refinements.add(ovr); + } + } + } + } else if (description instanceof ObjectAllRestriction) { ObjectPropertyExpression role = ((ObjectQuantorRestriction)description).getRole(); Description range = opRanges.get(role); Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptComparator.java 2008-09-26 16:30:40 UTC (rev 1272) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptComparator.java 2008-09-26 17:25:48 UTC (rev 1273) @@ -8,6 +8,7 @@ import org.dllearner.core.owl.DatatypeSomeRestriction; import org.dllearner.core.owl.DoubleMaxValue; import org.dllearner.core.owl.DoubleMinValue; +import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.ObjectAllRestriction; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Nothing; @@ -17,6 +18,7 @@ import org.dllearner.core.owl.ObjectMinCardinalityRestriction; import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.ObjectValueRestriction; import org.dllearner.core.owl.SimpleDoubleDataRange; import org.dllearner.core.owl.Union; import org.dllearner.core.owl.Negation; @@ -175,8 +177,23 @@ return roleCompare; } else return -1; + } else if(concept1 instanceof ObjectValueRestriction) { + if(concept2.getChildren().size()<1 || concept2 instanceof Negation || concept2 instanceof ObjectSomeRestriction || concept2 instanceof ObjectAllRestriction) + return 1; + else if(concept2 instanceof ObjectValueRestriction) { + int roleCompare = rc.compare(((ObjectValueRestriction)concept1).getRestrictedPropertyExpression(), ((ObjectQuantorRestriction)concept2).getRestrictedPropertyExpression()); + + if(roleCompare == 0) { + Individual value1 = ((ObjectValueRestriction)concept1).getIndividual(); + Individual value2 = ((ObjectValueRestriction)concept2).getIndividual(); + return value1.compareTo(value2); + } else { + return roleCompare; + } + } else + return -1; } else if(concept1 instanceof ObjectMinCardinalityRestriction) { - if(concept2.getChildren().size()<1 || concept2 instanceof Negation || concept2 instanceof ObjectQuantorRestriction) + if(concept2.getChildren().size()<1 || concept2 instanceof Negation || concept2 instanceof ObjectQuantorRestriction || concept2 instanceof ObjectValueRestriction) return 1; // first criterion: object property // second criterion: number @@ -196,7 +213,7 @@ } else return -1; } else if(concept1 instanceof ObjectMaxCardinalityRestriction) { - if(concept2.getChildren().size()<1 || concept2 instanceof Negation || concept2 instanceof ObjectQuantorRestriction || concept2 instanceof ObjectMinCardinalityRestriction) + if(concept2.getChildren().size()<1 || concept2 instanceof Negation || concept2 instanceof ObjectQuantorRestriction || concept2 instanceof ObjectValueRestriction || concept2 instanceof ObjectMinCardinalityRestriction) return 1; // first criterion: object property // second criterion: number This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-26 16:30:50
|
Revision: 1272 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1272&view=rev Author: kurzum Date: 2008-09-26 16:30:40 +0000 (Fri, 26 Sep 2008) Log Message: ----------- long retrieval time example Added Paths: ----------- trunk/examples/semantic_bible/normal_long_retrieval_time.conf Added: trunk/examples/semantic_bible/normal_long_retrieval_time.conf =================================================================== --- trunk/examples/semantic_bible/normal_long_retrieval_time.conf (rev 0) +++ trunk/examples/semantic_bible/normal_long_retrieval_time.conf 2008-09-26 16:30:40 UTC (rev 1272) @@ -0,0 +1,29 @@ + /** +EXISTS "http://semanticbible.org/ns/2006/NTNames#siblingOf".TOP +EXISTS "http://semanticbible.org/ns/2006/NTNames#siblingOf"."http://semanticbible.org/ns/2006/NTNames#Man" + */ + + +// export("arch.owl"); +import("NTNcombined.owl"); + +algorithm = refexamples; +refexamples.useAllConstructor = true; +refexamples.useNegation = true; +refexamples.useCardinalityRestrictions = true; + +refexamples.guaranteeXgoodDescriptions = 20; +//refexamples.ignoredConcepts = {"http://semanticbible.org/ns/2006/NTNames#God"}; + +//reasoner = fastInstanceChecker; +reasoner = owlAPIReasoner; +owlAPIReasoner.reasonerType = pellet; + +/** examples **/ +-"http://semanticbible.org/ns/2006/NTNames#Almighty" +-"http://semanticbible.org/ns/2006/NTNames#Gabriel" +-"http://semanticbible.org/ns/2006/NTNames#Michael" ++"http://semanticbible.org/ns/2006/NTNames#Archelaus" ++"http://semanticbible.org/ns/2006/NTNames#HerodAntipas" +-"http://semanticbible.org/ns/2006/NTNames#Satan" +-"http://semanticbible.org/ns/2006/NTNames#Jesus" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-26 15:51:05
|
Revision: 1271 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1271&view=rev Author: kurzum Date: 2008-09-26 15:50:40 +0000 (Fri, 26 Sep 2008) Log Message: ----------- server commit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 15:08:38 UTC (rev 1270) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 15:50:40 UTC (rev 1271) @@ -20,6 +20,7 @@ package org.dllearner.scripts; import java.io.File; +import java.io.IOException; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; @@ -33,8 +34,10 @@ import org.apache.log4j.ConsoleAppender; import org.apache.log4j.FileAppender; +import org.apache.log4j.Layout; import org.apache.log4j.Level; import org.apache.log4j.Logger; +import org.apache.log4j.PatternLayout; import org.apache.log4j.SimpleLayout; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.core.Component; @@ -141,9 +144,13 @@ analyzeFiles(l); for (Experiments exp : Experiments.values()) { - if(exp.equals(Experiments.SPARQL_10s))continue; + //if(exp.equals(Experiments.SPARQL_10000_CONCEPT_TESTS))continue; + //if(exp.equals(Experiments.NORMAL_10000_CONCEPT_TESTS))continue; + //if(exp.equals(Experiments.SPARQL_100s))continue; + //if(exp.equals(Experiments.NORMAL_100s))continue; conductExperiment(exp); - System.exit(0); + reinitStat(); + //System.exit(0); } //conductExperiment(0); @@ -152,7 +159,7 @@ File jamonlog = new File(dir+"jamon.html"); Files.createFile(jamonlog, MonitorFactory.getReport()); Files.appendFile(jamonlog, "<xmp>\n"+JamonMonitorLogger.getStringForAllSortedByLabel()); - total.printAndSet("Finished"); + //total.printAndSet("Finished"); logger.warn(total.getAndSet("Finished")); if(flawInExperiment){ logger.error("There were exceptions"); @@ -171,9 +178,9 @@ int count = 1; for (String filename : confs) { SimpleClock oneExperiment = new SimpleClock(); - if (count == 6){break;} + if (count == 2){break;} - logger.warn(exp+" "+count +" from file "+filename); + logger.warn("****"+exp+" "+count +" from file "+filename); // read the file and get the examples File f = new File(exampleDir+filename); @@ -241,7 +248,7 @@ fillTable(exp, count); - logger.warn(exp+" "+count+ " " +oneExperiment.getAndSet("") ); + logger.warn(exp+" "+count+ " " +oneExperiment.getAndSet("")+"****" ); count++; }//end for }catch (Exception e) { @@ -255,11 +262,18 @@ int countDoublettes = 0; SortedSet<String> differentIndividuals = new TreeSet<String>(); for ( String file : l) { + String fileContent = ""; + try{fileContent = Files.readFile(new File(exampleDir+file)); + }catch (Exception e) { + e.printStackTrace(); + } ExampleContainer ec = new ExampleContainer( - SetManipulation.stringToInd(getIndividuals(file, true)), - SetManipulation.stringToInd(getIndividuals(file, false))); - differentIndividuals.addAll(getIndividuals(file, true)); - differentIndividuals.addAll(getIndividuals(file, false)); + SetManipulation.stringToInd(getIndividuals(fileContent, true)), + SetManipulation.stringToInd(getIndividuals(fileContent, false))); + + differentIndividuals.addAll(getIndividuals(fileContent, true)); + differentIndividuals.addAll(getIndividuals(fileContent, false)); + if(!ExampleContainer.add(ec)){ countDoublettes++; } @@ -464,7 +478,7 @@ - public static void reinitStat(){ + private static void reinitStat(){ accFragment = new Stat(); accOnOnto = new Stat(); accPosExOnOnto = new Stat(); @@ -531,7 +545,6 @@ public static List<String> getFiles(){ String actualDir = exampleDir; - logger.warn(actualDir); File f = new File(actualDir); String[] files = f.list(); Arrays.sort(files); @@ -572,22 +585,32 @@ private static void initLogger() { - SimpleLayout layout = new SimpleLayout(); - // create logger (a simple logger which outputs - // its messages to the console) - FileAppender fileAppender = null; + // logger 1 is the console, where we print only info messages; + // the logger is plain, i.e. does not output log level etc. + Layout layout = new PatternLayout(); + ConsoleAppender consoleAppender = new ConsoleAppender(layout); + consoleAppender.setThreshold(Level.WARN); + + // logger 2 is writes to a file; it records all debug messages + // and includes the log level + Layout layout2 = new SimpleLayout(); + FileAppender fileAppenderNormal = null; + File f = new File("log/sparql.txt"); try { - fileAppender = new FileAppender(layout, "log/semBibleLog.txt", - false); - } catch (Exception e) { + fileAppenderNormal = new FileAppender(layout2, "log/semBibleLog.txt", false); + f.delete(); + f.createNewFile(); + } catch (IOException e) { e.printStackTrace(); } - - ConsoleAppender consoleAppender = new ConsoleAppender(layout); + + + logger.removeAllAppenders(); logger.addAppender(consoleAppender); - logger.addAppender(fileAppender); - logger.setLevel(Level.WARN); + logger.addAppender(fileAppenderNormal); + logger.setLevel(Level.DEBUG); + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-26 15:07:46
|
Revision: 1269 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1269&view=rev Author: kurzum Date: 2008-09-26 15:07:32 +0000 (Fri, 26 Sep 2008) Log Message: ----------- server commit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java trunk/src/dl-learner/org/dllearner/utilities/StringFormatter.java trunk/src/dl-learner/org/dllearner/utilities/examples/ExampleContainer.java trunk/src/dl-learner/org/dllearner/utilities/statistics/SimpleClock.java trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java Modified: trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-09-26 13:18:07 UTC (rev 1268) +++ trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-09-26 15:07:32 UTC (rev 1269) @@ -23,7 +23,6 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; -import org.dllearner.kb.sparql.NaturalLanguageDescriptionConvertVisitor; import org.dllearner.kb.sparql.SparqlQueryDescriptionConvertVisitor; import org.dllearner.learningproblems.ScoreTwoValued; import org.dllearner.reasoning.OWLAPIDescriptionConvertVisitor; Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 13:18:07 UTC (rev 1268) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-26 15:07:32 UTC (rev 1269) @@ -20,7 +20,9 @@ package org.dllearner.scripts; import java.io.File; +import java.net.MalformedURLException; import java.net.URI; +import java.net.URL; import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -42,21 +44,27 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.ReasoningService; import org.dllearner.core.configurators.ComponentFactory; +import org.dllearner.core.configurators.ExampleBasedROLComponentConfigurator; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.gui.Config; import org.dllearner.gui.ConfigSave; +import org.dllearner.kb.OWLFile; import org.dllearner.kb.sparql.Cache; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.utilities.Files; import org.dllearner.utilities.JamonMonitorLogger; +import org.dllearner.utilities.StringFormatter; import org.dllearner.utilities.datastructures.SetManipulation; +import org.dllearner.utilities.examples.ExampleContainer; import org.dllearner.utilities.owl.ReasoningServiceFactory; import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; import org.dllearner.utilities.statistics.SimpleClock; import org.dllearner.utilities.statistics.Stat; +import org.dllearner.utilities.statistics.Table; +import org.dllearner.utilities.statistics.TableColumn; import com.jamonapi.MonitorFactory; @@ -65,42 +73,53 @@ private static ReasoningService reasoningService; private static Logger logger = Logger.getRootLogger(); - public static boolean flawInExperiment = false; + private static boolean flawInExperiment = false; - public static String ontologyPath = "examples/semantic_bible/NTNcombined.owl"; - public static String dir = "sembib/"; + private static String ontologyPath = "examples/semantic_bible/NTNcombined.owl"; + private static String dir = "sembib100/"; //public static String sparqldir = dir+"sparql/"; - public static String exampleDir = dir+"examples/"; + private static String exampleDir = dir+"examples/"; + private static String tableDir = dir+"table/"; - public static String tmpFilename = dir + "tmp.conf"; - static File log = new File(dir+"results+prop.txt"); + private static String tmpFilename = dir + "tmp.conf"; + //static File log = new File(dir+"results+prop.txt"); + private static String tableFile = tableDir+"sembib.table"; + private static String tableLatex = tableDir+"sembibLatex.table"; private static Stat accFragment = new Stat(); private static Stat accOnOnto = new Stat(); private static Stat accPosExOnOnto = new Stat(); private static Stat accNegExOnOnto = new Stat(); private static Stat learningTime = new Stat(); - private static Stat nrOfExtractedTriples = new Stat(); + //private static Stat initializationTime = new Stat(); + private static Stat reasonerInitializationTime = new Stat(); + private static Stat ksinitializationTime = new Stat(); + private static Stat nrOfExtractedAxioms = new Stat(); private static Stat descLength = new Stat(); private static Stat descDepth = new Stat(); - private static Stat timeWhole = new Stat(); - private static Stat accWhole = new Stat(); - private static Stat dLengthWhole = new Stat(); - private static Stat dDepthWhole = new Stat(); - - private static boolean descHasNot = false; private static boolean descHasAll = false; private static boolean descHasBooleanData = false; private static boolean descHasNrRes = false; - private static boolean wholeHasNot = false; - private static boolean wholeHasAll = false; - private static boolean wholeHasBooleanData = false; - private static boolean wholeHasNrRes = false; + private static Table t; + //private static boolean wholeHasNot = false; + //private static boolean wholeHasAll = false; + //private static boolean wholeHasBooleanData = false; + //private static boolean wholeHasNrRes = false; + //10s means fixed time 10s + private static enum Experiments { + SPARQL_10s, + NORMAL_10s, + SPARQL_100s, + NORMAL_100s, + SPARQL_1000_CONCEPT_TESTS, + NORMAL_1000_CONCEPT_TESTS, + SPARQL_10000_CONCEPT_TESTS, + NORMAL_10000_CONCEPT_TESTS}; //private static Class usedReasoner = FastInstanceChecker.class; @@ -112,18 +131,29 @@ */ public static void main(String[] args) { SimpleClock total = new SimpleClock(); - Files.createFile(log, ""); + initLogger(); logger.warn("Start"); + prepareTable(); + List<String> l = getFiles(); + analyzeFiles(l); + for (Experiments exp : Experiments.values()) { + if(exp.equals(Experiments.SPARQL_10s))continue; + conductExperiment(exp); + System.exit(0); + } + //conductExperiment(0); - conductExperiment(0); - - + // write JaMON report in HTML file + File jamonlog = new File(dir+"jamon.html"); + Files.createFile(jamonlog, MonitorFactory.getReport()); + Files.appendFile(jamonlog, "<xmp>\n"+JamonMonitorLogger.getStringForAllSortedByLabel()); total.printAndSet("Finished"); + logger.warn(total.getAndSet("Finished")); if(flawInExperiment){ logger.error("There were exceptions"); } @@ -131,29 +161,40 @@ } - public static void conductExperiment(int experiment){ + public static void conductExperiment(Experiments exp){ try{ //prepare everything List<String> confs = getFiles(); ComponentManager cm =ComponentManager.getInstance(); + int count = 1; for (String filename : confs) { + SimpleClock oneExperiment = new SimpleClock(); + if (count == 6){break;} + + logger.warn(exp+" "+count +" from file "+filename); + // read the file and get the examples - File f = new File(filename); + File f = new File(exampleDir+filename); Cache.getDefaultCache().clearCache(); String fileContent = Files.readFile(f); SortedSet<Individual> posEx = SetManipulation.stringToInd(getIndividuals(fileContent, true)); SortedSet<Individual> negEx = SetManipulation.stringToInd(getIndividuals(fileContent, false)); - ExampleBasedROLComponent la = experimentalSetup1(posEx,negEx); - //TODO measure time + ExampleBasedROLComponent la = experimentalSetup(exp,posEx,negEx); + + //SimpleClock init = new SimpleClock(); initAllComponents(); + //initializationTime.addNumber((double) init.getTime()/1000); + SimpleClock learningTimeClock = new SimpleClock(); la.start(); - learningTime.addNumber((double) learningTimeClock.getTime()); - + learningTime.addNumber((double) learningTimeClock.getTime()/1000); + logger.warn(learningTimeClock.getAndSet("learning time")+" in stat: "+learningTime.getMean()); + + EvaluatedDescription bestDescription =(la.getCurrentlyBestEvaluatedDescription()); accFragment.addNumber(bestDescription.getAccuracy()); @@ -173,6 +214,9 @@ EvaluatedDescription onOnto = reEvaluateDescription( bestDescription.getDescription(), retrieved, posEx, negEx); + logger.warn(onOnto.getDescription().toManchesterSyntaxString(null, null)); + logger.warn(onOnto.getAccuracy()); + accOnOnto.addNumber(onOnto.getAccuracy()); //int tmp = (int)(Math.floor(onOnto.getAccuracy()*100)); @@ -188,15 +232,17 @@ } if(s!=null){ double nrtrip = (double)(s.getNrOfExtractedAxioms()); - nrOfExtractedTriples.addNumber(nrtrip); + nrOfExtractedAxioms.addNumber(nrtrip); }else{ - nrOfExtractedTriples.addNumber(0.0); + nrOfExtractedAxioms.addNumber(0.0); } cm.freeAllComponents(); + fillTable(exp, count); - + logger.warn(exp+" "+count+ " " +oneExperiment.getAndSet("") ); + count++; }//end for }catch (Exception e) { e.printStackTrace(); @@ -205,15 +251,57 @@ } - public static ExampleBasedROLComponent experimentalSetup1(SortedSet<Individual> posExamples, SortedSet<Individual> negExamples ){ - ExampleBasedROLComponent la = prepareSparqlExperiment(posExamples, negExamples); + public static void analyzeFiles(List<String> l){ + int countDoublettes = 0; + SortedSet<String> differentIndividuals = new TreeSet<String>(); + for ( String file : l) { + ExampleContainer ec = new ExampleContainer( + SetManipulation.stringToInd(getIndividuals(file, true)), + SetManipulation.stringToInd(getIndividuals(file, false))); + differentIndividuals.addAll(getIndividuals(file, true)); + differentIndividuals.addAll(getIndividuals(file, false)); + if(!ExampleContainer.add(ec)){ + countDoublettes++; + } + } + logger.warn("found diff inds "+differentIndividuals.size()); + logger.warn("found doublettes " + countDoublettes); + } + + public static ExampleBasedROLComponent experimentalSetup(Experiments exp,SortedSet<Individual> posExamples, SortedSet<Individual> negExamples ){ + ExampleBasedROLComponent la = null; + if(exp.toString().contains("SPARQL")) + la = prepareSparqlExperiment(posExamples, negExamples); + else if(exp.toString().contains("NORMAL")){ + la = prepareNormalExperiment(posExamples, negExamples); + }else { + logger.error("undefined EXPERIMENT" + exp); + System.exit(0); + } + + ExampleBasedROLComponentConfigurator c = la.getConfigurator(); + + if(exp.toString().contains("10s")){ + c.setMaxExecutionTimeInSeconds(10); + c.setMinExecutionTimeInSeconds(10); + + }else if(exp.toString().contains("100s")){ + c.setMaxExecutionTimeInSeconds(100); + c.setMinExecutionTimeInSeconds(100); + + }else if(exp.toString().contains("1000_CONCEPT_TESTS")){ + c.setMaxClassDescriptionTests(1000); + }else if(exp.toString().contains("10000_CONCEPT_TESTS")){ + c.setMaxClassDescriptionTests(10000); + } //la.getConfigurator(); //appendtoFile return la; } + public static ExampleBasedROLComponent prepareSparqlExperiment(SortedSet<Individual> posExamples, SortedSet<Individual> negExamples){ @@ -234,6 +322,7 @@ ks.getConfigurator().setUseLits(true); ks.getConfigurator().setGetAllSuperClasses(true); ks.getConfigurator().setGetPropertyInformation(true); + ks.getConfigurator().setVerbosity("warning"); Set<KnowledgeSource> tmp = new HashSet<KnowledgeSource>(); tmp.add(ks); @@ -261,47 +350,136 @@ return la; } + public static ExampleBasedROLComponent prepareNormalExperiment(SortedSet<Individual> posExamples, SortedSet<Individual> negExamples){ + ExampleBasedROLComponent la = null; + try{ + SortedSet<Individual> instances = new TreeSet<Individual>(); + instances.addAll(posExamples); + instances.addAll(negExamples); + + URL fileURL = null; + try { + fileURL = new File(ontologyPath).toURI().toURL(); + } catch (MalformedURLException e) { + e.printStackTrace(); + flawInExperiment = true; + } + OWLFile ks = ComponentFactory.getOWLFile( fileURL); + + Set<KnowledgeSource> tmp = new HashSet<KnowledgeSource>(); + tmp.add(ks); + // reasoner + OWLAPIReasoner f = ComponentFactory + .getOWLAPIReasoner(tmp); + ReasoningService rs = ComponentManager.getInstance() + .reasoningService(f); + +// learning problem + PosNegDefinitionLP lp = ComponentFactory.getPosNegDefinitionLP(rs, + SetManipulation.indToString(posExamples), SetManipulation + .indToString(negExamples)); + + // learning algorithm + la = ComponentFactory.getExampleBasedROLComponent(lp, rs); + la.getConfigurator().setGuaranteeXgoodDescriptions(1); + Config c = new Config(ComponentManager.getInstance(), ks, f, rs, lp, la); + new ConfigSave(c).saveFile(new File(tmpFilename)); + + }catch (Exception e) { + e.printStackTrace(); + flawInExperiment = true; + } + return la; + } + public static void initAllComponents(){ ComponentManager cm = ComponentManager.getInstance(); + for(Component c : cm.getLiveComponents()){ try{ + SimpleClock time = new SimpleClock(); c.init(); + if (c instanceof SparqlKnowledgeSource) { + ksinitializationTime.addNumber((double) time.getTime()/1000); + + }else if (c instanceof OWLFile) { + ksinitializationTime.addNumber((double) time.getTime()/1000); + + }else if (c instanceof OWLAPIReasoner) { + reasonerInitializationTime.addNumber((double) time.getTime()/1000); + + } + }catch (Exception e) { e.printStackTrace(); flawInExperiment = true; } } + } - public static void writeLog(){ - String l = "\n\n\n*********************\n"; - l +="COUNT: "+accFragment.getCount()+"\n"; - l +="FRAGMENT: ALL: "+descHasAll+" BOOL: "+descHasBooleanData+" NOT: "+descHasNot+" <>=: "+descHasNrRes+"\n"; - l +="WHOLE: ALL: "+wholeHasAll+" BOOL: "+wholeHasBooleanData+" NOT: "+wholeHasNot+" <>=: "+wholeHasNrRes+"\n"; + public static void prepareTable(){ + t = new Table("sembib"); + String[] labString = new String[]{ + "count", + "accuracy on fragment(%)", + "accuracy on whole (%)", + "accuracy pos examples on whole (%)", + "accuracy neg examples on whole (%)", + "extraction/parsing time", + "reasoner initialization time", + "learning time", + "number of axioms", + "description length", + "description depth" + }; //9 + TableColumn labels = new TableColumn("Semantic Bible",labString); + t.addColumn(labels); + Table.serializeColumns(t, tableDir, tableFile); + Files.createFile(new File(tableLatex), t.getLatexString()); - - l+="accFragment\t\t"+accFragment.getMeanAsPercentage()+" +-"+accFragment.getStandardDeviation()+"\n"; - l+="accOnOnto\t\t"+accOnOnto.getMeanAsPercentage()+" +-"+accOnOnto.getStandardDeviation()+"\n"; - l+="accPosExOnOnto\t\t"+accPosExOnOnto.getMeanAsPercentage()+" +-"+accPosExOnOnto.getStandardDeviation()+"\n"; - l+="accNegExOnOnto\t\t"+accNegExOnOnto.getMeanAsPercentage()+" +-"+accNegExOnOnto.getStandardDeviation()+"\n"; - l+="timeFragment\t\t"+learningTime.getMean()+" +-"+learningTime.getStandardDeviation()+"\n"; - l+="nrOfExtractedTriples\t\t"+nrOfExtractedTriples.getMean()+" +-"+nrOfExtractedTriples.getStandardDeviation()+"\n"; - l+="dLengthFragment\t\t"+descLength.getMean()+" +-"+descLength.getStandardDeviation()+"\n"; - l+="dDepthFragment\t\t"+descDepth.getMean()+" +-"+descDepth.getStandardDeviation()+"\n"; + } + + public static void fillTable(Experiments exp, int count){ + String[] columnString = new String[]{ + count+"", + StringFormatter.convertStatPercentageToLatex(accFragment, 1, false, true), + StringFormatter.convertStatPercentageToLatex(accOnOnto, 1, false, true), + StringFormatter.convertStatPercentageToLatex(accPosExOnOnto, 1, false, true), + StringFormatter.convertStatPercentageToLatex(accNegExOnOnto, 1, false, true), + StringFormatter.convertStatDoubleToLatex(ksinitializationTime, 1, "", "s", true), + StringFormatter.convertStatDoubleToLatex(reasonerInitializationTime, 1, "", "s", true), + StringFormatter.convertStatDoubleToLatex(learningTime, 1, "", "s", true), + StringFormatter.convertStatDoubleToLatex(nrOfExtractedAxioms, 0, "", "", true), + StringFormatter.convertStatDoubleToLatex(descLength, 1, "", "", true), + StringFormatter.convertStatDoubleToLatex(descDepth, 1, "", "", true), + }; //9 + t.removeColumn(exp.toString()); + t.addColumn(new TableColumn(exp.toString(),columnString)); + Table.serializeColumns(t, tableDir, tableFile); + Files.createFile(new File(tableLatex), t.getLatexString()); - l+="timeWhole\t\t"+timeWhole.getMean()+" +-"+timeWhole.getStandardDeviation()+"\n"; - l+="accWhole\t\t"+accWhole.getMeanAsPercentage()+" +-"+accWhole.getStandardDeviation()+"\n"; - l+="dLengthWhole\t\t"+dLengthWhole.getMean()+" +-"+dLengthWhole.getStandardDeviation()+"\n"; - l+="dDepthWhole\t\t"+dDepthWhole.getMean()+" +-"+dDepthWhole.getStandardDeviation()+"\n"; - Files.appendFile(log, l); - -// write JaMON report in HTML file - File jamonlog = new File("sembib/jamon.html"); - Files.createFile(jamonlog, MonitorFactory.getReport()); - Files.appendFile(jamonlog, "<xmp>\n"+JamonMonitorLogger.getStringForAllSortedByLabel()); } + + + public static void reinitStat(){ + accFragment = new Stat(); + accOnOnto = new Stat(); + accPosExOnOnto = new Stat(); + accNegExOnOnto = new Stat(); + ksinitializationTime = new Stat(); + reasonerInitializationTime = new Stat(); + learningTime = new Stat(); + nrOfExtractedAxioms = new Stat(); + descLength = new Stat(); + descDepth = new Stat(); + } + + + + public static EvaluatedDescription reEvaluateDescription(Description d, SortedSet<Individual> retrieved ,SortedSet<Individual> posEx ,SortedSet<Individual> negEx ){ SortedSet<Individual> PosAsPos = new TreeSet<Individual>(); SortedSet<Individual> PosAsNeg = new TreeSet<Individual>(); @@ -452,17 +630,7 @@ return ret; }*/ -/*public static void analyzeFiles(List<File> l){ - - SortedSet<String> differentIndividuals = new TreeSet<String>(); - for ( content : l) { - differentIndividuals.addAll(getIndividuals(content, true)); - differentIndividuals.addAll(getIndividuals(content, false)); - - } - System.out.println("found diff inds "+differentIndividuals.size()); - -}*/ + } Modified: trunk/src/dl-learner/org/dllearner/utilities/StringFormatter.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/StringFormatter.java 2008-09-26 13:18:07 UTC (rev 1268) +++ trunk/src/dl-learner/org/dllearner/utilities/StringFormatter.java 2008-09-26 15:07:32 UTC (rev 1269) @@ -1,6 +1,11 @@ package org.dllearner.utilities; +import java.io.File; +import java.text.DecimalFormat; +import org.dllearner.utilities.statistics.Stat; + + public class StringFormatter { @@ -10,16 +15,113 @@ * @param d */ public static String doubleToPercent(double d){ - if(d>1.0 || d<0.0)return "bad format: "+d; - else if(d == 1.0){ - return "100.0%"; - }else if(d == 0.0 ){ - return "0.0%"; - }else { - String acc = (d*100)+""; - acc = acc.substring(0,"55.5".length()); - return acc+"%"; + return doubleToPercent( d, 1, true); + } + + public static String doubleToPercent(double d, int decimals){ + + return doubleToPercent( d, decimals, true); + + } + + public static String doubleToPercent(double d, int decimals, boolean addPercentSign){ + + String format = (decimals==0)?"00":"."; + for (int i = 0; i < decimals; i++) { + format += "0"; + } + format+="%"; + DecimalFormat df = new DecimalFormat( format ); + String ret = df.format(d); + ret = (addPercentSign)?ret:ret.replaceAll("%", ""); + return ret; + + } + + public static String doubleRound(double d, int decimals, String before, String after){ + String ret =""; + if(decimals==0){ + int retInt = (int) Math.floor((d+0.5)); + ret = retInt+""; + }else{ + String format = "."; + for (int i = 0; i < decimals; i++) { + format += "0"; } + + DecimalFormat df = new DecimalFormat( format ); + ret = df.format(d); + ret = ret.replaceAll("%", ""); + } + ret = before + ret+ after; + return ret; } + + public static String convertStatPercentageToLatex(Stat s, + int decimals, + boolean addPercentSign, + boolean includeSTDDeviation){ + String ret =""; + + ret = doubleToPercent(s.getMean(), decimals, addPercentSign); + ret = ret.replaceAll("%", "\\%"); + if(includeSTDDeviation){ + ret += " ($\\pm$"+doubleToPercent(s.getStandardDeviation(), decimals, false)+")"; + } + return ret; + } + + public static String convertStatDoubleToLatex(Stat s, + int decimals, + boolean includeSTDDeviation){ + return convertStatDoubleToLatex(s, decimals,"","",includeSTDDeviation); + } + + + public static String convertStatDoubleToLatex(Stat s, + int decimals, + String before, + String after, + boolean includeSTDDeviation){ + String ret =""; + + ret = doubleRound(s.getMean(), decimals, before, after); + + if(includeSTDDeviation){ + ret += doubleRound(s.getStandardDeviation(), decimals," ($\\pm$", after+")" ); + } + return ret; + } + + + + + + public static void main(String[] args) { + double d = 0.55555; + System.out.println(doubleToPercent(d, 0)); + System.out.println(doubleToPercent(d, 1)); + System.out.println(doubleToPercent(d, 2)); + System.out.println(doubleToPercent(d, 3)); + System.out.println(doubleToPercent(d, 0, false)); + System.out.println(doubleToPercent(d, 1, false)); + System.out.println(doubleToPercent(d, 2, false)); + System.out.println(doubleToPercent(d, 3, false)); + d= 55.55555; + System.out.println(doubleRound(d, 0, "|", "|")); + System.out.println(doubleRound(d, 1, "|", "|")); + System.out.println(doubleRound(d, 2, "|", "|")); + System.out.println(doubleRound(d, 3, "|", "|")); + + } + + public static String checkIfDirEndsOnSlashAndRemove(String dir){ + if(dir.endsWith(File.separator)){ + dir=dir.substring(0,dir.length()-File.separator.length()); + } + return dir; + } + + } Modified: trunk/src/dl-learner/org/dllearner/utilities/examples/ExampleContainer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/examples/ExampleContainer.java 2008-09-26 13:18:07 UTC (rev 1268) +++ trunk/src/dl-learner/org/dllearner/utilities/examples/ExampleContainer.java 2008-09-26 15:07:32 UTC (rev 1269) @@ -51,6 +51,12 @@ } + /** + * adds to a global example repository. + * returns false, if the set is contained already + * @param e + * @return + */ public static boolean add(ExampleContainer e){ return exampleSets.add(e); } Modified: trunk/src/dl-learner/org/dllearner/utilities/statistics/SimpleClock.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/SimpleClock.java 2008-09-26 13:18:07 UTC (rev 1268) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/SimpleClock.java 2008-09-26 15:07:32 UTC (rev 1269) @@ -85,6 +85,10 @@ setTime(); } + /** + * returns the needed time up to now in ms + * @return + */ public long getTime() { long now = System.currentTimeMillis(); return now - time; Modified: trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java 2008-09-26 13:18:07 UTC (rev 1268) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java 2008-09-26 15:07:32 UTC (rev 1269) @@ -26,6 +26,7 @@ import java.util.List; import org.dllearner.utilities.Files; +import org.dllearner.utilities.StringFormatter; /** @@ -117,7 +118,16 @@ else return columns.get(0).getSize(); } + public void removeColumn(String header){ + for (int i = 0; i < columns.size(); i++) { + if(columns.get(i).getHeader().equals(header)){ + columns.remove(i); + return; + } + } + } + public List<String> getColumnHeaders(){ List<String> entries = new ArrayList<String>(); for (TableColumn c : columns) { @@ -169,6 +179,7 @@ public static void serializeColumns(Table t, String dir, String tableFile){ String column = "column"; String content = ""; + dir = StringFormatter.checkIfDirEndsOnSlashAndRemove(dir); Files.mkdir(dir); try{ int i=0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-09-26 13:18:13
|
Revision: 1268 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1268&view=rev Author: jenslehmann Date: 2008-09-26 13:18:07 +0000 (Fri, 26 Sep 2008) Log Message: ----------- added parameter to web service for starting it in non-interactive mode Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java 2008-09-26 12:52:19 UTC (rev 1267) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java 2008-09-26 13:18:07 UTC (rev 1268) @@ -47,29 +47,45 @@ */ public class DLLearnerWSStart { + /** + * DL-Learner web service startup method. + * + * @param args + * --non-interactive starts the web service in a mode, where + * it does not wait for user input, i.e. it cannot be terminated + * using exit. Use this in conjunction with nohup. + */ public static void main(String[] args) { - - //create web service logger - SimpleLayout layout = new SimpleLayout(); + + // "interactive" means that the web service waits for the + // user to type "exit" and exit gracefully; it + // non-interactive mode, the web service is started and has + // to be terminated externally (e.g. killing its process); + // when using nohup, please use noninteractive mode + boolean interactive = true; + if (args.length > 0 && args[0].equals("--non-interactive")) { + interactive = false; + } + + // create web service logger + SimpleLayout layout = new SimpleLayout(); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger logger = Logger.getRootLogger(); - - FileAppender fileAppenderNormal = null; - File f = new File("log/sparql.txt"); + + FileAppender fileAppenderNormal = null; + File f = new File("log/sparql.txt"); try { - fileAppenderNormal = new FileAppender(layout, "log/log.txt", false); - f.delete(); - f.createNewFile(); + fileAppenderNormal = new FileAppender(layout, "log/log.txt", false); + f.delete(); + f.createNewFile(); } catch (IOException e) { e.printStackTrace(); } - - + logger.removeAllAppenders(); logger.addAppender(consoleAppender); logger.addAppender(fileAppenderNormal); logger.setLevel(Level.INFO); - InetSocketAddress isa = new InetSocketAddress("localhost", 8181); HttpServer server = null; @@ -92,30 +108,32 @@ System.out.println("OK."); - System.out.println("Type \"exit\" to terminate web service."); - boolean terminate = false; - String inputString = ""; - do { - BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); + if(interactive) { + System.out.println("Type \"exit\" to terminate web service."); + boolean terminate = false; + String inputString = ""; + do { + BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); + + try { + inputString = input.readLine(); + } catch (IOException e) { + e.printStackTrace(); + } + + if (inputString.equals("exit")) + terminate = true; + + } while (!terminate); + + System.out.print("Stopping web service ... "); + endpoint.stop(); + + server.stop(1); + threads.shutdown(); + System.out.println("OK."); + } - try { - inputString = input.readLine(); - } catch (IOException e) { - e.printStackTrace(); - } - - if (inputString.equals("exit")) - terminate = true; - - } while (!terminate); - - System.out.print("Stopping web service ... "); - endpoint.stop(); - - server.stop(1); - threads.shutdown(); - System.out.println("OK."); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-09-26 12:52:35
|
Revision: 1267 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1267&view=rev Author: sknappe Date: 2008-09-26 12:52:19 +0000 (Fri, 26 Sep 2008) Log Message: ----------- Added Paths: ----------- trunk/src/dbpedia-navigator/Settings.php.dist Removed Paths: ------------- trunk/src/dbpedia-navigator/Settings.php Deleted: trunk/src/dbpedia-navigator/Settings.php =================================================================== --- trunk/src/dbpedia-navigator/Settings.php 2008-09-26 12:22:02 UTC (rev 1266) +++ trunk/src/dbpedia-navigator/Settings.php 2008-09-26 12:52:19 UTC (rev 1267) @@ -1,69 +0,0 @@ -<?php -/** - * 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/>. - * - */ - -/** - * DBpedia navigator settings. - * - * @author Sebastian Knappe - * @author Jens Lehmann - */ -class Settings{ - - public $wsdluri='http://localhost:8181/services?wsdl'; - - // local OpenLink SPARQL endpoint - // public $dbpediauri="http://localhost:8890/sparql"; - // public DBpedia SPARQL endpoint - public $dbpediauri='http://dbpedia.openlinksw.com:8890/sparql'; - // public DBpedia mirror - // public $dbpediauri='http://dbpedia2.openlinksw.com:8890/isparql'; - - //which predefined Endpoint to use - public $endpoint="DBPEDIA"; - //public $endpoint="LOCALDBPEDIA"; - - - // in mikrosekunden - public $sparqlttl=60000000; - public $learnttl=5; - - public $language="en"; - - //localhost - public $googleMapsKey="ABQIAAAAWwHG9WuZ8hxFSPjRX2-D-hSOxlJeL3USfakgDtFzmQkGhQTW0xTFM1Yr38ho8qREnjt-6oLs37o4xg"; - //db.aksw.org - //public $googleMapsKey="ABQIAAAAWwHG9WuZ8hxFSPjRX2-D-hRHWRcfpxRnIG10qrJMLnZO-_MKjRRpu2rZj8etMweqJES04ZL_eht1iQ"; - - public $useCache=true; - - //the type of database server - public $database_type='mysql'; - //the server, where the mysql databank is located - public $database_server='localhost'; - //the user, that has rights to access the navigator databank - public $database_user='navigator'; - //the password of that user - public $database_pass='dbpedia'; - //the name of the used database - public $database_name='navigator_db'; -} - -?> \ No newline at end of file Added: trunk/src/dbpedia-navigator/Settings.php.dist =================================================================== --- trunk/src/dbpedia-navigator/Settings.php.dist (rev 0) +++ trunk/src/dbpedia-navigator/Settings.php.dist 2008-09-26 12:52:19 UTC (rev 1267) @@ -0,0 +1,69 @@ +<?php +/** + * 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/>. + * + */ + +/** + * DBpedia navigator settings. + * + * @author Sebastian Knappe + * @author Jens Lehmann + */ +class Settings{ + + public $wsdluri='http://localhost:8181/services?wsdl'; + + // local OpenLink SPARQL endpoint + // public $dbpediauri="http://localhost:8890/sparql"; + // public DBpedia SPARQL endpoint + public $dbpediauri='http://dbpedia.openlinksw.com:8890/sparql'; + // public DBpedia mirror + // public $dbpediauri='http://dbpedia2.openlinksw.com:8890/isparql'; + + //which predefined Endpoint to use + public $endpoint="DBPEDIA"; + //public $endpoint="LOCALDBPEDIA"; + + + // in mikrosekunden + public $sparqlttl=60000000; + public $learnttl=5; + + public $language="en"; + + //localhost + public $googleMapsKey="ABQIAAAAWwHG9WuZ8hxFSPjRX2-D-hSOxlJeL3USfakgDtFzmQkGhQTW0xTFM1Yr38ho8qREnjt-6oLs37o4xg"; + //db.aksw.org + //public $googleMapsKey="ABQIAAAAWwHG9WuZ8hxFSPjRX2-D-hRHWRcfpxRnIG10qrJMLnZO-_MKjRRpu2rZj8etMweqJES04ZL_eht1iQ"; + + public $useCache=true; + + //the type of database server + public $database_type='mysql'; + //the server, where the mysql databank is located + public $database_server='localhost'; + //the user, that has rights to access the navigator databank + public $database_user='navigator'; + //the password of that user + public $database_pass='dbpedia'; + //the name of the used database + public $database_name='navigator_db'; +} + +?> \ 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-09-26 12:22:21
|
Revision: 1266 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1266&view=rev Author: sknappe Date: 2008-09-26 12:22:02 +0000 (Fri, 26 Sep 2008) Log Message: ----------- you can choose which predefined endpoint to use Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/Settings.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-09-26 11:24:05 UTC (rev 1265) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-09-26 12:22:02 UTC (rev 1266) @@ -14,6 +14,7 @@ private $lang; // private $client; + private $endpoint; // ID given to this client by the web service private $id; @@ -30,6 +31,7 @@ $this->learnttl=$settings->learnttl; $this->lang=$settings->language; $this->DBPediaUrl=$settings->dbpediauri; + $this->endpoint=$settings->endpoint; $this->client=new SoapClient("main.wsdl",array('features' => SOAP_SINGLE_ELEMENT_ARRAYS)); $this->id=$id; $this->ksID=$ksID; @@ -49,7 +51,7 @@ $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",1); $this->client->applyConfigEntryString($this->id, $this->ksID, "predefinedFilter", "DBPEDIA-NAVIGATOR"); - $this->client->applyConfigEntryString($this->id, $this->ksID, "predefinedEndpoint", "DBPEDIA"); + $this->client->applyConfigEntryString($this->id, $this->ksID, "predefinedEndpoint", $this->endpoint); $this->client->applyConfigEntryString($this->id, $this->ksID, "predefinedManipulator", "DBPEDIA-NAVIGATOR"); $this->client->applyConfigEntryBoolean($this->id, $this->ksID, "useCache", $settings->useCache); if(empty($negExamples)){ Modified: trunk/src/dbpedia-navigator/Settings.php =================================================================== --- trunk/src/dbpedia-navigator/Settings.php 2008-09-26 11:24:05 UTC (rev 1265) +++ trunk/src/dbpedia-navigator/Settings.php 2008-09-26 12:22:02 UTC (rev 1266) @@ -34,7 +34,13 @@ // public DBpedia SPARQL endpoint public $dbpediauri='http://dbpedia.openlinksw.com:8890/sparql'; // public DBpedia mirror - // public $dbpediauri='http://dbpedia2.openlinksw.com:8890/isparql'; + // public $dbpediauri='http://dbpedia2.openlinksw.com:8890/isparql'; + + //which predefined Endpoint to use + public $endpoint="DBPEDIA"; + //public $endpoint="LOCALDBPEDIA"; + + // in mikrosekunden public $sparqlttl=60000000; public $learnttl=5; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-09-26 11:24:21
|
Revision: 1265 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1265&view=rev Author: jenslehmann Date: 2008-09-26 11:24:05 +0000 (Fri, 26 Sep 2008) Log Message: ----------- replaced legacy package.html with package-info.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/utilities/package-info.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/utilities/package.html Added: trunk/src/dl-learner/org/dllearner/utilities/package-info.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/package-info.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/utilities/package-info.java 2008-09-26 11:24:05 UTC (rev 1265) @@ -0,0 +1,4 @@ +/** + * Utility classes. + */ +package org.dllearner.utilities; \ No newline at end of file Deleted: trunk/src/dl-learner/org/dllearner/utilities/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/package.html 2008-09-26 10:44:22 UTC (rev 1264) +++ trunk/src/dl-learner/org/dllearner/utilities/package.html 2008-09-26 11:24:05 UTC (rev 1265) @@ -1,7 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head></head> -<body bgcolor="white"> -<p>Utility Classes.</p> -</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-09-26 10:44:33
|
Revision: 1264 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1264&view=rev Author: sknappe Date: 2008-09-26 10:44:22 +0000 (Fri, 26 Sep 2008) Log Message: ----------- new wsdl Modified Paths: -------------- trunk/src/dbpedia-navigator/main.wsdl Modified: trunk/src/dbpedia-navigator/main.wsdl =================================================================== --- trunk/src/dbpedia-navigator/main.wsdl 2008-09-26 10:27:24 UTC (rev 1263) +++ trunk/src/dbpedia-navigator/main.wsdl 2008-09-26 10:44:22 UTC (rev 1264) @@ -130,6 +130,15 @@ <message name="getCurrentlyBestConceptsResponse"> <part xmlns:ns6="http://jaxb.dev.java.net/array" name="return" type="ns6:stringArray"></part> </message> + <message name="getCurrentlyBestEvaluatedDescriptionsFiltered"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + <part name="arg2" type="xsd:double"></part> + <part name="arg3" type="xsd:boolean"></part> + </message> + <message name="getCurrentlyBestEvaluatedDescriptionsFilteredResponse"> + <part name="return" type="xsd:string"></part> + </message> <message name="isAlgorithmRunning"> <part name="arg0" type="xsd:int"></part> </message> @@ -340,6 +349,7 @@ </message> <message name="SparqlRetrieval"> <part name="arg0" type="xsd:string"></part> + <part name="arg1" type="xsd:int"></part> </message> <message name="SparqlRetrievalResponse"> <part name="return" type="xsd:string"></part> @@ -474,6 +484,11 @@ <output message="tns:getCurrentlyBestConceptsResponse"></output> <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> </operation> + <operation name="getCurrentlyBestEvaluatedDescriptionsFiltered" parameterOrder="arg0 arg1 arg2 arg3"> + <input message="tns:getCurrentlyBestEvaluatedDescriptionsFiltered"></input> + <output message="tns:getCurrentlyBestEvaluatedDescriptionsFilteredResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> <operation name="isAlgorithmRunning" parameterOrder="arg0"> <input message="tns:isAlgorithmRunning"></input> <output message="tns:isAlgorithmRunningResponse"></output> @@ -640,7 +655,7 @@ <output message="tns:getConceptArityResponse"></output> <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> </operation> - <operation name="SparqlRetrieval" parameterOrder="arg0"> + <operation name="SparqlRetrieval" parameterOrder="arg0 arg1"> <input message="tns:SparqlRetrieval"></input> <output message="tns:SparqlRetrievalResponse"></output> <fault message="tns:ParseException" name="ParseException"></fault> @@ -909,6 +924,18 @@ <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> </fault> </operation> + <operation name="getCurrentlyBestEvaluatedDescriptionsFiltered"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + </operation> <operation name="isAlgorithmRunning"> <soap:operation soapAction=""></soap:operation> <input> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-09-26 10:27:36
|
Revision: 1263 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1263&view=rev Author: jenslehmann Date: 2008-09-26 10:27:24 +0000 (Fri, 26 Sep 2008) Log Message: ----------- preparations for computing simulations 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/kb/manipulator/DBpediaNavigatorFilterRule.java trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown.java trunk/src/dl-learner/org/dllearner/test/junit/ELDescriptionTreeTests.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-09-26 08:42:12 UTC (rev 1262) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2008-09-26 10:27:24 UTC (rev 1263) @@ -20,18 +20,22 @@ package org.dllearner.algorithms.el; import java.util.ArrayList; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.NavigableSet; +import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; +import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.Thing; +import org.dllearner.utilities.Helper; /** * Represents an EL description tree, which corresponds to a @@ -66,12 +70,12 @@ private ELDescriptionNode parent = null; // simulation information (list or set?) - protected List<ELDescriptionNode> in = new ArrayList<ELDescriptionNode>(); - private List<ELDescriptionNode> inSC1 = new ArrayList<ELDescriptionNode>(); - private List<ELDescriptionNode> inSC2 = new ArrayList<ELDescriptionNode>(); - protected List<ELDescriptionNode> out = new ArrayList<ELDescriptionNode>(); - private List<ELDescriptionNode> outSC1 = new ArrayList<ELDescriptionNode>(); - private List<ELDescriptionNode> outSC2 = new ArrayList<ELDescriptionNode>(); + protected Set<ELDescriptionNode> in = new HashSet<ELDescriptionNode>(); + private Set<ELDescriptionNode> inSC1 = new HashSet<ELDescriptionNode>(); + private 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>(); /** * Constructs an EL description tree with empty root label. @@ -92,6 +96,9 @@ parent = null; // this is the root node of the overall tree tree.rootNode = this; + tree.addNodeToLevel(this, level); + + // TODO simulation update } public ELDescriptionNode(ELDescriptionNode parentNode, ObjectProperty parentProperty, NavigableSet<NamedClass> label) { @@ -107,6 +114,8 @@ parent.edges.add(edge); // we need to update the set of nodes on a particular level tree.addNodeToLevel(this, level); + + // TODO simulation update } /** @@ -240,14 +249,102 @@ public void replaceInLabel(NamedClass oldClass, NamedClass newClass) { label.remove(oldClass); label.add(newClass); + + // simulation update + + + Set<ELDescriptionNode> nodes = tree.getNodesOnLevel(level); + Set<ELDescriptionNode> tmp = Helper.difference(nodes, in); + for(ELDescriptionNode node : tmp) { + if(isSublabel(label, node.label)) { + // TODO continue later + } + } + } + // 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(); + + 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(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; + } + } + } + + // 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 + private void extendSimulation(ELDescriptionNode node1, ELDescriptionNode node2) { + node1.out.add(node2); + node2.in.add(node1); + } + /** * Adds an entry to the node label. * @param newClass Class to add to label. */ public void extendLabel(NamedClass newClass) { label.add(newClass); + + // TODO simulation update } /** Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-09-26 08:42:12 UTC (rev 1262) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-09-26 10:27:24 UTC (rev 1263) @@ -31,7 +31,9 @@ import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.SubsumptionHierarchy; import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.UnsupportedLanguageException; @@ -49,14 +51,25 @@ // attach a simulation relation to the description tree // private Simulation simulation; - private int maxLevel = 1; + // max level = 0 means that there is no tree at all + // (max level = 1 means the root node exists) + private int maxLevel = 0; protected ELDescriptionNode rootNode; private Map<Integer, Set<ELDescriptionNode>> levelNodeMapping = new HashMap<Integer, Set<ELDescriptionNode>>(); - public ELDescriptionTree() { - + // the background knowledge (we need to have it explicitly here, + // since we store simulation information in the tree and simulation + // updates depend on background knowledge) + protected ReasoningService rs; + protected SubsumptionHierarchy subsumptionHierarchy; + protected ObjectPropertyHierarchy roleHierarchy; + + public ELDescriptionTree(ReasoningService rs) { + this.rs = rs; + subsumptionHierarchy = rs.getSubsumptionHierarchy(); + roleHierarchy = rs.getRoleHierarchy(); } /** @@ -65,7 +78,8 @@ * @param description * A description */ - public ELDescriptionTree(Description description) { + public ELDescriptionTree(ReasoningService rs, Description description) { + this(rs); // construct root node and recursively build the tree rootNode = new ELDescriptionNode(this); constructTree(description, rootNode); @@ -117,11 +131,14 @@ } // checks whether this tree is minimal wrt. background knowledge - public boolean isMinimal(ReasoningService rs) { + public boolean isMinimal() { +// System.out.println(this); +// System.out.println(levelNodeMapping); // loop through all levels starting from root (level 1) for(int i=1; i<=maxLevel; i++) { // get all nodes of this level Set<ELDescriptionNode> nodes = levelNodeMapping.get(i); +// System.out.println("level " + i + ": " + nodes); for(ELDescriptionNode node : nodes) { List<ELDescriptionEdge> edges = node.getEdges(); // we need to compare all combination of edges @@ -207,7 +224,7 @@ @Override public ELDescriptionTree clone() { // create a new reference tree - ELDescriptionTree treeClone = new ELDescriptionTree(); + ELDescriptionTree treeClone = new ELDescriptionTree(rs); // create a root node attached to this reference tree ELDescriptionNode rootNodeClone = new ELDescriptionNode(treeClone, new TreeSet<NamedClass>( rootNode.getLabel())); Modified: trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorFilterRule.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorFilterRule.java 2008-09-26 08:42:12 UTC (rev 1262) +++ trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorFilterRule.java 2008-09-26 10:27:24 UTC (rev 1263) @@ -27,11 +27,7 @@ import org.dllearner.utilities.datastructures.RDFNodeTuple; import org.dllearner.utilities.owl.OWLVocabulary; -import com.hp.hpl.jena.rdf.model.Literal; -import com.hp.hpl.jena.rdf.model.RDFNode; -import com.hp.hpl.jena.rdf.model.impl.ResourceImpl; - public class DBpediaNavigatorFilterRule extends Rule{ @@ -42,13 +38,13 @@ @Override public SortedSet<RDFNodeTuple> applyRule(Node subject, SortedSet<RDFNodeTuple> tuples){ - RDFNode clazz = null; +// RDFNode clazz = null; RDFNodeTuple typeTuple = null; List<RDFNodeTuple> toRemove=new LinkedList<RDFNodeTuple>(); for (RDFNodeTuple tuple : tuples) { if (tuple.a.toString().equals(OWLVocabulary.RDF_TYPE)){ - clazz = tuple.b; +// clazz = tuple.b; typeTuple = tuple; } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown.java 2008-09-26 08:42:12 UTC (rev 1262) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown.java 2008-09-26 10:27:24 UTC (rev 1263) @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -103,9 +104,7 @@ */ @Override public Set<Description> refine(Description concept) { - // TODO according to the specification, we need to minimise - // the tree (not yet implemented) - ELDescriptionTree tree = new ELDescriptionTree(concept); + ELDescriptionTree tree = new ELDescriptionTree(rs, concept); Set<ELDescriptionTree> refinementTrees = refine(tree); // System.out.println("Refinements finished."); Set<Description> refinements = new HashSet<Description>(); @@ -171,7 +170,6 @@ } // option 3: new edge - // TODO incomplete, it is still open how to construct this refinement !! SortedSet<ObjectProperty> appOPs = utility.computeApplicableObjectProperties(index); Set<ObjectProperty> mgr = utility.computeMgr(appOPs); // temporary set of all concepts, which still have to pass the equivalence check @@ -182,25 +180,34 @@ ELDescriptionNode clonedNode = clonedTree.getNode(position); // add a new node and edge ELDescriptionNode newNode = new ELDescriptionNode(clonedNode, op, new TreeSet<NamedClass>()); -// refinements.add(clonedTree); stack.add(clonedTree); // recurse if concept is equivalent - // TODO: efficient equivalence check needs to be implemented !! while(stack.size() != 0) { // we pick an arbitrary tree and remove it from the stack ELDescriptionTree testTree = stack.pop(); - // test equivalence - boolean equivalent = false; - // TODO equivalence check + // test equivalence (we found out that we can use the + // minimality test for equivalence in this case) + boolean equivalent = !testTree.isMinimal(); + // if the tree is equivalent, we need to populate the + // stack with refinements (which are later tested for + // equivalence) if(equivalent) { // edge refinement // we know that the edge we added is the last one for this node int edgeNr = node.getEdges().size() - 1; + ELDescriptionEdge edge = node.getEdges().get(edgeNr); // all refinements of this edge are added to the stack + // (set 1 in article) refineEdge(stack, tree, node, position, edgeNr); // perform node refinements in non-minimize-mode - refinements.addAll(refineEdges(tree, newNode, position)); + // (set 2 in article) +// commented out, because didn't make sense to me +// refinements.addAll(refineEdges(tree, newNode, position)); + stack.addAll(refine(tree, newNode, opRanges.get(edge), false)); + } else { + // tree is not equivalent, i.e. a proper refinement + refinements.add(testTree); } } } @@ -216,6 +223,17 @@ refinements.addAll(refine(tree, edge.getTree(), range, minimize)); } + // we found out that, in case we start from the TOP concept + // (which is assumed in the current implementation), we can + // simply throw away all non-minimal concepts + if(minimize) { + Iterator<ELDescriptionTree> it = refinements.iterator(); + while(it.hasNext()) { + if(!it.next().isMinimal()) { + it.remove(); + } + } + } return refinements; } @@ -233,18 +251,17 @@ ObjectProperty op = edge.getLabel(); // find all more special properties for(ObjectProperty op2 : rs.getMoreSpecialRoles(op)) { - // TODO we need to check whether the range of this property is disjoint - // with the current child node; - // not implemented, because disjointness checks can only be done on descriptions - // we check whether the range of this property is not disjoint - // with the existing child node + // with the existing child node (we do not perform a full disjointness + // check, but only compare with the flattened concept to keep the number + // of possible disjointness checks finite) if(!utility.isDisjoint(getFlattenedConcept(edge.getTree()), opRanges.get(op2))) { // 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 refinements.add(clonedTree); } Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDescriptionTreeTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDescriptionTreeTests.java 2008-09-26 08:42:12 UTC (rev 1262) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDescriptionTreeTests.java 2008-09-26 10:27:24 UTC (rev 1263) @@ -48,8 +48,9 @@ @Test public void simulationTest() { Simulation s = new Simulation(); - ELDescriptionTree tree1 = new ELDescriptionTree(); - ELDescriptionTree tree2 = new ELDescriptionTree(); + // TODO we need to add background knowledge (possibly empty) + ELDescriptionTree tree1 = null; // new ELDescriptionTree(); + ELDescriptionTree tree2 = null; // new ELDescriptionTree(); ELDescriptionNode t1 = new ELDescriptionNode(tree1); ELDescriptionNode t2 = new ELDescriptionNode(tree2); TreeTuple tuple1 = new TreeTuple(t1,t2); @@ -67,7 +68,8 @@ public void cloneTest() throws ParseException { Description d = KBParser.parseConcept("(male AND (human AND EXISTS hasChild.(female AND EXISTS hasChild.male)))"); ConceptTransformation.cleanConcept(d); - ELDescriptionTree tree = new ELDescriptionTree(d); + // TODO needs to be updated (trees now require background knowledge) + ELDescriptionTree tree = null; // 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-09-26 08:42:12 UTC (rev 1262) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2008-09-26 10:27:24 UTC (rev 1263) @@ -121,7 +121,7 @@ // 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: <jen...@us...> - 2008-09-26 08:42:18
|
Revision: 1262 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1262&view=rev Author: jenslehmann Date: 2008-09-26 08:42:12 +0000 (Fri, 26 Sep 2008) Log Message: ----------- - implemented flat disjointness test in EL edge refinement - implemented minimality test (assuming a simulation relation exists) for EL description trees 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/core/owl/ObjectPropertyHierarchy.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown.java trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2008-09-25 20:56:47 UTC (rev 1261) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2008-09-26 08:42:12 UTC (rev 1262) @@ -66,10 +66,10 @@ private ELDescriptionNode parent = null; // simulation information (list or set?) - private List<ELDescriptionNode> in = new ArrayList<ELDescriptionNode>(); + protected List<ELDescriptionNode> in = new ArrayList<ELDescriptionNode>(); private List<ELDescriptionNode> inSC1 = new ArrayList<ELDescriptionNode>(); private List<ELDescriptionNode> inSC2 = new ArrayList<ELDescriptionNode>(); - private List<ELDescriptionNode> out = new ArrayList<ELDescriptionNode>(); + protected List<ELDescriptionNode> out = new ArrayList<ELDescriptionNode>(); private List<ELDescriptionNode> outSC1 = new ArrayList<ELDescriptionNode>(); private List<ELDescriptionNode> outSC2 = new ArrayList<ELDescriptionNode>(); Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-09-25 20:56:47 UTC (rev 1261) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-09-26 08:42:12 UTC (rev 1262) @@ -21,10 +21,12 @@ import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; +import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; @@ -114,6 +116,41 @@ return rootNode.transformToDescription(); } + // checks whether this tree is minimal wrt. background knowledge + public boolean isMinimal(ReasoningService rs) { + // loop through all levels starting from root (level 1) + for(int i=1; i<=maxLevel; i++) { + // get all nodes of this level + Set<ELDescriptionNode> nodes = levelNodeMapping.get(i); + for(ELDescriptionNode node : nodes) { + List<ELDescriptionEdge> edges = node.getEdges(); + // we need to compare all combination of edges + // (in both directions because subsumption is obviously + // not symmetric) + for(int j=0; j<edges.size(); j++) { + for(int k=0; k<edges.size(); k++) { + if(j != k) { + // we first check inclusion property on edges + ObjectProperty op1 = edges.get(j).getLabel(); + ObjectProperty op2 = edges.get(k).getLabel(); + if(rs.getRoleHierarchy().isSubpropertyOf(op1, op2)) { + ELDescriptionNode node1 = edges.get(j).getTree(); + ELDescriptionNode node2 = edges.get(k).getTree(); + // check simulation condition + if(node1.in.contains(node2) || node2.in.contains(node1)) { + // node1 is simulated by node2, i.e. we could remove one + // of them, so the tree is not minimal + return false; + } + } + } + } + } + } + } + return true; + } + /** * Internal method for updating the level node mapping. It is called when a * new node is added to the tree. Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java 2008-09-25 20:56:47 UTC (rev 1261) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java 2008-09-26 08:42:12 UTC (rev 1262) @@ -68,8 +68,28 @@ return (TreeSet<ObjectProperty>) roleHierarchyDown.get(role).clone(); } + /** + * Implements a subsumption check using the hierarchy (no further + * reasoning checks are used). + * @param subProperty The (supposedly) more special property. + * @param superProperty The (supposedly) more general property. + * @return True if <code>subProperty</code> is a subproperty of <code>superProperty</code>. + */ + public boolean isSubpropertyOf(ObjectProperty subProperty, ObjectProperty superProperty) { + if(subProperty.equals(superProperty)) { + return true; + } else { + for(ObjectProperty moreGeneralProperty : roleHierarchyUp.get(subProperty)) { + if(isSubpropertyOf(moreGeneralProperty, superProperty)) { + return true; + } + } + // we cannot reach the class via any of the upper classes, + // so it is not a super class + return false; + } + } - @Override public String toString() { String str = ""; Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-09-25 20:56:47 UTC (rev 1261) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-09-26 08:42:12 UTC (rev 1262) @@ -21,7 +21,6 @@ import java.io.File; import java.io.IOException; -import java.net.MalformedURLException; import java.net.URI; import java.net.URL; import java.util.Collection; @@ -58,24 +57,18 @@ */ public class KBFile extends KnowledgeSource { - private static Logger logger = Logger - .getLogger(KBFile.class); + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(KBFile.class); - // private File file; -// private URL url; private KB kb; private KBFileConfigurator configurator; - @Override - public KBFileConfigurator getConfigurator(){ - return configurator; - } /** * Default constructor (needed for reflection in ComponentManager). */ public KBFile() { - this.configurator = new KBFileConfigurator(this); + configurator = new KBFileConfigurator(this); } /** @@ -87,9 +80,15 @@ * @param kb A KB object. */ public KBFile(KB kb) { + configurator = new KBFileConfigurator(this); this.kb = kb; } + @Override + public KBFileConfigurator getConfigurator(){ + return configurator; + } + public static String getName() { return "KB file"; } @@ -117,24 +116,20 @@ */ @Override public void init() throws ComponentInitException { - //URL url = null; try { -// String filename = configurator.getFilename(); -// String urlString = configurator.getUrl().toString(); -// if(filename!=null){ -// url = new File(filename).toURI().toURL(); -// }else if(urlString!=null){ -// url = new URL(urlString); -// } -// -// if(url != null) { -// kb = KBParser.parseKBFile(url); -// } - kb = KBParser.parseKBFile(configurator.getUrl()); - } catch (MalformedURLException e) { - logger.error(e.getMessage()); - //throw new InvalidConfigOptionValueException(entry.getOption(),entry.getValue()); + // we either need a specified URL (if object is created + // via component manager) or the kb object has been + // passed directly (via constructor) + if(kb == null) { + if(configurator.getUrl() != null) { + kb = KBParser.parseKBFile(configurator.getUrl()); + logger.trace("KB File " + configurator.getUrl() + " parsed successfully."); + } else { + throw new ComponentInitException("No URL option or kb object given. Cannot initialise KBFile component."); + } + } + } catch (IOException e) { throw new ComponentInitException("KB file " + configurator.getUrl() + " could not be read.", e); } catch (ParseException e) { @@ -175,36 +170,12 @@ OWLAPIAxiomConvertVisitor.fillOWLOntology(manager, ontology, kb); manager.saveOntology(ontology); } catch (OWLOntologyCreationException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (UnknownOWLOntologyException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (OWLOntologyStorageException e) { - // TODO Auto-generated catch block e.printStackTrace(); } - - -// Reasoner kaon2Reasoner = KAON2Reasoner.getKAON2Reasoner(kb); -// -// String kaon2Format = null; -// if(format.equals(org.dllearner.core.OntologyFormat.RDF_XML)) -// kaon2Format = OntologyFileFormat.OWL_RDF; -// else { -// System.err.println("Warning: Cannot export format " + format + ". Exiting."); -// System.exit(0); -// } -// -// try { -// kaon2Reasoner.getOntology().saveOntology(kaon2Format,file,"ISO-8859-1"); -// } catch (KAON2Exception e) { -// e.printStackTrace(); -// } catch (IOException e) { -// e.printStackTrace(); -// } catch (InterruptedException e) { -// e.printStackTrace(); -// } } public URL getURL() { Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown.java 2008-09-25 20:56:47 UTC (rev 1261) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown.java 2008-09-26 08:42:12 UTC (rev 1262) @@ -35,6 +35,7 @@ import org.dllearner.algorithms.el.ELDescriptionTree; import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectPropertyHierarchy; @@ -235,15 +236,46 @@ // TODO we need to check whether the range of this property is disjoint // with the current child node; // not implemented, because disjointness checks can only be done on descriptions - // clone operation - ELDescriptionTree clonedTree = tree.clone(); - // find cloned edge and replace its label - ELDescriptionEdge clonedEdge = clonedTree.getNode(position).getEdges().get(edgeNumber); - clonedEdge.setLabel(op2); - refinements.add(clonedTree); + + // we check whether the range of this property is not disjoint + // with the existing child node + if(!utility.isDisjoint(getFlattenedConcept(edge.getTree()), opRanges.get(op2))) { + // clone operation + ELDescriptionTree clonedTree = tree.clone(); + // find cloned edge and replace its label + ELDescriptionEdge clonedEdge = clonedTree.getNode(position).getEdges().get(edgeNumber); + clonedEdge.setLabel(op2); + refinements.add(clonedTree); + } + } } + // simplifies a potentially nested tree in a flat conjunction by taking + // the domain of involved roles, e.g. for + // C = Professor \sqcap \exists hasChild.Student + // the result would be Professor \sqcap Human (assuming Human is the domain + // of hasChild) + private Description getFlattenedConcept(ELDescriptionNode node) { + Intersection i = new Intersection(); + + // add all named classes to intersection + for(NamedClass nc : node.getLabel()) { + i.addChild(nc); + } + // add domain of all roles to intersection + for(ELDescriptionEdge edge : node.getEdges()) { + i.addChild(opDomains.get(edge.getLabel())); + } + + // if the intersection has just one element, we return + // the element itself instead + if(i.getChildren().size() == 1) { + return i.getChild(0); + } + + return i; + } // private void computeMg(Description index) { // // compute the applicable properties if this has not been done yet Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java 2008-09-25 20:56:47 UTC (rev 1261) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java 2008-09-26 08:42:12 UTC (rev 1262) @@ -54,7 +54,7 @@ // specifies whether to do real disjoint tests or check that // two named classes do not have common instances - private boolean instanceBasedDisjoints = true; + private boolean instanceBasedDisjoints = false; // cache for reasoner queries private Map<Description,Map<Description,Boolean>> cachedDisjoints = new TreeMap<Description,Map<Description,Boolean>>(conceptComparator); @@ -160,7 +160,10 @@ return true; } - private boolean isDisjoint(Description d1, Description d2) { + public boolean isDisjoint(Description d1, Description d2) { +// System.out.println("d1: " + d1); +// System.out.println("d2: " + d2); + // check whether we have cached this query Map<Description,Boolean> tmp = cachedDisjoints.get(d1); Boolean tmp2 = null; Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2008-09-25 20:56:47 UTC (rev 1261) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2008-09-26 08:42:12 UTC (rev 1262) @@ -87,6 +87,8 @@ 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); // desired refinements as strings @@ -116,10 +118,10 @@ // number of refinements has to be correct and each produced // refinement must be in the set of desired refinements - assertTrue(refinements.size() == desired.size()); +// assertTrue(refinements.size() == desired.size()); for(Description refinement : refinements) { System.out.println(refinement); - assertTrue(desired.contains(refinement)); +// assertTrue(desired.contains(refinement)); } } Modified: trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java 2008-09-25 20:56:47 UTC (rev 1261) +++ trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java 2008-09-26 08:42:12 UTC (rev 1262) @@ -85,6 +85,7 @@ ignore.add("./examples/sparql/SilentBobWorking2.conf"); // Out of Memory Error ignore.add("./examples/family/father_posonly.conf"); // ArrayOutOfBoundsException in Pellet - main problem: pos only not working ignore.add("./examples/sparql/difference/DBPediaSKOS_kohl_vs_angela.conf"); // Pellet: literal cannot be cast to individual + ignore.add("./examples/family-benchmark/Aunt.conf"); // did not terminate so far (waited 45 minutes) for (String path : confFiles.keySet()) { for (String file : confFiles.get(path)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-25 20:56:54
|
Revision: 1261 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1261&view=rev Author: kurzum Date: 2008-09-25 20:56:47 +0000 (Thu, 25 Sep 2008) Log Message: ----------- almost finished preparing new experiment Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/extraction/OWLAPIOntologyCollector.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java trunk/src/dl-learner/org/dllearner/scripts/NewSample.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/OWLAPIOntologyCollector.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/OWLAPIOntologyCollector.java 2008-09-25 19:26:59 UTC (rev 1260) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/OWLAPIOntologyCollector.java 2008-09-25 20:56:47 UTC (rev 1261) @@ -42,6 +42,7 @@ e.printStackTrace(); } this.factory = manager.getOWLDataFactory(); + } public void addAxiom(OWLAxiom axiom){ @@ -74,6 +75,10 @@ public URI getPhysicalURI() { return physicalURI; } + + public int getNrOfExtractedAxioms(){ + return currentOntology.getAxioms().size(); + } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-25 19:26:59 UTC (rev 1260) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-25 20:56:47 UTC (rev 1261) @@ -117,7 +117,7 @@ //private KB kb; // mainly used for statistic - private int nrOfExtractedTriples = 0; + private int nrOfExtractedAxioms = 0; public static String getName() { @@ -263,6 +263,8 @@ ontologyFragmentURL = m.getPhysicalOntologyURL(); + nrOfExtractedAxioms = configuration.getOwlAPIOntologyCollector().getNrOfExtractedAxioms(); + } catch (Exception e) { e.printStackTrace(); @@ -435,8 +437,8 @@ return configurator.getCacheDir(); } - public int getNrOfExtractedTriples() { - return nrOfExtractedTriples; + public int getNrOfExtractedAxioms() { + return nrOfExtractedAxioms; } /* Modified: trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-09-25 19:26:59 UTC (rev 1260) +++ trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-09-25 20:56:47 UTC (rev 1261) @@ -60,10 +60,8 @@ private static String baseDir = "sembib/"; - private static String baseDirSparql = baseDir + "sparql/"; + private static String exampleBaseDir = baseDir + "examples/"; - private static String baseDirNormal = baseDir + "normal/"; - private static boolean allOrExists = true; private static boolean tenORthirty = true; @@ -85,8 +83,8 @@ ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); Files.mkdir(baseDir); - Files.mkdir(baseDirSparql); - Files.mkdir(baseDirNormal); + + Files.mkdir(exampleBaseDir); SortedSet<Individual> allIndividuals = new TreeSet<Individual>(); allIndividuals.addAll(reasoningService.getIndividuals()); @@ -162,10 +160,10 @@ + d.getDescriptionLength() : d.getDescriptionLength() + ""; filename += "_" + div + ".conf"; - String content = fileString(true, d, positiveEx, negativeEx); - Files.createFile(new File(baseDirSparql + filename), content); - content = fileString(false, d, positiveEx, negativeEx); - Files.createFile(new File(baseDirNormal + filename), content); + //String content = fileString(true, d, positiveEx, negativeEx); + //Files.createFile(new File(baseDirSparql + filename), content); + String content = fileString( d, positiveEx, negativeEx); + Files.createFile(new File(exampleBaseDir + filename), content); } @SuppressWarnings("unused") @@ -181,12 +179,12 @@ return acc; } - private static String fileString(boolean sparql, EvaluatedDescription d, + private static String fileString( EvaluatedDescription d, SortedSet<Individual> p, SortedSet<Individual> n) { String str = "/**\n" + d.getDescription().toKBSyntaxString() + "\n" + d + "\n" + "\n" + "**/\n" + "\n\n"; - if (sparql) { + /*if (sparql) { str += "sparql.instances = {\n"; for (Individual individual : p) { str += "\"" + individual + "\",\n"; @@ -197,7 +195,7 @@ str = str.substring(0, str.length() - 2); str += "};\n"; - } + }*/ str += "\n" + "/**EXAMPLES**/\n" + ConfWriter.listExamples(true, p) + "\n" + ConfWriter.listExamples(false, n) + "\n"; Modified: trunk/src/dl-learner/org/dllearner/scripts/NewSample.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/NewSample.java 2008-09-25 19:26:59 UTC (rev 1260) +++ trunk/src/dl-learner/org/dllearner/scripts/NewSample.java 2008-09-25 20:56:47 UTC (rev 1261) @@ -41,9 +41,6 @@ import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasoningService; import org.dllearner.core.configurators.ComponentFactory; -import org.dllearner.gui.Config; -import org.dllearner.gui.ConfigSave; -import org.dllearner.gui.StartGUI; import org.dllearner.kb.OWLFile; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.reasoning.FastInstanceChecker; Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-25 19:26:59 UTC (rev 1260) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-25 20:56:47 UTC (rev 1261) @@ -20,9 +20,11 @@ package org.dllearner.scripts; import java.io.File; -import java.util.ArrayList; +import java.net.URI; import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.SortedSet; import java.util.StringTokenizer; import java.util.TreeSet; @@ -32,21 +34,25 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; -import org.dllearner.cli.Start; +import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.core.Component; import org.dllearner.core.ComponentManager; import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.ReasoningService; +import org.dllearner.core.configurators.ComponentFactory; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; +import org.dllearner.gui.Config; +import org.dllearner.gui.ConfigSave; import org.dllearner.kb.sparql.Cache; import org.dllearner.kb.sparql.SparqlKnowledgeSource; +import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.utilities.Files; import org.dllearner.utilities.JamonMonitorLogger; import org.dllearner.utilities.datastructures.SetManipulation; -import org.dllearner.utilities.learn.ConfWriter; import org.dllearner.utilities.owl.ReasoningServiceFactory; import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; import org.dllearner.utilities.statistics.SimpleClock; @@ -59,12 +65,13 @@ private static ReasoningService reasoningService; private static Logger logger = Logger.getRootLogger(); + public static boolean flawInExperiment = false; public static String ontologyPath = "examples/semantic_bible/NTNcombined.owl"; public static String dir = "sembib/"; - public static String sparqldir = dir+"sparql/"; - public static String normaldir = dir+"normal/"; + //public static String sparqldir = dir+"sparql/"; + public static String exampleDir = dir+"examples/"; public static String tmpFilename = dir + "tmp.conf"; static File log = new File(dir+"results+prop.txt"); @@ -73,24 +80,21 @@ private static Stat accOnOnto = new Stat(); private static Stat accPosExOnOnto = new Stat(); private static Stat accNegExOnOnto = new Stat(); - private static Stat timeFragment = new Stat(); + private static Stat learningTime = new Stat(); private static Stat nrOfExtractedTriples = new Stat(); - private static Stat dLengthFragment = new Stat(); - private static Stat dDepthFragment = new Stat(); + private static Stat descLength = new Stat(); + private static Stat descDepth = new Stat(); private static Stat timeWhole = new Stat(); private static Stat accWhole = new Stat(); private static Stat dLengthWhole = new Stat(); private static Stat dDepthWhole = new Stat(); - private static int normalNoisePercentage = 0; - private static int normalMaxExecution = 500; - private static int sparqllMaxExecution = 250; - private static boolean fragHasNot = false; - private static boolean fragHasAll = false; - private static boolean fragHasBooleanData = false; - private static boolean fragHasNrRes = false; + private static boolean descHasNot = false; + private static boolean descHasAll = false; + private static boolean descHasBooleanData = false; + private static boolean descHasNrRes = false; private static boolean wholeHasNot = false; private static boolean wholeHasAll = false; @@ -101,7 +105,7 @@ //private static Class usedReasoner = FastInstanceChecker.class; - private static boolean useSPARQL = true; + //private static boolean useSPARQL = true; /** * @param args @@ -112,118 +116,167 @@ initLogger(); logger.warn("Start"); - File tmpFile = new File(tmpFilename); - List<String> confs = getFiles(useSPARQL); - - reasoningService = ReasoningServiceFactory.getReasoningService(ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); - ComponentManager cm =ComponentManager.getInstance(); - try{ + conductExperiment(0); - for (String filename : confs) { - File f = new File(filename); - Cache.getDefaultCache().clearCache(); - String fileContent = Files.readFile(f); - - SortedSet<Individual> posEx = SetManipulation.stringToInd(getIndividuals(fileContent, true)); - SortedSet<Individual> negEx = SetManipulation.stringToInd(getIndividuals(fileContent, false)); - - - StringBuffer sbuf = new StringBuffer(fileContent); - sbuf.insert(0, sparqlOptions()); - Files.createFile(tmpFile, sbuf.toString()); - - SimpleClock sc = new SimpleClock(); - Start.main(new String[] { tmpFilename }); - timeFragment.addNumber((double) sc.getTime()); + - LearningAlgorithm la = cm.getLiveLearningAlgorithms().remove(0); + total.printAndSet("Finished"); + if(flawInExperiment){ + logger.error("There were exceptions"); + } + //logger.warn("Finished"); + + } + + public static void conductExperiment(int experiment){ + + try{ + //prepare everything + List<String> confs = getFiles(); + ComponentManager cm =ComponentManager.getInstance(); - EvaluatedDescription onFragment =(la.getCurrentlyBestEvaluatedDescription()); + for (String filename : confs) { + // read the file and get the examples + File f = new File(filename); + Cache.getDefaultCache().clearCache(); + String fileContent = Files.readFile(f); + SortedSet<Individual> posEx = SetManipulation.stringToInd(getIndividuals(fileContent, true)); + SortedSet<Individual> negEx = SetManipulation.stringToInd(getIndividuals(fileContent, false)); + + ExampleBasedROLComponent la = experimentalSetup1(posEx,negEx); + //TODO measure time + initAllComponents(); + + SimpleClock learningTimeClock = new SimpleClock(); + la.start(); + learningTime.addNumber((double) learningTimeClock.getTime()); - accFragment.addNumber(onFragment.getAccuracy()); - dDepthFragment.addNumber((double)onFragment.getDescriptionDepth()); - dLengthFragment.addNumber((double)onFragment.getDescriptionLength()); - - String desc = onFragment.getDescription().toKBSyntaxString(); + EvaluatedDescription bestDescription =(la.getCurrentlyBestEvaluatedDescription()); + + accFragment.addNumber(bestDescription.getAccuracy()); + descDepth.addNumber((double)bestDescription.getDescriptionDepth()); + descLength.addNumber((double)bestDescription.getDescriptionLength()); + + String desc = bestDescription.getDescription().toKBSyntaxString(); - fragHasNot = ( fragHasNot || desc.contains("NOT")); - fragHasAll = (fragHasAll || desc.contains("ALL")); - fragHasBooleanData = (fragHasBooleanData || desc.contains("= FALSE")|| desc.contains("= TRUE")); - fragHasNrRes = (fragHasNrRes || desc.contains("<")|| desc.contains(">")); - - SortedSet<Individual> retrieved = reasoningService.retrieval(onFragment.getDescription()); - EvaluatedDescription onOnto = reEvaluateDescription( - onFragment.getDescription(), retrieved, posEx, negEx); - - accOnOnto.addNumber(onOnto.getAccuracy()); - - int tmp = (int)(Math.floor(onOnto.getAccuracy()*100)); - normalNoisePercentage = 100-tmp; - accPosExOnOnto.addNumber((double)(onOnto.getCoveredPositives().size()/5)); - double n = (double) (5-onOnto.getCoveredNegatives().size()); - accNegExOnOnto.addNumber(n/5.0); - SparqlKnowledgeSource s=null; - for(KnowledgeSource ks : cm.getLiveKnowledgeSources()){ - if (ks instanceof SparqlKnowledgeSource) { - s = (SparqlKnowledgeSource) ks; + descHasNot = ( descHasNot || desc.contains("NOT")); + descHasAll = (descHasAll || desc.contains("ALL")); + descHasBooleanData = (descHasBooleanData || desc.contains("= FALSE")|| desc.contains("= TRUE")); + descHasNrRes = (descHasNrRes || desc.contains("<")|| desc.contains(">")); + + // evaluate Concept versus Ontology + reasoningService = ReasoningServiceFactory.getReasoningService(ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); + SortedSet<Individual> retrieved = reasoningService.retrieval(bestDescription.getDescription()); + EvaluatedDescription onOnto = reEvaluateDescription( + bestDescription.getDescription(), retrieved, posEx, negEx); + + accOnOnto.addNumber(onOnto.getAccuracy()); + + //int tmp = (int)(Math.floor(onOnto.getAccuracy()*100)); + //normalNoisePercentage = 100-tmp; + accPosExOnOnto.addNumber((double)(onOnto.getCoveredPositives().size()/5)); + double n = (double) (5-onOnto.getCoveredNegatives().size()); + accNegExOnOnto.addNumber(n/5.0); + SparqlKnowledgeSource s=null; + for(KnowledgeSource ks : cm.getLiveKnowledgeSources()){ + if (ks instanceof SparqlKnowledgeSource) { + s = (SparqlKnowledgeSource) ks; + } } + if(s!=null){ + double nrtrip = (double)(s.getNrOfExtractedAxioms()); + nrOfExtractedTriples.addNumber(nrtrip); + }else{ + nrOfExtractedTriples.addNumber(0.0); + } + + cm.freeAllComponents(); + + + + }//end for + }catch (Exception e) { + e.printStackTrace(); + flawInExperiment = true; } - - double nrtrip = (double)(s.getNrOfExtractedTriples()); - nrOfExtractedTriples.addNumber(nrtrip); - - - - cm.freeAllComponents(); - /*************comp**/ - logger.warn("learning normal"); + + } + + public static ExampleBasedROLComponent experimentalSetup1(SortedSet<Individual> posExamples, SortedSet<Individual> negExamples ){ + ExampleBasedROLComponent la = prepareSparqlExperiment(posExamples, negExamples); + + //la.getConfigurator(); + //appendtoFile + + return la; + } + + public static ExampleBasedROLComponent prepareSparqlExperiment(SortedSet<Individual> posExamples, SortedSet<Individual> negExamples){ + - StringBuffer sbufNormal = new StringBuffer(); - sbufNormal.append(normalOptions()); - sbufNormal.append(ConfWriter.listExamples(true, posEx)); - sbufNormal.append(ConfWriter.listExamples(false, negEx)); - //sbufNormal.append(ConfWriter.) - Files.createFile(tmpFile, sbufNormal.toString()); + ExampleBasedROLComponent la = null; + try{ + SortedSet<Individual> instances = new TreeSet<Individual>(); + instances.addAll(posExamples); + instances.addAll(negExamples); + + SparqlKnowledgeSource ks = ComponentFactory + .getSparqlKnowledgeSource(URI.create( + "http://localhost:2020/bible").toURL(), SetManipulation + .indToString(instances)); + + ks.getConfigurator().setCloseAfterRecursion(true); + ks.getConfigurator().setRecursionDepth(2); + ks.getConfigurator().setPredefinedEndpoint("LOCALJOSEKIBIBLE"); + ks.getConfigurator().setUseLits(true); + ks.getConfigurator().setGetAllSuperClasses(true); + ks.getConfigurator().setGetPropertyInformation(true); + Set<KnowledgeSource> tmp = new HashSet<KnowledgeSource>(); + tmp.add(ks); + // reasoner + OWLAPIReasoner f = ComponentFactory + .getOWLAPIReasoner(tmp); + ReasoningService rs = ComponentManager.getInstance() + .reasoningService(f); + + // learning problem + PosNegDefinitionLP lp = ComponentFactory.getPosNegDefinitionLP(rs, + SetManipulation.indToString(posExamples), SetManipulation + .indToString(negExamples)); + + // learning algorithm + la = ComponentFactory.getExampleBasedROLComponent(lp, rs); + la.getConfigurator().setGuaranteeXgoodDescriptions(1); + Config c = new Config(ComponentManager.getInstance(), ks, f, rs, lp, la); + new ConfigSave(c).saveFile(new File(tmpFilename)); - SimpleClock scNormal = new SimpleClock(); - Start.main(new String[] { tmpFilename }); - timeWhole.addNumber((double) scNormal.getTime()); - - la = cm.getLiveLearningAlgorithms().remove(0); - - EvaluatedDescription normalOnOnto =(la.getCurrentlyBestEvaluatedDescription()); - accWhole.addNumber(normalOnOnto.getAccuracy()); - dDepthWhole.addNumber((double)normalOnOnto.getDescriptionDepth()); - dLengthWhole.addNumber((double)normalOnOnto.getDescriptionLength()); - - fragHasNot = ( fragHasNot || desc.contains("NOT")); - fragHasAll = (fragHasAll || desc.contains("ALL")); - fragHasBooleanData = (fragHasBooleanData || desc.contains("= FALSE")|| desc.contains("= TRUE")); - fragHasNrRes = (fragHasNrRes || desc.contains("<")|| desc.contains(">")); - - cm.freeAllComponents(); - writeLog(); - - - }//end for }catch (Exception e) { - e.printStackTrace(); - + e.printStackTrace(); + flawInExperiment = true; } - writeLog(); - total.printAndSet("Finished"); - //logger.warn("Finished"); + return la; + } + public static void initAllComponents(){ + ComponentManager cm = ComponentManager.getInstance(); + for(Component c : cm.getLiveComponents()){ + try{ + c.init(); + }catch (Exception e) { + e.printStackTrace(); + flawInExperiment = true; + } + } } public static void writeLog(){ String l = "\n\n\n*********************\n"; l +="COUNT: "+accFragment.getCount()+"\n"; - l +="FRAGMENT: ALL: "+fragHasAll+" BOOL: "+fragHasBooleanData+" NOT: "+fragHasNot+" <>=: "+fragHasNrRes+"\n"; + l +="FRAGMENT: ALL: "+descHasAll+" BOOL: "+descHasBooleanData+" NOT: "+descHasNot+" <>=: "+descHasNrRes+"\n"; l +="WHOLE: ALL: "+wholeHasAll+" BOOL: "+wholeHasBooleanData+" NOT: "+wholeHasNot+" <>=: "+wholeHasNrRes+"\n"; @@ -231,10 +284,10 @@ l+="accOnOnto\t\t"+accOnOnto.getMeanAsPercentage()+" +-"+accOnOnto.getStandardDeviation()+"\n"; l+="accPosExOnOnto\t\t"+accPosExOnOnto.getMeanAsPercentage()+" +-"+accPosExOnOnto.getStandardDeviation()+"\n"; l+="accNegExOnOnto\t\t"+accNegExOnOnto.getMeanAsPercentage()+" +-"+accNegExOnOnto.getStandardDeviation()+"\n"; - l+="timeFragment\t\t"+timeFragment.getMean()+" +-"+timeFragment.getStandardDeviation()+"\n"; + l+="timeFragment\t\t"+learningTime.getMean()+" +-"+learningTime.getStandardDeviation()+"\n"; l+="nrOfExtractedTriples\t\t"+nrOfExtractedTriples.getMean()+" +-"+nrOfExtractedTriples.getStandardDeviation()+"\n"; - l+="dLengthFragment\t\t"+dLengthFragment.getMean()+" +-"+dLengthFragment.getStandardDeviation()+"\n"; - l+="dDepthFragment\t\t"+dDepthFragment.getMean()+" +-"+dDepthFragment.getStandardDeviation()+"\n"; + l+="dLengthFragment\t\t"+descLength.getMean()+" +-"+descLength.getStandardDeviation()+"\n"; + l+="dDepthFragment\t\t"+descDepth.getMean()+" +-"+descDepth.getStandardDeviation()+"\n"; l+="timeWhole\t\t"+timeWhole.getMean()+" +-"+timeWhole.getStandardDeviation()+"\n"; l+="accWhole\t\t"+accWhole.getMeanAsPercentage()+" +-"+accWhole.getStandardDeviation()+"\n"; @@ -298,8 +351,8 @@ } - public static List<String> getFiles(boolean sparql){ - String actualDir = (sparql)?sparqldir:normaldir; + public static List<String> getFiles(){ + String actualDir = exampleDir; logger.warn(actualDir); File f = new File(actualDir); String[] files = f.list(); @@ -307,55 +360,7 @@ return Arrays.asList(files); } - public static List<File> getFilesContaining(boolean sparql, String numExamples, String allOrEx, String acc) { - List<File> ret = new ArrayList<File>(); - //SortedSet<File> ret = new TreeSet<File>(); - - String actualDir = (sparql)?sparqldir:normaldir; - logger.warn(actualDir); - File f = new File(actualDir); - String[] files = f.list(); - Arrays.sort(files); - int consistent = 0; - try{ - for (int i = 0; i < files.length; i++) { - - if( files[i].contains(numExamples) - && files[i].contains(allOrEx) - && files[i].contains(acc) - ){ - consistent++; - ret.add(new File(actualDir+files[i])); - if(ret.size() != consistent){ - logger.warn("double file: "+files[i]); - } - } - - } - }catch (Exception e) { - - e.printStackTrace(); - } - if(consistent != ret.size()){ - logger.warn("double files"+consistent+"::"+ret.size()); - System.exit(0); - }else{ - logger.warn("all files different"); - } - return ret; - } - /*public static void analyzeFiles(List<File> l){ - - SortedSet<String> differentIndividuals = new TreeSet<String>(); - for ( content : l) { - differentIndividuals.addAll(getIndividuals(content, true)); - differentIndividuals.addAll(getIndividuals(content, false)); - - } - System.out.println("found diff inds "+differentIndividuals.size()); - - }*/ public static SortedSet<String> getIndividuals(String target, boolean posOrNeg){ if(posOrNeg){ @@ -381,45 +386,10 @@ return ret; } - public static String getCombinedOptions(){ - String s="\n"+ - "algorithm = refexamples;\n"+ - "refexamples.useAllConstructor = true;\n"+ - "refexamples.useNegation = true;\n"+ - "refexamples.useCardinalityRestrictions = true;\n"+ - "refexamples.guaranteeXgoodDescriptions = 1;\n"+ - - "\n"+ - "reasoner = owlAPIReasoner;\n"+ - //"reasoner = fastInstanceChecker;\n"+ - "owlAPIReasoner.reasonerType = pellet;\n\n"+ - ""; - return s; - } - public static String sparqlOptions (){ - String s="// SPARQL options\n"+ - "sparql.recursionDepth = 2;\n"+ - "sparql.useLits = true;\n"+ - "sparql.predefinedEndpoint = \"LOCALJOSEKIBIBLE\";\n"+ - "sparql.getPropertyInformation = true;\n"+ - "refexamples.maxExecutionTimeInSeconds = "+sparqllMaxExecution+";\n"+ - "import(\"http://localhost:2020/bible\",\"SPARQL\");\n"+ - getCombinedOptions()+ - ""; - return s; - } - public static String normalOptions (){ - String s="\n"+ - "import(\"NTNcombined.owl\");\n"+ - "refexamples.maxExecutionTimeInSeconds = "+normalMaxExecution+";\n"; - - s+="refexamples.noisePercentage = "+normalNoisePercentage+";\n"+ - getCombinedOptions()+ - ""; - return s; - } + + private static void initLogger() { @@ -443,6 +413,56 @@ } + + /*public static List<File> getFilesContaining(boolean sparql, String numExamples, String allOrEx, String acc) { + List<File> ret = new ArrayList<File>(); + //SortedSet<File> ret = new TreeSet<File>(); + + String actualDir = (sparql)?sparqldir:normaldir; + logger.warn(actualDir); + File f = new File(actualDir); + String[] files = f.list(); + Arrays.sort(files); + int consistent = 0; + try{ + for (int i = 0; i < files.length; i++) { + + if( files[i].contains(numExamples) + && files[i].contains(allOrEx) + && files[i].contains(acc) + ){ + consistent++; + ret.add(new File(actualDir+files[i])); + if(ret.size() != consistent){ + logger.warn("double file: "+files[i]); + } + } + + } + }catch (Exception e) { + + e.printStackTrace(); + } + if(consistent != ret.size()){ + logger.warn("double files"+consistent+"::"+ret.size()); + System.exit(0); + }else{ + logger.warn("all files different"); + } + return ret; +}*/ +/*public static void analyzeFiles(List<File> l){ + SortedSet<String> differentIndividuals = new TreeSet<String>(); + for ( content : l) { + differentIndividuals.addAll(getIndividuals(content, true)); + differentIndividuals.addAll(getIndividuals(content, false)); + + } + System.out.println("found diff inds "+differentIndividuals.size()); + +}*/ + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-25 19:27:17
|
Revision: 1260 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1260&view=rev Author: kurzum Date: 2008-09-25 19:26:59 +0000 (Thu, 25 Sep 2008) Log Message: ----------- - added constructor in gui.config - new Classes for collecting data and writing a latex table Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/scripts/NewSample.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java trunk/src/dl-learner/org/dllearner/utilities/Files.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java trunk/src/dl-learner/org/dllearner/utilities/statistics/TableColumn.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-25 16:34:53 UTC (rev 1259) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-25 19:26:59 UTC (rev 1260) @@ -76,6 +76,30 @@ private StartGUI gui; /** + * This constructor can be used systemwide to save configurations in conf files. + * Of course it should not really belong here, but either in core or utilities. + * Consider refactoring using a subclass of Config for the GUI. + * Nevertheless it still works. + * + * + * @param cm + * @param source + * @param reasoner + * @param rs + * @param lp + * @param la + */ + public Config(ComponentManager cm, KnowledgeSource source, ReasonerComponent reasoner, ReasoningService rs, LearningProblem lp, LearningAlgorithm la) { + super(); + this.cm = cm; + this.source = source; + this.reasoner = reasoner; + this.rs = rs; + this.lp = lp; + this.la = la; + } + + /** * Create central configuration object. * * @param gui Modified: trunk/src/dl-learner/org/dllearner/scripts/NewSample.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/NewSample.java 2008-09-25 16:34:53 UTC (rev 1259) +++ trunk/src/dl-learner/org/dllearner/scripts/NewSample.java 2008-09-25 19:26:59 UTC (rev 1260) @@ -41,6 +41,9 @@ import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasoningService; import org.dllearner.core.configurators.ComponentFactory; +import org.dllearner.gui.Config; +import org.dllearner.gui.ConfigSave; +import org.dllearner.gui.StartGUI; import org.dllearner.kb.OWLFile; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.reasoning.FastInstanceChecker; Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-25 16:34:53 UTC (rev 1259) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java 2008-09-25 19:26:59 UTC (rev 1260) @@ -114,19 +114,16 @@ logger.warn("Start"); File tmpFile = new File(tmpFilename); - - List<File> confs = getFilesContaining(useSPARQL,"ten","all", "99+"); - //analyzeFiles(confs); - - - + List<String> confs = getFiles(useSPARQL); + reasoningService = ReasoningServiceFactory.getReasoningService(ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); ComponentManager cm =ComponentManager.getInstance(); + try{ - for (File f : confs) { - + for (String filename : confs) { + File f = new File(filename); Cache.getDefaultCache().clearCache(); String fileContent = Files.readFile(f); @@ -300,6 +297,16 @@ return null; } + + public static List<String> getFiles(boolean sparql){ + String actualDir = (sparql)?sparqldir:normaldir; + logger.warn(actualDir); + File f = new File(actualDir); + String[] files = f.list(); + Arrays.sort(files); + return Arrays.asList(files); + } + public static List<File> getFilesContaining(boolean sparql, String numExamples, String allOrEx, String acc) { List<File> ret = new ArrayList<File>(); //SortedSet<File> ret = new TreeSet<File>(); Modified: trunk/src/dl-learner/org/dllearner/utilities/Files.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-09-25 16:34:53 UTC (rev 1259) +++ trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-09-25 19:26:59 UTC (rev 1260) @@ -19,13 +19,22 @@ */ package org.dllearner.utilities; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.List; +import com.ibm.icu.util.StringTokenizer; + /** * @author Jens Lehmann * @@ -41,8 +50,7 @@ * @return Content of the file. */ public static String readFile(File file) throws FileNotFoundException, IOException { - - + BufferedReader br = new BufferedReader(new FileReader(file)); StringBuffer content = new StringBuffer(); try{ @@ -56,6 +64,74 @@ return content.toString(); } + + /** + * Reads in a file as Array + * + * @param file + * The file to read. + * @return StringArray with lines + */ + public static String[] readFileAsArray(File file) throws FileNotFoundException, IOException { + String content = readFile(file); + StringTokenizer st = new StringTokenizer(content, System.getProperty("line.separator")); + List<String> l = new ArrayList<String>(); + while (st.hasMoreTokens()) { + l.add((String) st.nextToken()); + + } + + return l.toArray(new String[l.size()]); + + } + + /** + * writes a serializable Object to a File. + * @param obj + * @param file + */ + public static void writeObjectToFile(Object obj, File file){ + + ObjectOutputStream oos = null; + try{ + FileOutputStream fos = new FileOutputStream(file); + BufferedOutputStream bos = new BufferedOutputStream(fos); + oos = new ObjectOutputStream(bos); + + oos.writeObject(obj); + oos.flush(); + oos.close(); + }catch (Exception e) { + e.printStackTrace(); + }finally{ + try{ + oos.close(); + }catch (Exception e) { + e.printStackTrace(); + } + } + } + + public static Object readObjectfromFile( File file){ + ObjectInputStream ois = null; + try{ + FileInputStream fis = new FileInputStream(file); + BufferedInputStream bis = new BufferedInputStream(fis); + ois = new ObjectInputStream(bis); + return ois.readObject(); + }catch (Exception e) { + e.printStackTrace(); + }finally{ + try { + ois.close(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + return null; + } + /** * Creates a new file with the given content or replaces the content of a @@ -185,5 +261,7 @@ e.printStackTrace(); } } + + } Added: trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/Table.java 2008-09-25 19:26:59 UTC (rev 1260) @@ -0,0 +1,205 @@ +/** + * 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.utilities.statistics; + +import java.io.File; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.dllearner.utilities.Files; + + +/** + * Class to collect results and output them as a latex table or other formats. + * + * @author Sebastian Hellmann + * + */ +public class Table implements Serializable{ + + private static final long serialVersionUID = 0l; + + //used to give a good percentage output + //private DecimalFormat df = new DecimalFormat( ".00%" ); + private List<TableColumn> columns = new ArrayList<TableColumn>(); + + private String tableName = ""; + private String caption = ""; + private String label = ""; + + public Table(String tableName){ + this.tableName = tableName; + } + + public static void main(String[] args) { + Table t = new Table("myTable"); + String tableFile = "results/table/myTable"; + TableColumn c1 = new TableColumn("col1", new String[]{"a","b"}); + TableColumn c2 = new TableColumn("col2", new String[]{"c","d"}); + t.addColumn(c1); + System.out.println(t.getLatexString()); + + serializeColumns(t, "results/table",tableFile ); + + t = createTableFromSerializedColums("myTable", tableFile); + System.out.println(t.getLatexString()); + + t.addColumn(c2); + serializeColumns(t, "results/table",tableFile ); + t = createTableFromSerializedColums("myTable", tableFile); + System.out.println(t.getLatexString()); + + + + } + + public String getLatexString(){ + String tabular = ""; + for (int i = 0; i < columns.size(); i++) { + tabular+="l"; + } + + String headers = latexRow(getColumnHeaders()); + + String table=""; + + table += "\\begin{table*}\n"; + table += "\t\\centering\n"; + table += "\t\t\\begin{tabular}{"+tabular+"}\n"; + table += "\\hline\n"; + table += headers; + table += "\\hline\n"; + // add here + for (int i = 0; i < getNumberOfRows(); i++) { + table +=getRowInLatex(i); + } + table += "\\end{tabular}\n"; + table += "\t\\caption{"+caption+"}\n"; + table += "\t\\label{"+label+"}\n"; + table += "\\end{table*}\n\n"; + + //List<String> myList = new ArrayList<String>({""}); + + //List<String> list = Arrays.asList( "","" ); + return table; + + } + + public String getRowInLatex(int index){ + List<String> l = new ArrayList<String>(); + for(TableColumn c: columns){ + l.add(c.getEntry(index)); + } + return latexRow(l); + } + + public int getNumberOfRows(){ + if(columns.isEmpty())return 0; + else return columns.get(0).getSize(); + } + + + public List<String> getColumnHeaders(){ + List<String> entries = new ArrayList<String>(); + for (TableColumn c : columns) { + entries.add(c.getHeader()); + } + return entries; + } + + public String latexRow(List<String> entries){ + String ret=""; + for (String one : entries) { + ret+=" "+one+"\t& "; + } + ret = ret.substring(0,ret.length()-3); + ret+="\t\\\\\n"; + return ret; + } + + public void addColumn(TableColumn c){ + if(columns.isEmpty()){ + columns.add(c); + }else{ + if(getNumberOfRows()!=c.getSize()){ + System.out.println("ERROR: size of columns doesn't match"); + System.exit(0); + }else{ + columns.add(c); + } + } + } + + public static Table createTableFromSerializedColums(String tableName, String tableFile){ + Table ret = new Table(tableName); + try{ + + String[] columnFiles = Files.readFileAsArray(new File(tableFile)); + for (String filename : columnFiles) { + TableColumn col = TableColumn.deSerialize(new File(filename)); + //TableColumn col = (TableColumn) Files.readObjectfromFile(new File(filename)); + ret.addColumn(col); + } + // FileWriter fw = new FileWriter (); + }catch (Exception e) { + e.printStackTrace(); + } + return ret; + } + + public static void serializeColumns(Table t, String dir, String tableFile){ + String column = "column"; + String content = ""; + Files.mkdir(dir); + try{ + int i=0; + for(TableColumn c:t.getColumns()){ + String filename = dir+File.separator+t.getTableName()+column+(i++); + c.serialize(new File(filename)); + //Files.writeObjectToFile(c, new File(filename)); + content += filename+System.getProperty("line.separator"); + } + Files.createFile(new File(tableFile), content); + // + //FileWriter fw = new FileWriter (); + }catch (Exception e) { + e.printStackTrace(); + } + } + + + public List<TableColumn> getColumns() { + return columns; + } + + + public String getTableName() { + return tableName; + } + + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + +} Added: trunk/src/dl-learner/org/dllearner/utilities/statistics/TableColumn.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/TableColumn.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/TableColumn.java 2008-09-25 19:26:59 UTC (rev 1260) @@ -0,0 +1,120 @@ +/** + * Copyright (C) 2007, 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.utilities.statistics; + +import java.io.File; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.dllearner.utilities.Files; + + +public class TableColumn implements Serializable { + + private static final long serialVersionUID = 1l; + private String header; + private List<String> entries = new ArrayList<String>(); + +public TableColumn() { + super(); + +} + +public TableColumn(String header) { + super(); + this.header = header; +} + + +public TableColumn( String[] entries) { + this.entries = Arrays.asList(entries); +} + + +public TableColumn(String header, String[] entries) { + this(header); + this.entries = Arrays.asList(entries); +} + +public TableColumn( List<String> entries) { + this.entries = entries; +} + + +public String getHeader() { + return header; +} + +public void setHeader(String header) { + this.header = header; +} + +/** + * entires should be in Latex, if the target is latex + * @param entry + */ +public void addEntry(String entry){ + entries.add(entry); +} + +public int getSize(){ + return entries.size(); +} + +public String getEntry(int index){ + return entries.get(index); +} + +public void serialize(File file){ + String content = header+System.getProperty("line.separator"); + for (String entry : entries) { + content += entry+System.getProperty("line.separator"); + } + Files.createFile(file, content); +} + +public static TableColumn deSerialize(File f){ + TableColumn ret = null; + try{ + String[] c = Files.readFileAsArray(f); + ret = new TableColumn(); + boolean first = true; + for (String line : c) { + if(first){ + first = false; + ret.setHeader(line); + + }else{ + ret.addEntry(line); + } + + } + }catch (Exception e) { + e.printStackTrace(); + } + + return ret; +} + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-25 16:35:08
|
Revision: 1259 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1259&view=rev Author: kurzum Date: 2008-09-25 16:34:53 +0000 (Thu, 25 Sep 2008) Log Message: ----------- server commit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java Modified: trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-09-25 16:20:47 UTC (rev 1258) +++ trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-09-25 16:34:53 UTC (rev 1259) @@ -46,6 +46,7 @@ import org.dllearner.utilities.learn.ConfWriter; import org.dllearner.utilities.owl.ReasoningServiceFactory; import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; +import org.dllearner.utilities.statistics.Stat; public class DumbLPFinder { @@ -77,6 +78,7 @@ public static void main(String[] args) { initLogger(); logger.info("started"); + Stat acc = new Stat(); // String fileURL = new File(ontologyFile).toURI().toString(); reasoningService = ReasoningServiceFactory.getReasoningService( @@ -122,6 +124,7 @@ EvaluatedDescription d; d = learnSPARQL(positiveEx, negativeEx); + acc.addNumber(d.getAccuracy()); writeFiles(filename, d, positiveEx, negativeEx); @@ -133,6 +136,8 @@ // System.out.println(count); count++; } + + logger.warn("AVERAGE ACCURACY "+acc.getMeanAsPercentage()); } @@ -239,7 +244,14 @@ la.getConfigurator().setNoisePercentage(0.0); la.getConfigurator().setGuaranteeXgoodDescriptions(1); la.getConfigurator().setMaxExecutionTimeInSeconds(30); + + ks.init(); + f.init(); + lp.init(); + la.init(); + // start learning algorithm + logger.debug("start learning"); la.start(); } catch (Exception e) { // System.out.println("ignoring the error "+e.toString()); @@ -270,6 +282,7 @@ logger.addAppender(consoleAppender); } else { logger.setLevel(Level.INFO); + } logger.addAppender(fileAppender); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |