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: <dfl...@us...> - 2013-11-21 12:51:08
|
Revision: 4160 http://sourceforge.net/p/dl-learner/code/4160 Author: dfleischhacker Date: 2013-11-21 12:51:05 +0000 (Thu, 21 Nov 2013) Log Message: ----------- Move enum SurfaceFormLevel to own class Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SurfaceFormLevel.java Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SurfaceFormLevel.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SurfaceFormLevel.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SurfaceFormLevel.java 2013-11-21 12:51:05 UTC (rev 4160) @@ -0,0 +1,13 @@ +package org.dllearner.algorithms.isle.index; + +/** + * Different levels of surface forms supported by the {@link TextDocument} class. Used for retrieving certain types + * of texts. + * + * @author Daniel Fleischhacker + */ +public enum SurfaceFormLevel { + RAW, + POS_TAGGED, + STEMMED +} \ No newline at end of file Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java 2013-11-21 12:44:09 UTC (rev 4159) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java 2013-11-21 12:51:05 UTC (rev 4160) @@ -10,25 +10,19 @@ public class TextDocument extends LinkedList<Token> implements Document { @Override public String getContent() { - return getContentStartingAtToken(this.getFirst(), Level.STEMMED); + return getContentStartingAtToken(this.getFirst(), SurfaceFormLevel.STEMMED); } @Override public String getRawContent() { - return getContentStartingAtToken(this.getFirst(), Level.RAW); + return getContentStartingAtToken(this.getFirst(), SurfaceFormLevel.RAW); } @Override public String getPOSTaggedContent() { - return getContentStartingAtToken(this.getFirst(), Level.POS_TAGGED); + return getContentStartingAtToken(this.getFirst(), SurfaceFormLevel.POS_TAGGED); } - public static enum Level { - RAW, - POS_TAGGED, - STEMMED - } - /** * Returns a string containing all tokens starting at the token {@code start} until the end of the list. The * surface forms according to {@code level} are used to build the string. @@ -37,7 +31,7 @@ * @param l level of surface forms to use * @return built string */ - public String getContentStartingAtToken(Token start, Level l) { + public String getContentStartingAtToken(Token start, SurfaceFormLevel l) { StringBuilder sb = new StringBuilder(); boolean found = false; for (Token t : this) { @@ -54,7 +48,7 @@ return sb.toString(); } - private String getStringForLevel(Token t, Level l) { + private String getStringForLevel(Token t, SurfaceFormLevel l) { switch (l) { case RAW: return t.getRawForm(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dfl...@us...> - 2013-11-21 12:44:12
|
Revision: 4159 http://sourceforge.net/p/dl-learner/code/4159 Author: dfleischhacker Date: 2013-11-21 12:44:09 +0000 (Thu, 21 Nov 2013) Log Message: ----------- Re-implement TextDocument based on Tokens Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java 2013-11-21 12:36:47 UTC (rev 4158) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java 2013-11-21 12:44:09 UTC (rev 4159) @@ -7,6 +7,63 @@ * * @author Daniel Fleischhacker */ -public class TextDocument extends LinkedList<Token> { +public class TextDocument extends LinkedList<Token> implements Document { + @Override + public String getContent() { + return getContentStartingAtToken(this.getFirst(), Level.STEMMED); + } + @Override + public String getRawContent() { + return getContentStartingAtToken(this.getFirst(), Level.RAW); + } + + @Override + public String getPOSTaggedContent() { + return getContentStartingAtToken(this.getFirst(), Level.POS_TAGGED); + } + + public static enum Level { + RAW, + POS_TAGGED, + STEMMED + } + + /** + * Returns a string containing all tokens starting at the token {@code start} until the end of the list. The + * surface forms according to {@code level} are used to build the string. + * + * @param start token to start building the string at, i.e., the first token in the returned string + * @param l level of surface forms to use + * @return built string + */ + public String getContentStartingAtToken(Token start, Level l) { + StringBuilder sb = new StringBuilder(); + boolean found = false; + for (Token t : this) { + if (found) { + sb.append(" "); + sb.append(getStringForLevel(t, l)); + } + else if (t == start) { + found = true; + sb.append(getStringForLevel(t, l)); + } + } + + return sb.toString(); + } + + private String getStringForLevel(Token t, Level l) { + switch (l) { + case RAW: + return t.getRawForm(); + case POS_TAGGED: + return t.getPOSTag(); + case STEMMED: + return t.getStemmedForm(); + } + + return null; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-11-21 12:36:50
|
Revision: 4158 http://sourceforge.net/p/dl-learner/code/4158 Author: lorenz_b Date: 2013-11-21 12:36:47 +0000 (Thu, 21 Nov 2013) Log Message: ----------- Added text document generator. Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/TextDocumentGenerator.java Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/TextDocumentGenerator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/TextDocumentGenerator.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/TextDocumentGenerator.java 2013-11-21 12:36:47 UTC (rev 4158) @@ -0,0 +1,67 @@ +package org.dllearner.algorithms.isle; + +import java.util.List; +import java.util.Properties; + +import org.dllearner.algorithms.isle.index.TextDocument; +import org.dllearner.algorithms.isle.index.Token; + +import edu.stanford.nlp.ling.CoreAnnotations.LemmaAnnotation; +import edu.stanford.nlp.ling.CoreAnnotations.PartOfSpeechAnnotation; +import edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation; +import edu.stanford.nlp.ling.CoreAnnotations.TextAnnotation; +import edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation; +import edu.stanford.nlp.ling.CoreLabel; +import edu.stanford.nlp.pipeline.Annotation; +import edu.stanford.nlp.pipeline.StanfordCoreNLP; +import edu.stanford.nlp.util.CoreMap; + +public class TextDocumentGenerator { + + private static TextDocumentGenerator instance; + private StanfordCoreNLP pipeline; + + private TextDocumentGenerator(){ + Properties props = new Properties(); + props.put("annotators", "tokenize, ssplit, pos, lemma"); + pipeline = new StanfordCoreNLP(props); + } + + public static synchronized TextDocumentGenerator getInstance(){ + if(instance == null){ + instance = new TextDocumentGenerator(); + } + return instance; + } + + public TextDocument tag(String text) { + TextDocument document = new TextDocument(); + // create an empty Annotation just with the given text + Annotation annotatedDocument = new Annotation(text); + + // run all Annotators on this text + pipeline.annotate(annotatedDocument); + + // these are all the sentences in this document + // a CoreMap is essentially a Map that uses class objects as keys and has values with custom types + List<CoreMap> sentences = annotatedDocument.get(SentencesAnnotation.class); + + for(CoreMap sentence: sentences) { + for (CoreLabel label: sentence.get(TokensAnnotation.class)) { + // this is the text of the token + String word = label.get(TextAnnotation.class); + // this is the POS tag of the token + String pos = label.get(PartOfSpeechAnnotation.class); + //this is the POS tag of the token + String lemma = label.get(LemmaAnnotation.class); + + Token token = new Token(word); + token.setPOSTag(pos); + token.setStemmedForm(lemma); + document.add(token); + } + } + + return document; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dfl...@us...> - 2013-11-21 12:32:33
|
Revision: 4157 http://sourceforge.net/p/dl-learner/code/4157 Author: dfleischhacker Date: 2013-11-21 12:32:30 +0000 (Thu, 21 Nov 2013) Log Message: ----------- TextDocument refactoring Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java 2013-11-21 12:25:40 UTC (rev 4156) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java 2013-11-21 12:32:30 UTC (rev 4157) @@ -1,95 +1,12 @@ package org.dllearner.algorithms.isle.index; -import org.dllearner.algorithms.isle.StanfordPartOfSpeechTagger; +import java.util.LinkedList; /** * A simple text document without further formatting or markup. * * @author Daniel Fleischhacker */ -public class TextDocument implements Document { - private String content; - private String rawContent; - private String posTaggedContent; +public class TextDocument extends LinkedList<Token> { - /** - * Initializes a text document with the given raw content. Internally, the content is cleaned up so that it only - * contains letters adhering to the regular expression pattern [A-Za-z]. - * - * @param content the raw content of this text document - */ - public TextDocument(String content) { - this.rawContent = content; - - //build cleaned content - buildCleanedContent(); - - //build POS tagged content - buildPOSTaggedContent(); - } - - private void buildCleanedContent(){ - this.content = rawContent.toLowerCase(); - this.content = this.content.replaceAll("[^a-z ]", " "); - this.content = this.content.replaceAll("\\s{2,}", " "); - this.content = this.content.trim(); - } - - private void buildPOSTaggedContent(){ - this.posTaggedContent = StanfordPartOfSpeechTagger.getInstance().tag(rawContent); - } - - @Override - public String getContent() { - return content; - } - - /** - * The text content of this document. Returns the same data as {@link #getContent()}. - * - * @return text content of this document - */ - @Override - public String getRawContent() { - return rawContent; - } - - /* (non-Javadoc) - * @see org.dllearner.algorithms.isle.index.Document#getPOSTaggedContent() - */ - @Override - public String getPOSTaggedContent() { - return posTaggedContent; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - TextDocument that = (TextDocument) o; - - if (!content.equals(that.content)) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - return content.hashCode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return content; - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-11-21 12:25:43
|
Revision: 4156 http://sourceforge.net/p/dl-learner/code/4156 Author: lorenz_b Date: 2013-11-21 12:25:40 +0000 (Thu, 21 Nov 2013) Log Message: ----------- Added token class. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/Token.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/WordTypeComparator.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java 2013-11-21 11:54:23 UTC (rev 4155) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java 2013-11-21 12:25:40 UTC (rev 4156) @@ -29,7 +29,7 @@ } private void buildCleanedContent(){ - this.content = content.toLowerCase(); + this.content = rawContent.toLowerCase(); this.content = this.content.replaceAll("[^a-z ]", " "); this.content = this.content.replaceAll("\\s{2,}", " "); this.content = this.content.trim(); Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/Token.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/Token.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/Token.java 2013-11-21 12:25:40 UTC (rev 4156) @@ -0,0 +1,64 @@ +/** + * + */ +package org.dllearner.algorithms.isle.index; + +/** + * @author Lorenz Buehmann + * + */ +public class Token { + + private String rawForm; + private String stemmedForm; + private String posTag; + + public Token(String rawForm) { + posTag = rawForm; + } + + /** + * @return the rawForm + */ + public String getRawForm() { + return rawForm; + } + + /** + * @return the stemmedForm + */ + public String getStemmedForm() { + return stemmedForm; + } + + /** + * @return the posTag + */ + public String getPOSTag() { + return posTag; + } + + /** + * @param stemmedForm the stemmedForm to set + */ + public void setStemmedForm(String stemmedForm) { + this.stemmedForm = stemmedForm; + } + + /** + * @param posTag the posTag to set + */ + public void setPOSTag(String posTag) { + this.posTag = posTag; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Word: " + rawForm + "\n" + + "Stemmed word: " + stemmedForm + "\n" + + "POS tag: " + posTag; + } +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/WordTypeComparator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/WordTypeComparator.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/WordTypeComparator.java 2013-11-21 12:25:40 UTC (rev 4156) @@ -0,0 +1,27 @@ +/** + * + */ +package org.dllearner.algorithms.isle.index; + +/** + * Compare the word types of two given words. + * @author Lorenz Buehmann + * + */ +public class WordTypeComparator { + + /** + * Returns TRUE if both POS tags are related to the same word type, i.e. whether both are NOUNS, VERBS, etc. , + * else FALSE is returned. + * @param posTag1 the POS tag of the first word + * @param posTag2 the POS tag of the second word + * @return + */ + public static boolean sameWordType(String posTag1, String posTag2){ + if(posTag1.startsWith("NN") && posTag2.startsWith("NN") || + posTag1.startsWith("V") && posTag2.startsWith("V")){ + return true; + } + return false; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-11-21 11:54:26
|
Revision: 4155 http://sourceforge.net/p/dl-learner/code/4155 Author: lorenz_b Date: 2013-11-21 11:54:23 +0000 (Thu, 21 Nov 2013) Log Message: ----------- Added POS tags to text documents in constructor. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/StanfordPartOfSpeechTagger.java Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/StanfordPartOfSpeechTagger.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/StanfordPartOfSpeechTagger.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/StanfordPartOfSpeechTagger.java 2013-11-21 11:54:23 UTC (rev 4155) @@ -0,0 +1,59 @@ +package org.dllearner.algorithms.isle; + +import java.util.List; +import java.util.Properties; + +import edu.stanford.nlp.ling.CoreAnnotations.PartOfSpeechAnnotation; +import edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation; +import edu.stanford.nlp.ling.CoreAnnotations.TextAnnotation; +import edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation; +import edu.stanford.nlp.ling.CoreLabel; +import edu.stanford.nlp.pipeline.Annotation; +import edu.stanford.nlp.pipeline.StanfordCoreNLP; +import edu.stanford.nlp.util.CoreMap; + +public class StanfordPartOfSpeechTagger { + + private static StanfordPartOfSpeechTagger instance; + private StanfordCoreNLP pipeline; + + private StanfordPartOfSpeechTagger(){ + Properties props = new Properties(); + props.put("annotators", "tokenize, ssplit, pos"); + pipeline = new StanfordCoreNLP(props); + } + + public static synchronized StanfordPartOfSpeechTagger getInstance(){ + if(instance == null){ + instance = new StanfordPartOfSpeechTagger(); + } + return instance; + } + + public String tag(String text) { + String out = ""; + + // create an empty Annotation just with the given text + Annotation document = new Annotation(text); + + // run all Annotators on this text + pipeline.annotate(document); + + // these are all the sentences in this document + // a CoreMap is essentially a Map that uses class objects as keys and has values with custom types + List<CoreMap> sentences = document.get(SentencesAnnotation.class); + + for(CoreMap sentence: sentences) { + for (CoreLabel token: sentence.get(TokensAnnotation.class)) { + // this is the text of the token + String word = token.get(TextAnnotation.class); + // this is the POS tag of the token + String pos = token.get(PartOfSpeechAnnotation.class); + + out += " " + word + "/" + pos; + } + } + + return out.trim(); + } +} Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java 2013-11-21 11:39:19 UTC (rev 4154) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java 2013-11-21 11:54:23 UTC (rev 4155) @@ -1,5 +1,7 @@ package org.dllearner.algorithms.isle.index; +import org.dllearner.algorithms.isle.StanfordPartOfSpeechTagger; + /** * A simple text document without further formatting or markup. * @@ -10,7 +12,6 @@ private String rawContent; private String posTaggedContent; - /** * Initializes a text document with the given raw content. Internally, the content is cleaned up so that it only * contains letters adhering to the regular expression pattern [A-Za-z]. @@ -19,26 +20,24 @@ */ public TextDocument(String content) { this.rawContent = content; - this.content = content.toLowerCase(); - this.content = this.content.replaceAll("[^a-z ]", " "); - this.content = this.content.replaceAll("\\s{2,}", " "); - this.content = this.content.trim(); + + //build cleaned content + buildCleanedContent(); + + //build POS tagged content + buildPOSTaggedContent(); } - /** - * Initializes a text document with the given raw content. Internally, the content is cleaned up so that it only - * contains letters adhering to the regular expression pattern [A-Za-z]. - * - * @param content the raw content of this text document - */ - public TextDocument(String content, String posTaggedContent) { - this.rawContent = content; - this.posTaggedContent = posTaggedContent; - this.content = content.toLowerCase(); + private void buildCleanedContent(){ + this.content = content.toLowerCase(); this.content = this.content.replaceAll("[^a-z ]", " "); this.content = this.content.replaceAll("\\s{2,}", " "); this.content = this.content.trim(); } + + private void buildPOSTaggedContent(){ + this.posTaggedContent = StanfordPartOfSpeechTagger.getInstance().tag(rawContent); + } @Override public String getContent() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-11-21 11:39:22
|
Revision: 4154 http://sourceforge.net/p/dl-learner/code/4154 Author: lorenz_b Date: 2013-11-21 11:39:19 +0000 (Thu, 21 Nov 2013) Log Message: ----------- POS tags in ISLE text documents. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/AnnotatedTextDocument.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/Document.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/SemanticBibleExperiment.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java 2013-11-19 21:14:09 UTC (rev 4153) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java 2013-11-21 11:39:19 UTC (rev 4154) @@ -386,10 +386,10 @@ } else if (learningProblem instanceof PosNegLP) { examples = Helper.union(((PosNegLP)learningProblem).getPositiveExamples(),((PosNegLP)learningProblem).getNegativeExamples()); } - // commented by Josue as now there's no need of + and - examples (more code need to be deleted in this sense) - // else if (learningProblem instanceof FuzzyPosNegLP) { - //examples = Helper.union(((FuzzyPosNegLP)learningProblem).getPositiveExamples(),((FuzzyPosNegLP)learningProblem).getNegativeExamples()); - // } +// commented by Josue as now there's no need of + and - examples (more code need to be deleted in this sense) + else if (learningProblem instanceof FuzzyPosNegLP) { + examples = Helper.union(((FuzzyPosNegLP)learningProblem).getPositiveExamples(),((FuzzyPosNegLP)learningProblem).getNegativeExamples()); + } } @Override Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/AnnotatedTextDocument.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/AnnotatedTextDocument.java 2013-11-19 21:14:09 UTC (rev 4153) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/AnnotatedTextDocument.java 2013-11-21 11:39:19 UTC (rev 4154) @@ -44,6 +44,14 @@ public String getRawContent() { return document.getRawContent(); } + + /* (non-Javadoc) + * @see org.dllearner.algorithms.isle.index.Document#getPOSTaggedContent() + */ + @Override + public String getPOSTaggedContent() { + return document.getPOSTaggedContent(); + } /* (non-Javadoc) * @see org.dllearner.algorithms.isle.index.AnnotatedDocument#getContainedEntities() Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/Document.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/Document.java 2013-11-19 21:14:09 UTC (rev 4153) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/Document.java 2013-11-21 11:39:19 UTC (rev 4154) @@ -21,4 +21,11 @@ * @return uncleaned content of this document */ public String getRawContent(); + + /** + * Returns the uncleaned content with POS tags in form of word1/pos1 word2/pos2 ... as string. + * + * @return uncleaned content with POS tags + */ + public String getPOSTaggedContent(); } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java 2013-11-19 21:14:09 UTC (rev 4153) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TextDocument.java 2013-11-21 11:39:19 UTC (rev 4154) @@ -8,6 +8,7 @@ public class TextDocument implements Document { private String content; private String rawContent; + private String posTaggedContent; /** @@ -23,6 +24,21 @@ this.content = this.content.replaceAll("\\s{2,}", " "); this.content = this.content.trim(); } + + /** + * Initializes a text document with the given raw content. Internally, the content is cleaned up so that it only + * contains letters adhering to the regular expression pattern [A-Za-z]. + * + * @param content the raw content of this text document + */ + public TextDocument(String content, String posTaggedContent) { + this.rawContent = content; + this.posTaggedContent = posTaggedContent; + this.content = content.toLowerCase(); + this.content = this.content.replaceAll("[^a-z ]", " "); + this.content = this.content.replaceAll("\\s{2,}", " "); + this.content = this.content.trim(); + } @Override public String getContent() { @@ -38,6 +54,14 @@ public String getRawContent() { return rawContent; } + + /* (non-Javadoc) + * @see org.dllearner.algorithms.isle.index.Document#getPOSTaggedContent() + */ + @Override + public String getPOSTaggedContent() { + return posTaggedContent; + } @Override public boolean equals(Object o) { Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2013-11-19 21:14:09 UTC (rev 4153) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2013-11-21 11:39:19 UTC (rev 4154) @@ -147,8 +147,14 @@ private Concept convert(OWLClassExpression classExpression){ baos.reset(); - String name = fuzzyFileParser.getClassName(classExpression); - return fuzzyKB.getConcept(name); + if(classExpression.isOWLThing()){ + return Concept.CONCEPT_TOP; + } else if(classExpression.isOWLNothing()){ + return Concept.CONCEPT_BOTTOM; + } else { + String name = fuzzyFileParser.getClassName(classExpression); + return fuzzyKB.getConcept(name); + } } private Individual convert(OWLIndividual individual){ @@ -183,22 +189,16 @@ // System.err.println("WARNING: you're using a particular fuzzy ontology"); // parser = new Parser(new FileInputStream(CHANGING_JUST_HIERARCHI_PROBLEM)); - parser = new Parser(new FileInputStream(FUZZYOWL2FUZZYDLPARSEROUTPUT)); - - parser.Start(); - return parser.getKB(); + return Parser.getKB(FUZZYOWL2FUZZYDLPARSEROUTPUT); } // added by Josue public double getFuzzyMembership(OWLClassExpression oce, OWLIndividual i) { - Individual fIndividual = convert(i); Concept fConcept = convert(oce); - System.out.println(fConcept + "(" + fIndividual + ")?"); try { - Query q = new MinInstanceQuery(fConcept, fIndividual); - + Query q = new MinInstanceQuery(fConcept, fIndividual); KnowledgeBase clonedFuzzyKB = fuzzyKB.clone(); @@ -206,7 +206,7 @@ // long start = System.nanoTime(); queryResult = q.solve(clonedFuzzyKB); - + System.out.println(q.toString() + queryResult.getSolution()); // TODO: just for testing, remove // out.println(counter + " * " + (System.nanoTime() - start)); // counter++; Modified: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/SemanticBibleExperiment.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/SemanticBibleExperiment.java 2013-11-19 21:14:09 UTC (rev 4153) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/SemanticBibleExperiment.java 2013-11-21 11:39:19 UTC (rev 4154) @@ -85,8 +85,8 @@ if(!file.isDirectory() && !file.isHidden()){ try { String text = Files.toString(file, Charsets.UTF_8); - String posTagged = getPOSTaggedText(text); - Files.write(posTagged, new File(taggedFolder, file.getName() + ".tagged"), Charsets.UTF_8); +// String posTagged = getPOSTaggedText(text); +// Files.write(posTagged, new File(taggedFolder, file.getName() + ".tagged"), Charsets.UTF_8); documents.add(new TextDocument(text)); } catch (IOException e) { e.printStackTrace(); @@ -99,7 +99,7 @@ e.printStackTrace(); } -// documents = Sets.newHashSet(new TextDocument("and in that day seven women shall take hold of one man saying we will eat our own bread and wear our own apparel only let us be called by thy name to take away our reproach in that day shall the branch of the lord be beautiful and glorious and the fruit of the earth excellent and comely for them that are escaped of israel and it shall come to pass left in zion and remaineth in jerusalem shall be called holy every one that is written among the living in jerusalem when the lord shall have washed away the filth of the daughters of zion and shall have purged the blood of jerusalem from the midst thereof by the spirit of judgment and by the spirit of burning and the lord will create upon every dwelling place of mount zion and upon her assemblies a cloud and smoke by day and the shining of a flaming fire by night for upon all the glory a defence and there shall be a tabernacle for a shadow in the daytime from the heat and for a place of refuge and for a covert from storm and from rain")); + documents = Sets.newHashSet(new TextDocument("and in that day seven women shall take hold of one man saying we will eat our own bread and wear our own apparel only let us be called by thy name to take away our reproach in that day shall the branch of the lord be beautiful and glorious and the fruit of the earth excellent and comely for them that are escaped of israel and it shall come to pass left in zion and remaineth in jerusalem shall be called holy every one that is written among the living in jerusalem when the lord shall have washed away the filth of the daughters of zion and shall have purged the blood of jerusalem from the midst thereof by the spirit of judgment and by the spirit of burning and the lord will create upon every dwelling place of mount zion and upon her assemblies a cloud and smoke by day and the shining of a flaming fire by night for upon all the glory a defence and there shall be a tabernacle for a shadow in the daytime from the heat and for a place of refuge and for a covert from storm and from rain")); return documents; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <far...@us...> - 2013-11-19 21:14:13
|
Revision: 4153 http://sourceforge.net/p/dl-learner/code/4153 Author: farshadbadie Date: 2013-11-19 21:14:09 +0000 (Tue, 19 Nov 2013) Log Message: ----------- EvKnowledgeFuzzyTrain Added Paths: ----------- trunk/test/fuzzydll/EvKnowledge/EvKnowledge.conf trunk/test/fuzzydll/EvKnowledge/EvKnowledge.txt Added: trunk/test/fuzzydll/EvKnowledge/EvKnowledge.conf =================================================================== --- trunk/test/fuzzydll/EvKnowledge/EvKnowledge.conf (rev 0) +++ trunk/test/fuzzydll/EvKnowledge/EvKnowledge.conf 2013-11-19 21:14:09 UTC (rev 4153) @@ -0,0 +1,29 @@ +/** + * SUCCESSFUL USER Example + * + * possible solution: + * User AND EXISTS hasSTG.VeryLow AND hasSCG.VeryLow AND hasSTR.VeryLow AND hasLPR.High AND hasPEG.High AND hasUNS.HIGH + * + * Copyright (C) 2007, Jens Lehmann + */ + +// declare some prefixes to use as abbreviations +prefixes = [ ("ex","http://example.com/EvKnowledge#") ] + +// knowledge source definition +ks.type = "OWL File" +ks.fileName = "EvKnowledge.owl" + +// reasoner +reasoner.type = "fast instance checker" +reasoner.sources = { ks } + +// learning problem +lp.type = "posNegStandard" +lp.positiveExamples = { "ex:", "ex:USER49", "ex:USER167" } +lp.negativeExamples = { "ex:heinz", "ex:USER118", "ex:USER149" } + +// create learning algorithm to run +alg1.type = "celoe" +alg2.type = "pceloe" + Added: trunk/test/fuzzydll/EvKnowledge/EvKnowledge.txt =================================================================== --- trunk/test/fuzzydll/EvKnowledge/EvKnowledge.txt (rev 0) +++ trunk/test/fuzzydll/EvKnowledge/EvKnowledge.txt 2013-11-19 21:14:09 UTC (rev 4153) @@ -0,0 +1,129 @@ + +- Train has changed to EvKnowledge +- Car has changed to User +- Lengh has changed to Success +- Short has changed to Unsuccessful +- Long has changed to Successful +- Load is still Load . And can have several shapes + +(define-fuzzy-concept fuzzySuccessfulUser right-shoulder(0.2, 0.4, 0.7, 1.0) ) +(define-fuzzy-concept fuzzyUnsuccessfulUser left-shoulder(1.0, 0.7, 0.4, 0.2) ) +(define-fuzzy-concept fuzzyMediumSuccessfulUser trapezoidal(-50.0, 50.0, 0.4, 0.2, 0.7, 1.0) ) +(functional isInFrontOf) +(functional hasUserSuccess) +(domain hasLoad User ) +(domain isInFrontOf (or User EvKnowledge ) ) +(domain hasUser EvKnowledge ) +(range hasUser User ) +(range isInFrontOf User ) +(range hasLoad Load ) +(domain hasUserSuccess User ) +(range hasUserSuccess *real* 0 1 ) + +(instance load63a Rectangle 1.0) +(instance load21a Triangle 1.0) +(instance User72 User 1.0) +(instance User22 User 1.0) +(instance User13 User 1.0) +(instance load72c Triangle 1.0) +(instance load63b Triangle 1.0) +(instance User61 User 1.0) +(instance User21 User 1.0) +(instance User62 User 1.0) +(instance load71b Rectangle 1.0) +(instance User63 User 1.0) +(instance load72b Rectangle 1.0) +(instance load11a Rectangle 1.0) +(instance User11 User 1.0) +(instance User12 User 1.0) +(instance User7 EvKnowledge 1.0) +(instance load61a Triangle 0.4) +(instance load11c Triangle 1.0) +(instance load62a Rectangle 1.0) +(instance load11b Rectangle 1.0) +(instance load71a Triangle 1.0) +(instance load22a Rectangle 0.8) +(instance User71 User 1.0) +(instance west6 EvKnowledge 1.0) +(instance load22a Triangle 0.2) +(instance load12a Rectangle 1.0) +(instance load61a Rectangle 0.6) +(instance east1 EvKnowledge 1.0) +(instance load72a Rectangle 1.0) + +(related west6 User61 isInFrontOf 1.0) +(related car63 load63a hasLoad 1.0) +(related west6 User63 hasUser 1.0) +(related east1 User13 hasUser 1.0) +(related east2 User21 hasUser 1.0) +(related User72 load72b hasLoad 1.0) +(related east1 User11 hasUser 1.0) +(related User61 load61a hasLoad 0.1) +(related west7 User72 hasUser 1.0) +(related User62 load62a hasLoad 1.0) +(related User11 load11a hasLoad 1.0) +(related west6 User61 hasUser 1.0) +(related User71 load71a hasLoad 1.0) +(related west7 User71 isInFrontOf 1.0) +(related User11 load11c hasLoad 1.0) +(related west7 User71 hasUser 1.0) +(related east2 User22 hasUser 1.0) +(related User21 User22 isInFrontOf 1.0) +(related User63 load63b hasLoad 1.0) +(related west6 User62 hasUser 1.0) +(related west6 User62 hasUser 1.0) +(related west7 User70 hasUser 1.0) +(related west1 User19 hasUser 1.0) +(related west1 User162 hasUser 1.0) +(related west1 User102 hasUser 1.0) +(related west1 User192 hasUser 1.0) +(related west2 User221 hasUser 1.0) +(related west2 User200 hasUser 1.0) +(related west6 User247 hasUser 1.0) +(related east1 User11 isInFrontOf 1.0) +(related User12 User13 isInFrontOf 1.0) +(related User61 User62 isInFrontOf 1.0) +(related User12 load12a hasLoad 1.0) +(related User11 User12 isInFrontOf 1.0) +(related east1 User12 hasUser 1.0) +(related User72 load72c hasLoad 1.0) +(related User22 load22a hasLoad 1.0) +(related east2 User21 isInFrontOf 1.0) +(related east2 User221 isInFrontOf 1.0) +(related east2 User215 isInFrontOf 1.0) +(related east2 User245 isInFrontOf 1.0) +(related east2 User200 isInFrontOf 1.0) +(related east1 User121 isInFrontOf 1.0) +(related east1 User109 isInFrontOf 1.0) +(related east1 User121 isInFrontOf 1.0) +(related east1 User149 isInFrontOf 1.0) +(related east1 User191 isInFrontOf 1.0) +(related east1 User199 isInFrontOf 1.0) +(related User71 User72 isInFrontOf 1.0) +(related User71 load71b hasLoad 1.0) +(related User21 load21a hasLoad 1.0) +(related User62 User63 isInFrontOf 1.0) +(related User11 load11b hasLoad 1.0) +(related User72 load72a hasLoad 1.0) + +(instance User197 (= hasUserSuccessVeryLow) 1.0 ) +(instance User208 (= hasUserSuccessMiddle) 1.0 ) +(instance User225 (= hasUserSuccessMiddle) 1.0 ) +(instance User249 (= hasUserSuccessLow) 1.0 ) +(instance User258 (= hasUserSuccessHigh) 1.0 ) +(instance User134 (= hasUserSuccessHigh) 1.0 ) +(instance User140 (= hasUserSuccessLow) 1.0 ) +(instance User173 (= hasUserSuccessHigh) 1.0 ) +(instance User65 (= hasUserSuccessMiddle) 1.0 ) +(instance User50 (= hasUserSuccessHigh) 1.0 ) +(instance User4 (= hasUserSuccessLow) 1.0 ) +(instance User12 (= hasUserSuccessHigh) 1.0 ) +(instance User17 (= hasUserSuccessVeryLow) 1.0 ) +(instance User13 (= hasUserSuccessLow) 1.0 ) + +(disjoint User Load ) +(disjoint User EvKnowledge ) +(disjoint Load EvKnowledge ) +(define-concept SuccessfulUser (and User (some hasUserSuccess fuzzySuccessfulUser))) +(define-concept UnsuccessfulUser (and User (some hasUserSuccess fuzzyUnsuccessfulUser))) +(define-concept MediumSuccessUser (and User (some hasUserSuccess fuzzyMediumSuccessUser))) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-11-19 12:04:02
|
Revision: 4152 http://sourceforge.net/p/dl-learner/code/4152 Author: lorenz_b Date: 2013-11-19 12:03:59 +0000 (Tue, 19 Nov 2013) Log Message: ----------- Updated fuzzy component. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/isle/textretrieval/RDFSLabelEntityTextRetriever.java trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/SemanticBibleExperiment.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/QALDExperiment.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/utilities/FuzzyOwl2.java trunk/components-core/src/main/java/org/dllearner/utilities/FuzzyOwl2toFuzzyDL.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2013-11-18 09:42:55 UTC (rev 4151) +++ trunk/components-core/pom.xml 2013-11-19 12:03:59 UTC (rev 4152) @@ -177,11 +177,17 @@ <version>1.0</version> </dependency> +<!-- <dependency> --> +<!-- <groupId>fuzzydll</groupId> --> +<!-- <artifactId>fuzzyowl2fuzzydlparser</artifactId> --> +<!-- <version>1.0</version> --> +<!-- </dependency> --> + <dependency> - <groupId>fuzzydll</groupId> - <artifactId>fuzzyowl2fuzzydlparser</artifactId> - <version>1.0</version> - </dependency> + <groupId>org.fuzzy</groupId> + <artifactId>fuzzyowl</artifactId> + <version>1.0</version> + </dependency> <dependency> <groupId>edu.northwestern.at</groupId> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/textretrieval/RDFSLabelEntityTextRetriever.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/textretrieval/RDFSLabelEntityTextRetriever.java 2013-11-18 09:42:55 UTC (rev 4151) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/textretrieval/RDFSLabelEntityTextRetriever.java 2013-11-19 12:03:59 UTC (rev 4152) @@ -3,13 +3,27 @@ */ package org.dllearner.algorithms.isle.textretrieval; +import java.io.File; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; + +import org.dllearner.core.owl.Entity; import org.dllearner.kb.OWLAPIOntology; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; +import com.google.common.base.Charsets; +import com.google.common.io.Files; + /** * @author Lorenz Buehmann * @@ -23,4 +37,27 @@ public RDFSLabelEntityTextRetriever(OWLAPIOntology ontology) { super(ontology, new OWLDataFactoryImpl().getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI())); } + + public static void main(String[] args) throws Exception { + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLOntology ontology = man.loadOntology(IRI.create("http://www.semanticbible.com/2006/11/NTNames.owl")); + + RDFSLabelEntityTextRetriever labelRetriever = new RDFSLabelEntityTextRetriever(ontology); + Map<Entity, Set<String>> relevantText = labelRetriever.getRelevantText(ontology); + SortedMap<String, String> uri2Labels = new TreeMap<String, String>(); + + for (Entry<Entity, Set<String>> entry : relevantText.entrySet()) { + Entity key = entry.getKey(); + Set<String> value = entry.getValue(); + uri2Labels.put(key.getName(), value.iterator().next()); + } + + StringBuilder csv = new StringBuilder(); + for (Entry<String, String> entry : uri2Labels.entrySet()) { + String uri = entry.getKey(); + String label = entry.getValue(); + csv.append(uri).append(",").append(label).append("\n"); + } + Files.write(csv, new File("semantic-bible-labels.csv"), Charsets.UTF_8); + } } Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2013-11-18 09:42:55 UTC (rev 4151) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2013-11-19 12:03:59 UTC (rev 4152) @@ -19,7 +19,9 @@ package org.dllearner.reasoning.fuzzydll; +import java.io.ByteArrayOutputStream; import java.io.FileInputStream; +import java.io.PrintStream; import java.io.PrintWriter; import java.io.StringWriter; import java.util.HashSet; @@ -30,6 +32,7 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; +import org.dllearner.utilities.FuzzyOwl2toFuzzyDL; import org.semanticweb.owlapi.model.AxiomType; import org.semanticweb.owlapi.model.OWLAxiom; import org.semanticweb.owlapi.model.OWLClass; @@ -37,7 +40,6 @@ import org.semanticweb.owlapi.model.OWLDataFactory; import org.semanticweb.owlapi.model.OWLDataProperty; import org.semanticweb.owlapi.model.OWLDataPropertyExpression; -import org.semanticweb.owlapi.model.OWLEntity; import org.semanticweb.owlapi.model.OWLIndividual; import org.semanticweb.owlapi.model.OWLLiteral; import org.semanticweb.owlapi.model.OWLNamedIndividual; @@ -68,6 +70,7 @@ import com.clarkparsia.pellet.owlapiv3.PelletReasoner; import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; +import edu.stanford.nlp.io.StringOutputStream; import fuzzydl.AllInstancesQuery; import fuzzydl.Concept; import fuzzydl.ConfigReader; @@ -78,8 +81,6 @@ import fuzzydl.exception.FuzzyOntologyException; import fuzzydl.milp.Solution; import fuzzydl.parser.Parser; -import fuzzydll.fuzzyowl2fuzzydlparser.FuzzyOwl2toFuzzyDL; -import fuzzydll.fuzzyowl2fuzzydlparser.OWLAPI_fuzzyDLObjectParser; public class FuzzyDLReasonerManager implements OWLReasoner { @@ -104,6 +105,8 @@ // private PrintStream out; // private int counter = 1; // private int counter2 = 1; + + private ByteArrayOutputStream baos; public FuzzyDLReasonerManager(String ontologyFile, OWLOntology ontology, OWLReasonerConfiguration conf, OWLDataFactory factory, String baseURI) throws Exception { @@ -132,12 +135,27 @@ fuzzyKB = parseOWLontologyToFuzzyDLsyntax(ontologyFile); // fuzzyFileParser.setBaseKB(fuzzyKB); - OWLAPI_fuzzyDLObjectParser.setParsingFuzzyKB(fuzzyFileParser, fuzzyKB); +// OWLAPI_fuzzyDLObjectParser.setParsingFuzzyKB(fuzzyFileParser, fuzzyKB); + baos = new ByteArrayOutputStream(); + fuzzyFileParser.setPrintStream(new PrintStream(baos)); + solveKB(); - // errorFile = new FileOutputStream("errorFile.txt"); + // errorFile = new FileOutputStream("errorFile.txt")name; } + + private Concept convert(OWLClassExpression classExpression){ + baos.reset(); + String name = fuzzyFileParser.getClassName(classExpression); + return fuzzyKB.getConcept(name); + } + + private Individual convert(OWLIndividual individual){ + baos.reset(); + String name = fuzzyFileParser.getIndividualName(individual); + return fuzzyKB.getIndividual(name); + } private void startPellet(OWLOntology ontology, OWLReasonerConfiguration conf) { // instantiate Pellet reasoner @@ -173,9 +191,10 @@ // added by Josue public double getFuzzyMembership(OWLClassExpression oce, OWLIndividual i) { - - Individual fIndividual = fuzzyKB.getIndividual(shortFormParser.getShortForm((OWLEntity) i)); - Concept fConcept = OWLAPI_fuzzyDLObjectParser.getFuzzyDLExpresion(oce); + + Individual fIndividual = convert(i); + Concept fConcept = convert(oce); + System.out.println(fConcept + "(" + fIndividual + ")?"); try { Query q = new MinInstanceQuery(fConcept, fIndividual); @@ -215,7 +234,6 @@ // Scanner sc = new Scanner(System.in); // sc.nextLine(); } - // return (1 - Math.abs(truthDegree - queryResult.getSolution())); return queryResult.getSolution(); } @@ -379,7 +397,7 @@ Set<OWLNamedIndividual> owlApiInstances = owlApiOutput.getFlattened(); //get all instances using FuzzyDL try { - Concept fuzzyConcept = OWLAPI_fuzzyDLObjectParser.getFuzzyDLExpresion(cls); + Concept fuzzyConcept = convert(cls); AllInstancesQuery query = new AllInstancesQuery(fuzzyConcept); Solution solution = query.solve(fuzzyKB); if(solution.isConsistentKB() && solution.getSolution() == 0){ Added: trunk/components-core/src/main/java/org/dllearner/utilities/FuzzyOwl2.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/FuzzyOwl2.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/utilities/FuzzyOwl2.java 2013-11-19 12:03:59 UTC (rev 4152) @@ -0,0 +1,1929 @@ +package org.dllearner.utilities; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.DataRangeType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLAnnotationValue; +import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataCardinalityRestriction; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLDataPropertyExpression; +import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLDeclarationAxiom; +import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; +import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; +import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectCardinalityRestriction; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; +import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; +import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLProperty; +import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; +import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; +import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; +import org.semanticweb.owlapi.util.SimpleShortFormProvider; +import org.semanticweb.owlapi.vocab.OWLFacet; + +import fuzzyowl2.ChoquetConcept; +import fuzzyowl2.ConceptDefinition; +import fuzzyowl2.FuzzyConcept; +import fuzzyowl2.FuzzyDatatype; +import fuzzyowl2.FuzzyLogic; +import fuzzyowl2.FuzzyModifier; +import fuzzyowl2.FuzzyNominalConcept; +import fuzzyowl2.FuzzyProperty; +import fuzzyowl2.LeftShoulderFunction; +import fuzzyowl2.LinearFunction; +import fuzzyowl2.LinearModifier; +import fuzzyowl2.ModifiedConcept; +import fuzzyowl2.ModifiedFunction; +import fuzzyowl2.ModifiedProperty; +import fuzzyowl2.OwaConcept; +import fuzzyowl2.PropertyDefinition; +import fuzzyowl2.QowaConcept; +import fuzzyowl2.QuasiSugenoConcept; +import fuzzyowl2.RightShoulderFunction; +import fuzzyowl2.SugenoConcept; +import fuzzyowl2.TrapezoidalFunction; +import fuzzyowl2.TriangularFunction; +import fuzzyowl2.TriangularModifier; +import fuzzyowl2.WeightedConcept; +import fuzzyowl2.WeightedMaxConcept; +import fuzzyowl2.WeightedMinConcept; +import fuzzyowl2.WeightedSumConcept; +import fuzzyowl2.parser.Parser; + + +/** + * General class translating from OWL 2 into some fuzzy Description Logic language. + * Subclasses of Owl2ToFuzzyDescriptionLogic translate it into specific + * languages, such as the language of fuzzyDL, the language of DeLorean... + * The user must override most of the following methods: + * + * <ul> + <li>protected String getAtomicConceptName(OWLClass c)</li> + <li>protected String getAtomicDataPropertyName(OWLDataProperty p)</li> + <li>protected String getAtomicObjectPropertyName(OWLObjectProperty p)</li> + <li>protected String getBottomConceptName()</li> + <li>protected String getBottomDataPropertyName()</li> + <li>protected String getBottomObjectPropertyName()</li> + <li>protected String getDataAllValuesFromName(OWLDataPropertyExpression p, OWLDataRange range)</li> + <li>protected String getDataExactCardinalityRestrictionName(int card, OWLDataPropertyExpression p)</li> + <li>protected String getDataExactCardinalityRestrictionName(int card, OWLDataPropertyExpression p, OWLDataRange range)</li> + <li>protected String getDataHasValueName(OWLDataPropertyExpression p, OWLLiteral lit)</li> + <li>protected String getDataMaxCardinalityRestrictionName(int card, OWLDataPropertyExpression p)</li> + <li>protected String getDataMaxCardinalityRestrictionName(int card, OWLDataPropertyExpression p, OWLDataRange range)</li> + <li>protected String getDataMinCardinalityRestrictionName(int card, OWLDataPropertyExpression p)</li> + <li>protected String getDataMinCardinalityRestrictionName(int card, OWLDataPropertyExpression p, OWLDataRange range)</li> + <li>protected String getDataSomeValuesFromName(OWLDataPropertyExpression p, OWLDataRange range)</li> + <li>protected String getIndividualName(OWLIndividual i)</li> + <li>protected String getObjectAllValuesFromName(OWLObjectPropertyExpression p, OWLClassExpression c)</li> + <li>protected String getObjectComplementOfName(OWLClassExpression c)</li> + <li>protected String getObjectExactCardinalityRestrictionName(int card, OWLObjectPropertyExpression p)</li> + <li>protected String getObjectExactCardinalityRestrictionName(int card, OWLObjectPropertyExpression p, OWLClassExpression c)</li> + <li>protected String getObjectHasSelfName(OWLObjectPropertyExpression p)</li> + <li>protected String getObjectHasValueName(OWLObjectPropertyExpression p, OWLIndividual i)</li> + <li>protected String getObjectIntersectionOfName(Set<OWLClassExpression> operands)</li> + <li>protected String getObjectMaxCardinalityRestrictionName(int card, OWLObjectPropertyExpression p)</li> + <li>protected String getObjectMaxCardinalityRestrictionName(int card, OWLObjectPropertyExpression p, OWLClassExpression c)</li> + <li>protected String getObjectMinCardinalityRestrictionName(int card, OWLObjectPropertyExpression p)</li> + <li>protected String getObjectMinCardinalityRestrictionName(int card, OWLObjectPropertyExpression p, OWLClassExpression c)</li> + <li>protected String getObjectOneOfName(Set<OWLIndividual> set)</li> + <li>protected String getObjectSomeValuesFromName(OWLObjectPropertyExpression p, OWLClassExpression c)</li> + <li>protected String getObjectUnionOfName(Set<OWLClassExpression> operands)</li> + <li>protected String getShortName(OWLEntity e)</li> + <li>protected String getTopConceptName()</li> + <li>protected String getTopDataPropertyName()</li> + <li>protected String getTopObjectPropertyName()</li> + <li>protected void writeAsymmetricObjectPropertyAxiom(OWLObjectPropertyExpression p)</li> + <li>protected void writeChoquetConceptDefinition(String name, ChoquetConcept c)</li> + <li>protected void writeConceptAssertionAxiom(OWLIndividual i, OWLClassExpression c, double d)</li> + <li>protected void writeConceptDeclaration(OWLClassExpression c)</li> + <li>protected void writeDataPropertyAssertionAxiom(OWLIndividual i1, OWLLiteral i2, OWLDataPropertyExpression p, double d)</li> + <li>protected void writeDataPropertyDeclaration(OWLDataPropertyExpression dp)</li> + <li>protected void writeDataPropertyDomainAxiom(OWLDataPropertyExpression p, OWLClassExpression c)</li> + <li>protected void writeDataPropertyRangeAxiom(OWLDataPropertyExpression p, OWLDataRange c)</li> + <li>protected void writeDifferentIndividualsAxiom(Set<OWLIndividual> set)</li> + <li>protected void writeDisjointClassesAxiom(Set<OWLClassExpression> set)</li> + <li>protected void writeDisjointDataPropertiesAxiom(Set<OWLDataPropertyExpression> set)</li> + <li>protected void writeDisjointObjectPropertiesAxiom(Set<OWLObjectPropertyExpression> set)</li> + <li>protected void writeDisjointUnionAxiom(Set<OWLClassExpression> set)</li> + <li>protected void writeEquivalentClassesAxiom(Set<OWLClassExpression> set)</li> + <li>protected void writeEquivalentDataPropertiesAxiom(Set<OWLDataPropertyExpression> set)</li> + <li>protected void writeEquivalentObjectPropertiesAxiom(Set<OWLObjectPropertyExpression> set)</li> + <li>protected void writeFunctionalDataPropertyAxiom(OWLDataPropertyExpression p)</li> + <li>protected void writeFunctionalObjectPropertyAxiom(OWLObjectPropertyExpression p)</li> + <li>protected void writeFuzzyLogic(FuzzyLogic logic)</li> + <li>protected void writeFuzzyNominalConceptDefinition(String name, FuzzyNominalConcept c)</li> + <li>protected void writeInverseFunctionalObjectPropertyAxiom(OWLObjectPropertyExpression p)</li> + <li>protected void writeInverseObjectPropertiesAxiom(OWLObjectPropertyExpression p1, OWLObjectPropertyExpression p2)</li> + <li>protected void writeIrreflexiveObjectPropertyAxiom(OWLObjectPropertyExpression p)</li> + <li>protected void writeLeftShoulderFunctionDefinition(String name, LeftShoulderFunction dat)</li> + <li>protected void writeLinearFunctionDefinition(String name, LinearFunction dat)</li> + <li>protected void writeLinearModifierDefinition(String name, LinearModifier mod)</li> + <li>protected void writeModifiedConceptDefinition(String name, ModifiedConcept c)</li> + <li>protected void writeModifiedFunctionDefinition(String name, ModifiedFunction dat)</li> + <li>protected void writeModifiedPropertyDefinition(String name, ModifiedProperty c)</li> + <li>protected void writeNegativeDataPropertyAssertionAxiom(OWLIndividual i1, OWLLiteral i2, OWLDataPropertyExpression p, double d)</li> + <li>protected void writeNegativeObjectPropertyAssertionAxiom(OWLIndividual i1, OWLIndividual i2, OWLObjectPropertyExpression p, double d)</li> + <li>protected void writeObjectPropertyAssertionAxiom(OWLIndividual i1, OWLIndividual i2, OWLObjectPropertyExpression p, double d)</li> + <li>protected void writeObjectPropertyDeclaration(OWLObjectPropertyExpression op)</li> + <li>protected void writeObjectPropertyDomainAxiom(OWLObjectPropertyExpression p, OWLClassExpression c)</li> + <li>protected void writeObjectPropertyRangeAxiom(OWLObjectPropertyExpression p, OWLClassExpression c)</li> + <li>protected void writeOwaConceptDefinition(String name, OwaConcept c)</li> + <li>protected void writeQowaConceptDefinition(String name, QowaConcept c)</li> + <li>protected void writeQuasiSugenoConceptDefinition(String name, QuasiSugenoConcept c)</li> + <li>protected void writeReflexiveObjectPropertyAxiom(OWLObjectPropertyExpression p)</li> + <li>protected void writeRightShoulderFunctionDefinition(String name, RightShoulderFunction dat)</li> + <li>protected void writeSameIndividualAxiom(Set<OWLIndividual> set)</li> + <li>protected void writeSubclassOfAxiom(OWLClassExpression subclass, OWLClassExpression superclass, double d)</li> + <li>protected void writeSubDataPropertyOfAxiom(OWLDataPropertyExpression subProperty, OWLDataPropertyExpression superProperty, double d)</li> + <li>protected void writeSubObjectPropertyOfAxiom(OWLObjectPropertyExpression subProperty, OWLObjectPropertyExpression superProperty, double d)</li> + <li>protected void writeSubPropertyChainOfAxiom(List<OWLObjectPropertyExpression> chain, OWLObjectPropertyExpression superProperty, double d)</li> + <li>protected void writeSugenoConceptDefinition(String name, SugenoConcept c)</li> + <li>protected void writeSymmetricObjectPropertyAxiom(OWLObjectPropertyExpression p)</li> + <li>protected void writeTransitiveObjectPropertyAxiom(OWLObjectPropertyExpression p)</li> + <li>protected void writeTrapezoidalFunctionDefinition(String name, TrapezoidalFunction dat)</li> + <li>protected void writeTriangularFunctionDefinition(String name, TriangularFunction dat)</li> + <li>protected void writeTriangularModifierDefinition(String name, TriangularModifier mod)</li> + <li>protected void writeWeightedConceptDefinition(String name, WeightedConcept c)</li> + <li>protected void writeWeightedMaxConceptDefinition(String name, WeightedMaxConcept c)</li> + <li>protected void writeWeightedMinConceptDefinition(String name, WeightedMinConcept c)</li> + <li>protected void writeWeightedSumConceptDefinition(String name, WeightedSumConcept c)</li> + * </ul> + * + * @author Fernando Bobillo + */ +public class FuzzyOwl2 +{ + + protected OWLDataFactory dataFactory; + protected Hashtable<String, FuzzyConcept> definedConcepts; + protected Hashtable<String, FuzzyProperty> definedProperties; + protected Hashtable<String, FuzzyDatatype> fuzzyDatatypes; + protected Hashtable<String, FuzzyModifier> fuzzyModifiers; + protected OWLAnnotationProperty label; + protected OWLOntologyManager manager; + protected String ontologyPath; + protected OWLOntology ontology; + protected Set<OWLOntology> ontologies; + protected SimpleShortFormProvider pm; + + protected final double NEG_INFINITY = -10000; + protected final double POS_INFINITY = 10000; + + /** + * Output (file, standard output...) + */ + protected static PrintStream out = System.out; + + + /** + * Constructor. + * @param input Path of the input ontology. + * @param output Path of the output file; null for the standard output. + */ + public FuzzyOwl2(String input, String output) + { + definedConcepts = new Hashtable<String, FuzzyConcept> (); + definedProperties = new Hashtable<String, FuzzyProperty> (); + fuzzyDatatypes = new Hashtable<String, FuzzyDatatype> (); + fuzzyModifiers = new Hashtable<String, FuzzyModifier> (); + manager = OWLManager.createOWLOntologyManager(); + ontologyPath = input; + + loadOntology(ontologyPath); + ontologies = new HashSet<OWLOntology>(); + ontologies.add(ontology); + + // Imported ontologies + Set<OWLOntology> imports = manager.getImportsClosure(ontology); + if (imports != null) + ontologies.addAll(imports); + + // If an output file is specified, try to open it. + // If not, or if there are problems opening it, we use the standard output. + if (output != null) + { + try { + out = new PrintStream(new FileOutputStream(output)); + } + catch (Exception ex) + { + printError("Could not load ontology: " + ex.getMessage()); + } + } + + dataFactory = manager.getOWLDataFactory(); + if (ontology.getOntologyID().getOntologyIRI() == null) + ontologyPath = ""; + else + ontologyPath = ontology.getOntologyID().getOntologyIRI().toString(); + pm = new SimpleShortFormProvider(); + + label = dataFactory.getOWLAnnotationProperty(IRI.create(ontologyPath + "#" + "fuzzyLabel")); + } + + public void setPrintStream(PrintStream ps){ + out = ps; + } + + protected void loadOntology(String ontologyPath) + { + try + { + // Try ontologyPath as the path of a local file + File f = new File(ontologyPath); + IRI iri = IRI.create(f); + ontology = manager.loadOntologyFromOntologyDocument(iri); + } + catch (Exception e) + { + // Try ontologyPath as an IRI + IRI iri = IRI.create(ontologyPath); + try { + ontology = manager.loadOntologyFromOntologyDocument(iri); + } + catch (OWLOntologyCreationException ex) + { + printError("Could not load ontology: " + ex.getMessage()); + } + } + } + + + /** + * Prints an error message in the standard output and finishes the execution. + * @param s An error message. + */ + protected static void exit(String s) + { + System.out.println(s); + System.exit(0); + } + + + /** + * Prints a string in the desired PrintStream, unless it contains a null value. + */ + protected static void print(String s) + { + try + { + if (s.contains(" null") == false) + out.println(s); + } + catch (NullPointerException ex) + { + + } + + } + + /** + * Prints an error string in the standard error. + * The parameter could be used in the future to write in the desired PrintStream. + */ + protected static void printError(String s) + { + System.err.println(s); + } + + + /** + * @param args Two arguments: the input OWL 2 ontology, and the output fuzzy ontology in fuzzyDL syntax. + */ + public static void main(String[] args) + { + String[] returnValue = processParameters(args); + FuzzyOwl2 f = new FuzzyOwl2(returnValue[0], returnValue[1]); + f.translateOwl2Ontology(); + } + + + /** + * Translates an OWL 2 ontology into a fuzzy one, processing the OWL 2 annotations. + */ + public void translateOwl2Ontology() + { + processOntologyAnnotations(); + processDatatypeAnnotations(); + processConceptAnnotations(); + processPropertyAnnotations(); + processOntologyAxioms(); + } + + + /** + * Write annotations on the ontology. + */ + protected void processOntologyAnnotations() + { + for(OWLOntology o : ontologies) + { + Set<OWLAnnotation> annotations = o.getAnnotations(); + + for (OWLAnnotation ax : annotations) + { + if (ax.getProperty().compareTo(label) != 0) + continue; + + OWLAnnotationValue value = ax.getValue(); + FuzzyLogic logic = Parser.getLogic(value.toString()); + writeFuzzyLogic(logic); + } + } + } + + + // We annotate left, right, triangular, and trapezoidal functions. + private void writeType1Datatypes(Object o, String name) + { + if (o instanceof LeftShoulderFunction) + { + LeftShoulderFunction dat = (LeftShoulderFunction) o; + double k[] = new double[2]; + getK1AndK2(name, k); + setK1AndK2(dat, k); + fuzzyDatatypes.put(name, dat); + writeLeftShoulderFunctionDefinition(name, dat); + } + else if (o instanceof RightShoulderFunction) + { + RightShoulderFunction dat = (RightShoulderFunction) o; + double k[] = new double[2]; + getK1AndK2(name, k); + setK1AndK2(dat, k); + fuzzyDatatypes.put(name, dat); + writeRightShoulderFunctionDefinition(name, dat); + } + else if (o instanceof TriangularFunction) + { + TriangularFunction dat = (TriangularFunction) o; + double k[] = new double[2]; + getK1AndK2(name, k); + setK1AndK2(dat, k); + fuzzyDatatypes.put(name, dat); + writeTriangularFunctionDefinition(name, dat); + } + else if (o instanceof TrapezoidalFunction) + { + TrapezoidalFunction dat = (TrapezoidalFunction) o; + double k[] = new double[2]; + getK1AndK2(name, k); + setK1AndK2(dat, k); + fuzzyDatatypes.put(name, dat); + writeTrapezoidalFunctionDefinition(name, dat); + } + else if (o instanceof LinearFunction) + { + LinearFunction dat = (LinearFunction) o; + double k[] = new double[2]; + getK1AndK2(name, k); + setK1AndK2(dat, k); + fuzzyDatatypes.put(name, dat); + writeLinearFunctionDefinition(name, dat); + } + } + + + // We annotate linear and triangular modifiers. + private void writeType2Datatypes(Object o, String name) + { + if (o instanceof TriangularModifier) + { + TriangularModifier mod = (TriangularModifier) o; + fuzzyModifiers.put(name, mod); + writeTriangularModifierDefinition(name, mod); + } + else if (o instanceof LinearModifier) + { + LinearModifier mod = (LinearModifier) o; + fuzzyModifiers.put(name, mod); + writeLinearModifierDefinition(name, mod); + } + } + + + // We annotate modified functions. + private void writeType3Datatypes(Object o, String name) + { + if (o instanceof ModifiedFunction) + { + ModifiedFunction dat = (ModifiedFunction) o; + fuzzyDatatypes.put(name, dat); + writeModifiedFunctionDefinition(name, dat); + } + } + + + /** + * Write fuzzy datatypes and modifiers definitions, defined with OWL 2 concept annotations. + */ + protected void processDatatypeAnnotations() + { + /* + * Step 1. We annotate left, right, triangular, trapezoidal, and linear functions. + * Step 2. We annotate linear and triangular modifiers. + * Step 3. We annotate modified functions. + */ + for(OWLOntology o : ontologies) + { + for (OWLDeclarationAxiom ax : o.getAxioms(AxiomType.DECLARATION)) + { + OWLEntity ent = ax.getEntity(); + if (ent.isOWLDatatype()) + { + OWLDatatype dt = ent.asOWLDatatype(); + Set<OWLAnnotation> annotations = dt.getAnnotations(o, label); + if (annotations != null) + { + if (annotations.size() > 1) + exit("Error: There are more than" + annotations.size() + " annotations for datatype " + dt + "."); + else if (annotations.size() == 1) + { + Iterator<OWLAnnotation> it = annotations.iterator(); + OWLAnnotation next = it.next(); + Object ob = Parser.getDatatype(next.getValue().toString()); + if (ob != null) + writeType1Datatypes(ob, getShortName(dt)); + } + } + } + } + + for (OWLDeclarationAxiom ax : o.getAxioms(AxiomType.DECLARATION)) + { + OWLEntity ent = ax.getEntity(); + if (ent.isOWLDatatype()) + { + OWLDatatype dt = ent.asOWLDatatype(); + Set<OWLAnnotation> annotations = dt.getAnnotations(o, label); + if (annotations != null) + { + if (annotations.size() == 1) + { + Iterator<OWLAnnotation> it = annotations.iterator(); + OWLAnnotation next = it.next(); + Object ob = Parser.getDatatype(next.getValue().toString()); + if (ob != null) + writeType2Datatypes(ob, getShortName(dt)); + } + } + } + } + + for (OWLDeclarationAxiom ax : o.getAxioms(AxiomType.DECLARATION)) + { + OWLEntity ent = ax.getEntity(); + if (ent.isOWLDatatype()) + { + OWLDatatype dt = ent.asOWLDatatype(); + Set<OWLAnnotation> annotations = dt.getAnnotations(o, label); + if (annotations != null) + { + if (annotations.size() == 1) + { + Iterator<OWLAnnotation> it = annotations.iterator(); + OWLAnnotation next = it.next(); + Object ob = Parser.getDatatype(next.getValue().toString()); + if (ob != null) + writeType3Datatypes(ob, getShortName(dt)); + } + } + } + } + } + } + + + /** + * Write fuzzy concept definitions, defined with OWL 2 concept annotations. + */ + protected void processConceptAnnotations() + { + for(OWLOntology o : ontologies) + { + for (OWLDeclarationAxiom ax : o.getAxioms(AxiomType.DECLARATION)) + { + OWLEntity ent = ax.getEntity(); + if (ent.isOWLClass()) + { + OWLClass cls = ent.asOWLClass(); + Set<OWLAnnotation> annotations = cls.getAnnotations(o, label); + + if (annotations.size() > 1) + exit("Error: There are " + annotations.size() + " class annotations for " + cls + "."); + else if (annotations.size() == 1) + { + String name = getShortName(cls); + + ConceptDefinition c = Parser.getDefinedConcept(annotations.iterator().next().getValue().toString()); + if (c != null) + { + switch (c.getType()) + { + case MODIFIED_CONCEPT: + String modName = c.getFuzzyModifier(); + if (fuzzyModifiers.containsKey(modName)) + { + ModifiedConcept md = new ModifiedConcept(modName, c.getFuzzyConcept()); + definedConcepts.put(name, md); + writeModifiedConceptDefinition(name, md); + } + else + exit("Error: Fuzzy modifier " + modName + " not defined."); + break; + + case FUZZY_NOMINAL: + FuzzyNominalConcept nc = new FuzzyNominalConcept(c.getNumber(), c.getIndividual()); + definedConcepts.put(name, nc); + writeFuzzyNominalConceptDefinition(name, nc); + break; + + case WEIGHTED_CONCEPT: + WeightedConcept wc = new WeightedConcept(c.getNumber(), c.getFuzzyConcept()); + definedConcepts.put(name, wc); + writeWeightedConceptDefinition(name, wc); + break; + + case WEIGHTED_MAX: + List<ConceptDefinition> sourceList = c.getWeightedConcepts(); + ArrayList<WeightedConcept> list = new ArrayList<WeightedConcept>(); + for(ConceptDefinition def : sourceList) + list.add(new WeightedConcept(def.getNumber(), def.getFuzzyConcept() ) ); + WeightedMaxConcept wmax = new WeightedMaxConcept(list); + definedConcepts.put(name, wmax); + writeWeightedMaxConceptDefinition(name, wmax); + break; + + case WEIGHTED_MIN: + sourceList = c.getWeightedConcepts(); + list = new ArrayList<WeightedConcept>(); + for(ConceptDefinition def : sourceList) + list.add(new WeightedConcept(def.getNumber(), def.getFuzzyConcept() ) ); + WeightedMinConcept wmin = new WeightedMinConcept(list); + definedConcepts.put(name, wmin); + writeWeightedMinConceptDefinition(name, wmin); + break; + + case WEIGHTED_SUM: + sourceList = c.getWeightedConcepts(); + list = new ArrayList<WeightedConcept>(); + for(ConceptDefinition def : sourceList) + list.add(new WeightedConcept(def.getNumber(), def.getFuzzyConcept() ) ); + WeightedSumConcept wsum = new WeightedSumConcept(list); + definedConcepts.put(name, wsum); + writeWeightedSumConceptDefinition(name, wsum); + break; + + case OWA: + List<Double> weights = c.getWeights(); + List<String> concepts = c.getConcepts(); + if (weights.size() != concepts.size()) + exit("Error: OWA concept " + name + " has different number of weights and concepts."); + else + { + OwaConcept owa = new OwaConcept(weights, concepts); + definedConcepts.put(name, owa); + writeOwaConceptDefinition(name, owa); + } + break; + + case CHOQUET: + weights = c.getWeights(); + concepts = c.getConcepts(); + if (weights.size() != concepts.size()) + exit("Error: Choquet concept " + name + " has different number of weights and concepts."); + else + { + ChoquetConcept owa = new ChoquetConcept(weights, concepts); + definedConcepts.put(name, owa); + writeChoquetConceptDefinition(name, owa); + } + break; + + case SUGENO: + weights = c.getWeights(); + concepts = c.getConcepts(); + if (weights.size() != concepts.size()) + exit("Error: Sugeno concept " + name + " has different number of weights and concepts."); + else + { + SugenoConcept owa = new SugenoConcept(weights, concepts); + definedConcepts.put(name, owa); + writeSugenoConceptDefinition(name, owa); + } + break; + + case QUASI_SUGENO: + weights = c.getWeights(); + concepts = c.getConcepts(); + if (weights.size() != concepts.size()) + exit("Error: QuasiSugeno concept " + name + " has different number of weights and concepts."); + else + { + QuasiSugenoConcept owa = new QuasiSugenoConcept(weights, concepts); + definedConcepts.put(name, owa); + writeQuasiSugenoConceptDefinition(name, owa); + } + break; + + case QUANTIFIER_OWA: + String q = c.getQuantifier(); + if (!fuzzyDatatypes.containsKey(q)) + exit("Error: Quantifier " + q + " not defined."); + else // if (fuzzyDatatypes.containsKey(q)) + { + FuzzyDatatype def = fuzzyDatatypes.get(q); + if (!(def instanceof RightShoulderFunction) && !(def instanceof LinearFunction)) + exit("Error: Quantifier " + q + " must be a right-shoulder or a linear function."); + else { + concepts = c.getConcepts(); + QowaConcept qowa = new QowaConcept(q, concepts); + definedConcepts.put(name, qowa); + writeQowaConceptDefinition(name, qowa); + } + } + break; + } + } + } + } + } + } + } + + + /** + * Write fuzzy property definitions, defined with OWL 2 concept annotations. + */ + protected void processPropertyAnnotations() + { + for(OWLOntology o : ontologies) + { + for (OWLDeclarationAxiom ax : o.getAxioms(AxiomType.DECLARATION)) + { + OWLEntity ent = ax.getEntity(); + + if (ent.isOWLObjectProperty() || ent.isOWLDataProperty()) + { + OWLProperty prop; + if (ent.isOWLObjectProperty() ) + prop = ent.asOWLObjectProperty(); + else // if (ent.isOWLDataProperty() ) + prop = ent.asOWLDataProperty(); + + Set<OWLAnnotation> annotations = prop.getAnnotations(o, label); + + if (annotations.size() > 1) + exit("Error: There are " + annotations.size() + " property annotations for " + prop + "."); + else if (annotations.size() == 1) + { + PropertyDefinition pro = Parser.getDefinedProperty(annotations.iterator().next().getValue().toString()); + if (pro != null) + { + if (pro.getType() == PropertyDefinition.PropertyType.MODIFIED_PROPERTY) + { + String name = getShortName(prop); + String modName = pro.getFuzzyModifier(); + if (fuzzyModifiers.containsKey(modName)) + { + ModifiedProperty mp = new ModifiedProperty(modName, pro.getProperty()); + definedProperties.put(name, mp); + writeModifiedPropertyDefinition(name, mp); + } + else + exit("Error: Fuzzy modifier " + modName + " not defined."); + } + } + } + } + } + } + } + + + /** + * Write the axioms of the OWL 2 ontology. They can have annotations or not. + */ + protected void processOntologyAxioms() + { + + for(OWLOntology o : ontologies) + { + + // ****** + // TBOx + // ****** + for (OWLDisjointClassesAxiom ax : o.getAxioms(AxiomType.DISJOINT_CLASSES)) + { + Set<OWLClassExpression> c = ax.getClassExpressions(); + writeDisjointClassesAxiom(c); + } + + for (OWLDisjointUnionAxiom ax : o.getAxioms(AxiomType.DISJOINT_UNION)) + { + Set<OWLClassExpression> c = ax.getClassExpressions(); + writeDisjointUnionAxiom(c); + } + + for (OWLSubClassOfAxiom ax : o.getAxioms(AxiomType.SUBCLASS_OF)) + { + OWLClassExpression subclass = ax.getSubClass(); + OWLClassExpression superclass = ax.getSuperClass(); + double d = getDegree(ax); + writeSubclassOfAxiom(subclass, superclass, d); + } + + for (OWLEquivalentClassesAxiom ax : o.getAxioms(AxiomType.EQUIVALENT_CLASSES)) + { + Set<OWLClassExpression> c = ax.getClassExpressions(); + writeEquivalentClassesAxiom(c); + } + + for (OWLClass c : o.getClassesInSignature()) + { + if (c.isTopEntity() == false) + writeConceptDeclaration(c); + } + + + // ****** + // RBOx + // ****** + + for (OWLSubObjectPropertyOfAxiom ax : o.getAxioms(AxiomType.SUB_OBJECT_PROPERTY)) + { + OWLObjectPropertyExpression subProperty = ax.getSubProperty(); + OWLObjectPropertyExpression superProperty = ax.getSuperProperty(); + double d = getDegree(ax); + writeSubObjectPropertyOfAxiom(subProperty, superProperty, d); + } + + for (OWLSubDataPropertyOfAxiom ax : o.getAxioms(AxiomType.SUB_DATA_PROPERTY)) + { + OWLDataPropertyExpression subProperty = ax.getSubProperty(); + OWLDataPropertyExpression superProperty = ax.getSuperProperty(); + double d = getDegree(ax); + writeSubDataPropertyOfAxiom(subProperty, superProperty, d); + } + + for (OWLSubPropertyChainOfAxiom ax : o.getAxioms(AxiomType.SUB_PROPERTY_CHAIN_OF)) + { + List<OWLObjectPropertyExpression> chain = ax.getPropertyChain(); + OWLObjectPropertyExpression superProperty = ax.getSuperProperty(); + double d = getDegree(ax); + writeSubPropertyChainOfAxiom(chain, superProperty, d); + } + + for (OWLEquivalentObjectPropertiesAxiom ax : o.getAxioms(AxiomType.EQUIVALENT_OBJECT_PROPERTIES)) + { + Set<OWLObjectPropertyExpression> set = ax.getProperties(); + writeEquivalentObjectPropertiesAxiom(set); + } + + for (OWLEquivalentDataPropertiesAxiom ax : o.getAxioms(AxiomType.EQUIVALENT_DATA_PROPERTIES)) + { + Set<OWLDataPropertyExpression> set = ax.getProperties(); + writeEquivalentDataPropertiesAxiom(set); + } + + for (OWLTransitiveObjectPropertyAxiom ax : o.getAxioms(AxiomType.TRANSITIVE_OBJECT_PROPERTY)) + { + OWLObjectPropertyExpression p = ax.getProperty(); + writeTransitiveObjectPropertyAxiom(p); + } + + for (OWLSymmetricObjectPropertyAxiom ax : o.getAxioms(AxiomType.SYMMETRIC_OBJECT_PROPERTY)) + { + OWLObjectPropertyExpression p = ax.getProperty(); + writeSymmetricObjectPropertyAxiom(p); + } + + for (OWLAsymmetricObjectPropertyAxiom ax : o.getAxioms(AxiomType.ASYMMETRIC_OBJECT_PROPERTY)) + { + OWLObjectPropertyExpression p = ax.getProperty(); + writeAsymmetricObjectPropertyAxiom(p); + } + + for (OWLReflexiveObjectPropertyAxiom ax : o.getAxioms(AxiomType.REFLEXIVE_OBJECT_PROPERTY)) + { + OWLObjectPropertyExpression p = ax.getProperty(); + writeReflexiveObjectPropertyAxiom(p); + } + + for (OWLIrreflexiveObjectPropertyAxiom ax : o.getAxioms(AxiomType.IRREFLEXIVE_OBJECT_PROPERTY)) + { + OWLObjectPropertyExpression p = ax.getProperty(); + writeIrreflexiveObjectPropertyAxiom(p); + } + + for (OWLFunctionalObjectPropertyAxiom ax : o.getAxioms(AxiomType.FUNCTIONAL_OBJECT_PROPERTY)) + { + OWLObjectPropertyExpression p = ax.getProperty(); + writeFunctionalObjectPropertyAxiom(p); + } + + for (OWLFunctionalDataPropertyAxiom ax : o.getAxioms(AxiomType.FUNCTIONAL_DATA_PROPERTY)) + { + OWLDataPropertyExpression p = ax.getProperty(); + writeFunctionalDataPropertyAxiom(p); + } + + for (OWLInverseObjectPropertiesAxiom ax : o.getAxioms(AxiomType.INVERSE_OBJECT_PROPERTIES)) + { + OWLObjectPropertyExpression p1 = ax.getFirstProperty(); + OWLObjectPropertyExpression p2 = ax.getSecondProperty(); + writeInverseObjectPropertiesAxiom(p1, p2); + } + + for (OWLInverseFunctionalObjectPropertyAxiom ax : o.getAxioms(AxiomType.INVERSE_FUNCTIONAL_OBJECT_PROPERTY)) + { + OWLObjectPropertyExpression p = ax.getProperty(); + writeInverseFunctionalObjectPropertyAxiom(p); + } + + for (OWLObjectPropertyDomainAxiom ax : o.getAxioms(AxiomType.OBJECT_PROPERTY_DOMAIN)) + { + OWLObjectPropertyExpression p = ax.getProperty(); + OWLClassExpression c = ax.getDomain(); + writeObjectPropertyDomainAxiom(p, c); + } + + for (OWLObjectPropertyRangeAxiom ax : o.getAxioms(AxiomType.OBJECT_PROPERTY_RANGE)) + { + OWLObjectPropertyExpression p = ax.getProperty(); + OWLClassExpression c = ax.getRange(); + writeObjectPropertyRangeAxiom(p, c); + } + + for (OWLDataPropertyDomainAxiom ax : o.getAxioms(AxiomType.DATA_PROPERTY_DOMAIN)) + { + OWLDataPropertyExpression p = ax.getProperty(); + OWLClassExpression c = ax.getDomain(); + writeDataPropertyDomainAxiom(p, c); + } + + for (OWLDataPropertyRangeAxiom ax : o.getAxioms(AxiomType.DATA_PROPERTY_RANGE)) + { + OWLDataPropertyExpression p = ax.getProperty(); + OWLDataRange range = ax.getRange(); + writeDataPropertyRangeAxiom(p, range); + } + + for (OWLDisjointObjectPropertiesAxiom ax : o.getAxioms(AxiomType.DISJOINT_OBJECT_PROPERTIES)) + { + Set<OWLObjectPropertyExpression> properties = ax.getProperties(); + writeDisjointObjectPropertiesAxiom(properties); + } + + for (OWLDisjointDataPropertiesAxiom ax : o.getAxioms(AxiomType.DISJOINT_DATA_PROPERTIES)) + { + Set<OWLDataPropertyExpression> properties = ax.getProperties(); + writeDisjointDataPropertiesAxiom(properties); + } + +/* + for (OWLDataPropertyExpression dp : o.getDataPropertiesInSignature()) + { + writeDataPropertyDeclaration(dp); + } + + + for (OWLObjectPropertyExpression op : o.getObjectPropertiesInSignature()) + { + writeObjectPropertyDeclaration(op); + } +*/ + + // ****** + // ABOx + // ****** + + for (OWLClassAssertionAxiom ax : o.getAxioms(AxiomType.CLASS_ASSERTION)) + { + OWLClassExpression c = ax.getClassExpression(); + OWLIndividual i = ax.getIndividual(); + double d = getDegree(ax); + writeConceptAssertionAxiom(i, c, d); + } + + for (OWLObjectPropertyAssertionAxiom ax : o.getAxioms(AxiomType.OBJECT_PROPERTY_ASSERTION)) + { + OWLObjectPropertyExpression p = ax.getProperty(); + OWLIndividual i1 = ax.getSubject(); + OWLIndividual i2 = ax.getObject(); + double d = getDegree(ax); + writeObjectPropertyAssertionAxiom(i1, i2, p, d); + } + + for (OWLDataPropertyAssertionAxiom ax : o.getAxioms(AxiomType.DATA_PROPERTY_ASSERTION)) + { + OWLDataPropertyExpression p = ax.getProperty(); + OWLIndividual i1 = ax.getSubject(); + OWLLiteral i2 = ax.getObject(); + double d = getDegree(ax); + writeDataPropertyAssertionAxiom(i1, i2, p, d); + } + + for (OWLNegativeObjectPropertyAssertionAxiom ax : o.getAxioms(AxiomType.NEGATIVE_OBJECT_PROPERTY_ASSERTION)) + { + OWLObjectPropertyExpression p = ax.getProperty(); + OWLIndividual i1 = ax.getSubject(); + OWLIndividual i2 = ax.getObject(); + double d = getDegree(ax); + writeNegativeObjectPropertyAssertionAxiom(i1, i2, p, d); + } + + for (OWLNegativeDataPropertyAssertionAxiom ax : o.getAxioms(AxiomType.NEGATIVE_DATA_PROPERTY_ASSERTION)) + { + OWLDataPropertyExpression p = ax.getProperty(); + OWLIndividual i1 = ax.getSubject(); + OWLLiteral i2 = ax.getObject(); + double d = getDegree(ax); + writeNegativeDataPropertyAssertionAxiom(i1, i2, p, d); + } + + for (OWLSameIndividualAxiom ax: o.getAxioms(AxiomType.SAME_INDIVIDUAL)) + { + Set<OWLIndividual> set = ax.getIndividuals(); + writeSameIndividualAxiom(set); + } + + for (OWLDifferentIndividualsAxiom ax: o.getAxioms(AxiomType.DIFFERENT_INDIVIDUALS)) + { + Set<OWLIndividual> set = ax.getIndividuals(); + writeDifferentIndividualsAxiom(set); + } + } + } + + + /** + * Gets a String representation of an OWL 2 class. + * + * @param c An OWL 2 class. + * @return A String representation of c. + */ + public String getClassName(OWLClassExpression c) + { + + switch (c.getClassExpressionType()) + { + case OWL_CLASS: + + OWLClass d = (OWLClass) c; + if (d.isOWLThing()) + return getTopConceptName(); + else if (d.isOWLNothing()) + return getBottomConceptName(); + else + // Atomic concept + return getAtomicConceptName(d); + + case OBJECT_INTERSECTION_OF: + + Set<OWLClassExpression> operands = ((OWLObjectIntersectionOf) c).getOperands(); + return getObjectIntersectionOfName(operands); + + case OBJECT_UNION_OF: + + operands = ((OWLObjectUnionOf) c).getOperands(); + return getObjectUnionOfName(operands); + + case OBJECT_SOME_VALUES_FROM: + + OWLObjectPropertyExpression p = ((OWLObjectSomeValuesFrom) c).getProperty(); + OWLClassExpression e = ((OWLObjectSomeValuesFrom) c).getFiller(); + return getObjectSomeValuesFromName(p, e); + + case OBJECT_ALL_VALUES_FROM: + + p = ((OWLObjectAllValuesFrom) c).getProperty(); + e = ((OWLObjectAllValuesFrom) c).getFiller(); + return getObjectAllValuesFromName(p, e); + + case DATA_SOME_VALUES_FROM: + + OWLDataPropertyExpression dp = ((OWLDataSomeValuesFrom) c).getProperty(); + OWLDataRange range = ((OWLDataSomeValuesFrom) c).getFiller(); + return getDataSomeValuesFromName(dp, range); + + case DATA_ALL_VALUES_FROM: + + dp = ((OWLDataAllValuesFrom) c).getProperty(); + range = ((OWLDataAllValuesFrom) c).getFiller(); + return getDataAllValuesFromName(dp, range); + + case OBJECT_COMPLEMENT_OF: + + e = ((OWLObjectComplementOf) c).getOperand(); + return getObjectComplementOfName(e); + + case OBJECT_HAS_SELF: + + p = ((OWLObjectHasSelf) c).getProperty(); + return getObjectHasSelfName(p); + + case OBJECT_ONE_OF: + + Set<OWLIndividual> set = ((OWLObjectOneOf) c).getIndividuals(); + return getObjectOneOfName(set); + + case OBJECT_HAS_VALUE: + + OWLObjectHasValue hasValue = (OWLObjectHasValue) c; + OWLIndividual i = hasValue.getValue(); + p = hasValue.getProperty(); + return getObjectHasValueName(p, i); + + case DATA_HAS_VALUE: + + OWLDataHasValue dataHasValue = (OWLDataHasValue) c; + OWLLiteral lit = dataHasValue.getValue(); + dp = dataHasValue.getProperty(); + return getDataHasValueName(dp, lit); + + case OBJECT_MAX_CARDINALITY: + + OWLObjectCardinalityRestriction q = (OWLObjectMaxCardinality) c; + p = q.getProperty(); + int card = q.getCardinality(); + if (q.isQualified()) + return getObjectMaxCardinalityRestrictionName(card, p, q.getFiller()); + else + return getObjectMaxCardinalityRestrictionName(card, p); + + case OBJECT_MIN_CARDINALITY: + + q = (OWLObjectMinCardinality) c; + p = q.getProperty(); + card = q.getCardinality(); + if (q.isQualified()) + return getObjectMinCardinalityRestrictionName(card, p, q.getFiller()); + else + return getObjectMinCardinalityRestrictionName(card, p); + + case OBJECT_EXACT_CARDINALITY: + + q = (OWLObjectExactCardinality) c; + p = q.getProperty(); + card = q.getCardinality(); + if (q.isQualified()) + return getObjectExactCardinalityRestrictionName(card, p, q.getFiller()); + else + return getObjectExactCardinalityRestrictionName(card, p); + + case DATA_MAX_CARDINALITY: + + OWLDataCardinalityRestriction dq = (OWLDataMaxCardinality) c; + dp = dq.getProperty(); + card = dq.getCardinality(); + if (dq.isQualified()) + return getDataMaxCardinalityRestrictionName(card, dp, dq.getFiller()); + else + return getDataMaxCardinalityRestrictionName(card, dp); + + case DATA_MIN_CARDINALITY: + + dq = (OWLDataMinCardinality) c; + dp = dq.getProperty(); + card = dq.getCardinality(); + if (dq.isQualified()) + return getDataMinCardinalityRestrictionName(card, dp, dq.getFiller()); + else + return getDataMinCardinalityRestrictionName(card, dp); + + case DATA_EXACT_CARDINALITY: + + dq = (OWLDataExactCardinality) c; + dp = dq.getProperty(); + card = dq.getCardinality(); + if (dq.isQualified()) + return getDataExactCardinalityRestrictionName(card, dp, dq.getFiller()); + else + return getDataExactCardinalityRestrictionName(card, dp); + + default: + print("Print class of type " + c.getClassExpressionType()); + return ""; + } + } + + + /** + * Gets a String representation of an OWL 2 object property. + * + * @param p An OWL 2 object property. + * @return A String representation of p. + */ + protected String getObjectPropertyName(OWLObjectPropertyExpression p) + { + if (p.isOWLTopObjectProperty()) + return getTopObjectPropertyName(); + else if (p.isOWLBottomObjectProperty()) + return getBottomObjectPropertyName(); + else + return getAtomicObjectPropertyName(p.asOWLObjectProperty()); + } + + + /** + * Gets a String representation of an OWL 2 data property. + * + * @param p An OWL 2 data property. + * @return A String representation of p. + */ + protected String getDataPropertyName(OWLDataPropertyExpression p) + { + if (p.isOWLTopDataProperty()) + return getTopDataPropertyName(); + else if (p.isOWLBottomDataProperty()) + return getBottomDataPropertyName(); + else + return getAtomicDataPropertyName(p.asOWLDataProperty()); + } + + + /** + * Returns the degree in the annotation of an axiom. + * @param axiom An OWLAxiom. + * @return The degree in the annotation of an axiom; 1 if it does not exist. + */ + protected double getDegree(OWLAxiom axiom) + { + Set<OWLAnnotation> annotations = axiom.getAnnotations(label); + + if (annotations.size() != 1) + { + if (annotations.size() > 1) + print("Error: There are " + annotations.size() + " annotations for axiom " + axiom + "."); + return 1; + } + else + return Parser.getDegree(annotations.iterator().next().getValue().toString()); + } + + + private void setK1AndK2(FuzzyDatatype dat, double[] k) + { + dat.setMinValue(k[0]); + dat.setMaxValue(k[1]); + } + + + private void getK1AndK2(String name, double[] k) + { + k[0] = NEG_INFINITY; + k[1] = POS_INFINITY; + + for (OWLOntology o : ontologies) + { + Set<OWLDatatypeDefinitionAxiom> set = o.getAxioms(AxiomType.DATATYPE_DEFINITION); + if (set != null) + { + Iterator<OWLDatatypeDefinitionAxiom> it2 = set.iterator(); + + String datatypeName = ""; + OWLDatatypeDefinitionAxiom def; + do + { + def = it2.next(); + datatypeName = pm.getShortForm(def.getDatatype()).replace(":", ""); + } while (it2.hasNext() && (datatypeName.compareTo(name) != 0)); + + if (datatypeName.compareTo(name) == 0) + { + if (def.getDataRange().getDataRangeType() == DataRangeType.DATA_INTERSECTION_OF) + { + OWLDataIntersectionOf inter = (OWLDataIntersectionOf) def.getDataRange(); + Set<OWLDataRange> operands = inter.getOperands(); + if ((operands != null) && (operands.size() == 2)) + { + Iterator<OWLDataRange> it3 = operands.iterator(); + OWLDataRange r1 = it3.next(); + OWLDataRange r2 = it3.next(); + if ( (r1.getDataRangeType() == DataRangeType.DATATYPE_RESTRICTION) && (r2.getDataRangeType() == DataRangeType.DATATYPE_RESTRICTION) ) + { + OWLDatatypeRestriction rest1 = (OWLDatatypeRestriction) r1; + OWLDatatypeRestriction rest2 = (OWLDatatypeRestriction) r2; + Set<OWLFacetRestriction> set1 = rest1.getFacetRestrictions(); + Set<OWLFacetRestriction> set2 = rest2.getFacetRestrictions(); + if ( (set1 != null) && (set2 != null) && (set1.size() == 1) && (set2.size() == 1) ) + { + OWLFacetRestriction f1 = rest1.getFacetRestrictions().iterator().next(); + OWLFacetRestriction f2 = rest2.getFacetRestrictions().iterator().next(); + if (f1.getFacet() == OWLFacet.MIN_INCLUSIVE) + k[0] = Double.parseDouble(f1.getFacetValue().getLiteral()); + else if (f1.getFacet() == OWLFacet.MAX_INCLUSIVE) + k[1] = Double.parseDouble(f1.getFacetValue().getLiteral()); + if (f2.getFacet() == OWLFacet.MIN_INCLUSIVE) + k[0] = Double.parseDouble(f2.getFacetValue().getLiteral()); + else if (f2.getFacet() == OWLFacet.MAX_INCLUSIVE) + k[1] = Double.parseDouble(f2.getFacetValue().getLiteral()); + } + } + } + } + } + } + } + } + + + protected static String[] processParameters(String[] args) + { + boolean versionRequested = false; + int numParams = args.length; + String[] returnValue = new String[2]; + + if ((args.length >= 1) && args[0].equals("--version")) + { + System.out.println(FuzzyOwl2.class.getSimpleName() + " version: " + 1.0); + versionRequested = true; + numParams--; + } + + if (numParams < 1) + exit("Error. Use: java " + FuzzyOwl2.class.getSimpleName() + " <Owl2Ontology> ( <outputFileName> ).\n" + + " Example: java " + FuzzyOwl2.class.getSimpleName() + " c:\\\\fuzzyWine.owl test.txt \n" + + " Example: java " + FuzzyOwl2.class.getSimpleName() + " http://www.co-ode.org/ontologies/pizza/pizza.owl c:\\ont\\test.txt \n"); + else + { + if (versionRequested) + { + returnValue[0] = args[1]; + if (numParams == 2) + returnValue[1] = args[2]; + } + else + { + returnValue[0] = args[0]; + returnValue[1] = args[1]; + } + } + return returnValue; + } + + + // ****************************************************** + // Methods that should be overwritten by the subclasses. + // ****************************************************** + + /** + * Gets the short name (without namespaces) of an OWL 2 entity. + * @param e An OWL 2 entity. + * @return Short name of e. + */ + protected String getShortName(OWLEntity e) + { + return pm.getShortForm(e); + } + + + /** + * Gets a String representation of an OWL 2 individual. + * + * @param i An OWL 2 individual. + * @return A String representation of i. + */ + public String getIndividualName(OWLIndividual i) + { + if (i.isAnonymous()) + { + print("Anonymous individual not supported"); + return null; + } + else + { + String name = getShortName(i.asOWLNamedIndividual()); + print("Print individual " + name); + return name; + } + } + + + protected String getTopConceptName() + { + print("Print Top concept"); + return ""; + } + + + protected String getBottomConceptName() + { + print("Print Bottom concept"); + return ""; + } + + + protected String getAtomicConceptName(OWLClass c) + { + String name = getShortName(c); + print("Print Atomic concept" + name); + return ""; + } + + + protected String getObjectIntersectionOfName(Set<OWLClassExpression> operands) + { + print("Print ObjectIntersectionOf" + operands); + return ""; + } + + + protected String getObjectUnionOfName(Set<OWLClassExpression> operands) + { + print("Print ObjectUnionOf" + operands); + return ""; + }... [truncated message content] |
From: <ki...@us...> - 2013-11-18 09:42:58
|
Revision: 4151 http://sourceforge.net/p/dl-learner/code/4151 Author: kirdie Date: 2013-11-18 09:42:55 +0000 (Mon, 18 Nov 2013) Log Message: ----------- last changes to hmm branch Modified Paths: -------------- branches/hmm/components-ext/eval/eval2.xml branches/hmm/components-ext/src/test/java/org/dllearner/algorithm/tbsl/learning/QueryTestData.java branches/hmm/components-ext/src/test/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner3Test.java Modified: branches/hmm/components-ext/eval/eval2.xml =================================================================== --- branches/hmm/components-ext/eval/eval2.xml 2013-11-17 19:29:06 UTC (rev 4150) +++ branches/hmm/components-ext/eval/eval2.xml 2013-11-18 09:42:55 UTC (rev 4151) @@ -2,7 +2,7 @@ <question answertype="resource" id="0"> <string>houses/NNS in/IN Headington/NNP</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -18,7 +18,7 @@ <question answertype="resource" id="1"> <string>houses/NNS in/IN Abingdon/NNP with/IN more/JJR than/IN 2/CD bedrooms/NNS</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -37,7 +37,7 @@ <question answertype="resource" id="2"> <string>houses/NNS with/IN garden/NN in/IN Wheatley/NNP</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -55,7 +55,7 @@ <question answertype="resource" id="3"> <string>detached/JJ houses/NNS in/IN Oxford/NNP</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -73,7 +73,7 @@ <question answertype="resource" id="4"> <string>Victorian/JJ houses/NNS in/IN Oxfordshire/NNP</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -91,7 +91,7 @@ <question answertype="resource" id="5"> <string>Edwardian/JJ house/NN in/IN Oxfordshire/NNP for/IN less/JJR than/IN 1000000/CD</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -111,7 +111,7 @@ <question answertype="resource" id="6"> <string>houses/NNS with/IN double/JJ garage/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -128,7 +128,7 @@ <question answertype="resource" id="7"> <string>houses/NNS with/IN large/JJ garden/NN and/CC equipped/JJ kitchen/NN</string> <queryStatus> -<evaluation>partlycorrect</correct> +<evaluation>partlycorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -147,7 +147,7 @@ <question answertype="resource" id="8"> <string>houses/NNS with/IN more/JJR than/IN 1/CD reception/NN room/NN</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -163,8 +163,8 @@ <question answertype="resource" id="9"> <string>houses/NNS with/IN conservatory/NN room/NN and/CC less/JJR than/IN 900000/CD pounds/NNS</string> <queryStatus> -<evaluation>incorrect</correct> -<notes><note>templateproblem</note></note> +<evaluation>incorrect</evaluation> +<notes><note>templateproblem</note></notes> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -182,7 +182,7 @@ <question answertype="resource" id="10"> <string>houses/NNS in/IN Old/NNP Marston/NNP</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -198,7 +198,7 @@ <question answertype="resource" id="11"> <string>family/NN houses/NNS with/IN more/JJR than/IN 2/CD bathrooms/NNS and/CC more/JJR than/IN 4/CD bedrooms/NNS</string> <queryStatus> -<evaluation>partlycorrect</correct> +<evaluation>partlycorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -217,7 +217,7 @@ <question answertype="resource" id="12"> <string>houses/NNS close/RB to/TO Iffley/NNP Sport/NNP Centre/NNP</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -232,7 +232,7 @@ <question answertype="resource" id="13"> <string>houses/NNS in/IN Oxford/NNP close/RB to/TO the/DT train/NN station/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -250,7 +250,7 @@ <question answertype="resource" id="14"> <string>houses/NNS in/IN Summertown/NNP for/IN less/JJR than/IN 400000/CD pounds/NNS</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -268,7 +268,7 @@ <question answertype="resource" id="15"> <string>two/CD floors/NNS houses/NNS in/IN East/NNP Oxford/NNP</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -284,7 +284,7 @@ <question answertype="resource" id="16"> <string>brand/NN new/JJ houses/NNS in/IN Oxford/NNP for/IN less/JJR than/IN 500000/CD pounds/NNS</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -305,7 +305,7 @@ <question answertype="resource" id="17"> <string>houses/NNS close/RB to/TO Brookes/NNP University/NNP</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -320,7 +320,7 @@ <question answertype="resource" id="18"> <string>houses/NNS in/IN Jericho/NNP area/NN</string> <queryStatus> -<evaluation>partlycorrect</correct> +<evaluation>partlycorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -336,7 +336,7 @@ <question answertype="resource" id="19"> <string>house/NN close/RB to/TO Headington/NNP hospitals/NNS</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -351,7 +351,7 @@ <question answertype="resource" id="20"> <string>modern/JJ houses/NNS with/IN gas/NN central/JJ heating/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -369,7 +369,7 @@ <question answertype="resource" id="21"> <string>houses/NNS with/IN electric/JJ heating/NN</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -392,7 +392,7 @@ <question answertype="resource" id="23"> <string>houses/NNS close/RB to/TO an/DT Italian/JJ restaurant/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -410,7 +410,7 @@ <question answertype="resource" id="24"> <string>houses/NNS at/IN walking/VBG distance/NN from/IN a/DT pharmacy/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -426,7 +426,7 @@ <question answertype="resource" id="25"> <string>houses/NNS at/IN walking/VBG distance/NN from/IN Tesco/NNP or/CC Sainsburys/NNP shops/NNS</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -440,7 +440,7 @@ <question answertype="resource" id="26"> <string>houses/NNS nearby/JJ Sheldonian/NNP Theatre/NNP</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -455,7 +455,7 @@ <question answertype="resource" id="27"> <string>houses/NNS with/IN underfloor/JJ heating/NN</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -471,7 +471,7 @@ <question answertype="resource" id="28"> <string>houses/NNS with/IN wood/NN floor/NN</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -487,7 +487,7 @@ <question answertype="resource" id="29"> <string>houses/NNS close/RB to/TO The/DT King/NN 's/POS Arms/NNS pub/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -512,7 +512,7 @@ <string>houses/NNS with/IN many/JJ reception/NN rooms/NNS</string> <queryStatus> <type>OK</type> -<evaluation>partlycorrect</correct> +<evaluation>partlycorrect</evaluation> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> @@ -533,7 +533,7 @@ <question answertype="resource" id="33"> <string>houses/NNS with/IN balcony/NN</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -549,7 +549,7 @@ <question answertype="resource" id="34"> <string>houses/NNS with/IN double/JJ glazed/JJ windows/NNS</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -565,7 +565,7 @@ <question answertype="resource" id="35"> <string>2/CD bedroom/NN houses/NNS near/IN Oxford/NNP train/NN station/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -582,7 +582,7 @@ <question answertype="resource" id="36"> <string>4/CD bedroom/NN detached/VBD houses/NNS in/IN Oxford/NNP</string> <queryStatus> -<evaluation>partlycorrect</correct> +<evaluation>partlycorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -608,7 +608,7 @@ <question answertype="resource" id="38"> <string>freehold/NN houses/NNS with/IN 2/CD bedrooms/NNS and/CC a/DT living/NN room/NN in/IN Banbury/NNP</string> <queryStatus> -<evaluation>partlycorrect</correct> +<evaluation>partlycorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -628,7 +628,7 @@ <question answertype="resource" id="39"> <string>houses/NNS in/IN Oxford/NNP city/NN center/NN with/IN at/IN most/JJS 2/CD bedrooms/NNS</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -647,7 +647,7 @@ <question answertype="resource" id="40"> <string>victorian/JJ town/NN houses/NNS in/IN north/JJ Oxford/NNP</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -666,7 +666,7 @@ <question answertype="resource" id="41"> <string>terrace/NN houses/NNS with/IN west/NN facing/VBG garden/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -684,7 +684,7 @@ <question answertype="resource" id="42"> <string>modernized/JJ end/NN terrace/NN houses/NNS with/IN private/JJ parking/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -703,7 +703,7 @@ <question answertype="resource" id="43"> <string>three/CD bedroom/NN houses/NNS with/IN open/JJ fireplace/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -728,7 +728,7 @@ <question answertype="resource" id="45"> <string>houses/NNS on/IN Rawlinson/NNP Road/NNP</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -744,7 +744,7 @@ <question answertype="resource" id="46"> <string>flats/NNS near/IN supermarket/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -872,7 +872,7 @@ <question answertype="resource" id="63"> <string>houses/NNS in/IN Botley/NNP Road/NNP</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -888,7 +888,7 @@ <question answertype="resource" id="64"> <string>houses/NNS in/IN Littlemore/NNP</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -911,7 +911,7 @@ <question answertype="resource" id="66"> <string>houses/NNS with/IN 3/CD bedrooms/NNS in/IN Florence/NNP Park/NNP Road/NNP</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -930,7 +930,7 @@ <question answertype="resource" id="67"> <string>houses/NNS with/IN front/JJ garden/NN and/CC rear/NN garden/NN</string> <queryStatus> -<evaluation>partlycorrect</correct> +<evaluation>partlycorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -954,7 +954,7 @@ <question answertype="resource" id="69"> <string>houses/NNS with/IN ample/JJ parking/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -971,7 +971,7 @@ <question answertype="resource" id="70"> <string>house/NN with/IN electric/JJ central/JJ heating/NN system/NN</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -994,7 +994,7 @@ <question answertype="resource" id="72"> <string>houses/NNS with/IN countryside/NN views/NNS</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1009,7 +1009,7 @@ <question answertype="resource" id="73"> <string>houses/NNS with/IN farmland/NN views/NNS</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1025,7 +1025,7 @@ <question answertype="resource" id="74"> <string>houses/NNS nearby/JJ River/NNP Thames/NNPS</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1040,7 +1040,7 @@ <question answertype="resource" id="75"> <string>houses/NNS having/VBG one/CD utility/NN room/NN or/CC cloakroom/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1057,7 +1057,7 @@ <question answertype="resource" id="76"> <string>houses/NNS in/IN Oxfordshire/NNP with/IN fireplaces/NNS</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1075,7 +1075,7 @@ <question answertype="resource" id="77"> <string>houses/NNS with/IN open/JJ plan/NN kitchen/NN near/IN Oxford/NNP</string> <queryStatus> -<evaluation>partlycorrect</correct> +<evaluation>partlycorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1092,7 +1092,7 @@ <question answertype="resource" id="78"> <string>houses/NNS with/IN walled/JJ garden/NN near/IN Oxford/NNP</string> <queryStatus> -<evaluation>partlycorrect</correct> +<evaluation>partlycorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1109,7 +1109,7 @@ <question answertype="resource" id="79"> <string>houses/NNS with/IN river/NN views/NNS</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1139,7 +1139,7 @@ <question answertype="resource" id="82"> <string>house/NN with/IN balcony/NN and/CC vaulted/VBD ceiling/NN</string> <queryStatus> -<evaluation>partlycorrect</correct> +<evaluation>partlycorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1165,7 +1165,7 @@ <question answertype="resource" id="84"> <string>house/NN in/IN a/DT corner/NN or/CC end/NN of/IN terrace/NN plot/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1188,7 +1188,7 @@ <question answertype="resource" id="86"> <string>house/NN with/IN at/IN least/JJS 2/CD reception/NN rooms/NNS and/CC a/DT garden/NN</string> <queryStatus> -<evaluation>partlycorrect</correct> +<evaluation>partlycorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1205,7 +1205,7 @@ <question answertype="resource" id="87"> <string>house/NN with/IN a/DT courtyard/NN</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1242,7 +1242,7 @@ <question answertype="resource" id="91"> <string>house/NN in/IN a/DT retirement/NN complex/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1258,7 +1258,7 @@ <question answertype="resource" id="92"> <string>house/NN with/IN double/JJ glazing/NN and/CC central/JJ heating/NN</string> <queryStatus> -<evaluation>partlycorrect</correct> +<evaluation>partlycorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1282,7 +1282,7 @@ <question answertype="resource" id="94"> <string>house/NN listed/VBD Grade/NNP I/NNP or/CC Grade/NNP II/NNP</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1305,7 +1305,7 @@ <question answertype="resource" id="96"> <string>house/NN in/IN Witney/NNP or/CC Wolvercote/NNP</string> <queryStatus> -<evaluation>partlycorrect</correct> +<evaluation>partlycorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1329,7 +1329,7 @@ <question answertype="resource" id="98"> <string>house/NN in/IN Banbury/NNP Road/NNP</string> <queryStatus> -<evaluation>correct</correct> +<evaluation>correct</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -1345,7 +1345,7 @@ <question answertype="resource" id="99"> <string>house/NN in/IN the/DT area/NN of/IN John/NNP Radcliffe/NNP hospital/NN</string> <queryStatus> -<evaluation>incorrect</correct> +<evaluation>incorrect</evaluation> <type>OK</type> </queryStatus> <query><![CDATA[PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> Modified: branches/hmm/components-ext/src/test/java/org/dllearner/algorithm/tbsl/learning/QueryTestData.java =================================================================== --- branches/hmm/components-ext/src/test/java/org/dllearner/algorithm/tbsl/learning/QueryTestData.java 2013-11-17 19:29:06 UTC (rev 4150) +++ branches/hmm/components-ext/src/test/java/org/dllearner/algorithm/tbsl/learning/QueryTestData.java 2013-11-18 09:42:55 UTC (rev 4151) @@ -38,12 +38,15 @@ public class QueryTestData implements Serializable { + public enum EvaluationStatus {CORRECT,PARTIALLY_CORRECT,INCORRECT}; + private static final long serialVersionUID = 2L; public boolean hmm = false; public SortedMap<Integer, String> id2Question = new ConcurrentSkipListMap<Integer, String>(); public SortedMap<Integer, String> id2Query = new ConcurrentSkipListMap<Integer, String>(); public SortedMap<Integer, Set<String>> id2Answers = new ConcurrentSkipListMap<Integer, Set<String>>(); public SortedMap<Integer, LearnStatus> id2QueryStatus = new ConcurrentSkipListMap<Integer, LearnStatus>(); + public SortedMap<Integer, EvaluationStatus> id2EvaluationStatus = new ConcurrentSkipListMap<Integer, EvaluationStatus>(); /** TODO: include in the xml*/ public SortedMap<Integer, LearnStatus> id2AnswerStatus = new ConcurrentSkipListMap<Integer, LearnStatus>(); @@ -100,6 +103,11 @@ } return this; } + /** @see readQaldXml(File file, int MAX_NUMBER_OF_QUESTIONS, boolean whitelistOnly, Set<Integer> whitelist)**/ + public static QueryTestData readQaldXml(final File file) + { + return readQaldXml(file, Integer.MAX_VALUE, false,null); + } /** reads test data from a QALD2 benchmark XML file, including questions, queries and answers. * each question needs to have a query but not necessarily an answer. @@ -127,38 +135,44 @@ //read question ID id = Integer.valueOf(questionNode.getAttribute("id")); if(whitelistOnly&&!whitelist.contains(id)) {continue;} - + //Read question question = ((Element)questionNode.getElementsByTagName("string").item(0)).getChildNodes().item(0).getNodeValue().trim(); + // TODO: read evaluation status //Read SPARQL query - query = ((Element)questionNode.getElementsByTagName("query").item(0)).getChildNodes().item(0).getNodeValue().trim(); - // //Read answers - // answers = new HashSet<String>(); - // NodeList aswersNodes = questionNode.getElementsByTagName("answer"); - // for(int j = 0; j < aswersNodes.getLength(); j++){ - // Element answerNode = (Element) aswersNodes.item(j); - // answers.add(((Element)answerNode.getElementsByTagName("uri").item(0)).getChildNodes().item(0).getNodeValue().trim()); - // } - if(!query.equals("OUT OF SCOPE")) // marker in qald benchmark file, will create holes interval of ids (e.g. 1,2,5,7) + NodeList queryElements = questionNode.getElementsByTagName("query"); + if(queryElements.getLength()>0) { - testData.id2Question.put(id, question); - testData.id2Query.put(id, query); - Element answersElement = (Element) questionNode.getElementsByTagName("answers").item(0); - // some of our qald files were mistakenly created so that they have the "answer" elements directly under the question node - // with no answers element - if(answersElement==null) answersElement = (Element)questionNode; - // if(answersElement!=null) + query = queryElements.item(0).getChildNodes().item(0).getNodeValue().trim(); + // //Read answers + // answers = new HashSet<String>(); + // NodeList aswersNodes = questionNode.getElementsByTagName("answer"); + // for(int j = 0; j < aswersNodes.getLength(); j++){ + // Element answerNode = (Element) aswersNodes.item(j); + // answers.add(((Element)answerNode.getElementsByTagName("uri").item(0)).getChildNodes().item(0).getNodeValue().trim()); + // } + + if(!query.equals("OUT OF SCOPE")) // marker in qald benchmark file, will create holes interval of ids (e.g. 1,2,5,7) { - NodeList answerElements = answersElement.getElementsByTagName("answer"); - for(int j=0; j<answerElements.getLength();j++) + testData.id2Question.put(id, question); + testData.id2Query.put(id, query); + Element answersElement = (Element) questionNode.getElementsByTagName("answers").item(0); + // some of our qald files were mistakenly created so that they have the "answer" elements directly under the question node + // with no answers element + if(answersElement==null) answersElement = (Element)questionNode; + // if(answersElement!=null) { - String answer = ((Element)answerElements.item(j)).getTextContent(); - answers.add(answer); + NodeList answerElements = answersElement.getElementsByTagName("answer"); + for(int j=0; j<answerElements.getLength();j++) + { + String answer = ((Element)answerElements.item(j)).getTextContent(); + answers.add(answer); + } + testData.id2Answers.put(id, answers); } - testData.id2Answers.put(id, answers); } - } + } // question2Answers.put(question, answers); } Modified: branches/hmm/components-ext/src/test/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner3Test.java =================================================================== --- branches/hmm/components-ext/src/test/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner3Test.java 2013-11-17 19:29:06 UTC (rev 4150) +++ branches/hmm/components-ext/src/test/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner3Test.java 2013-11-18 09:42:55 UTC (rev 4151) @@ -48,7 +48,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.regex.Pattern; @@ -132,7 +131,7 @@ protected static final int QUESTION_OFFSET = 0; protected static final int QUESTION_LIMIT = Integer.MAX_VALUE; - protected static final boolean WHITELIST_ONLY = true; + protected static final boolean WHITELIST_ONLY = false; protected static final Set<Integer> WHITELIST = Collections.unmodifiableSet(new HashSet<Integer>(Arrays.asList(new Integer[] {24}))); protected static final boolean GENERATE_HTML_ONLY = false; protected static final int MAX_THREADS = 4; @@ -359,7 +358,7 @@ } - @Test @SuppressWarnings("null") public void createXMLOxford() throws IOException + /*@Test*/ @SuppressWarnings("null") public void createXMLOxford() throws IOException { /**more will be left out of the xml file */ List<String> questions = new LinkedList<String>(); @@ -731,9 +730,12 @@ { final Set<Integer> aMinusB = new HashSet<Integer>(); final Set<Integer> bMinusA = new HashSet<Integer>(); - final Set<Integer> intersection = new HashSet<Integer>(); + final Set<Integer> intersection = new HashSet<Integer>(); + final Set<Integer> differentQueries = new HashSet<Integer>(); + /** only contains ids of who have the same query*/ final Set<Integer> differentAnswers = new HashSet<Integer>(); + /** assumes that the same questions have the same ids in both test datas */ public Diff(QueryTestData reference, QueryTestData newData) { // if(d.id2Question.size()!=e.id2Question.size()) @@ -753,14 +755,30 @@ intersection.retainAll(newData.id2Question.keySet()); for(int i: intersection) - { - // the questions are the same - we don't care about the answer + { if(reference.id2Question.get(i).equals(newData.id2Question.get(i))) - - if(reference.id2Answers.containsKey(i)&&!reference.id2Answers.get(i).equals(newData.id2Answers.get(i))) + { + { + boolean r = reference.id2Query.containsKey(i); + boolean n = newData.id2Query.containsKey(i); + // no queries - stop + if(!r&&!n) {continue;} + // if exactly one of them contains queries or both do and the queries are different + if((r^n)||(!reference.id2Query.get(i).equals(newData.id2Query.get(i)))) + { + differentQueries.add(i); + continue; + } + } + // both have the same queries - check the answers + boolean r = reference.id2Answers.containsKey(i); + boolean n = newData.id2Answers.containsKey(i); + if(!r&&!n) {continue;} + if(r^n||!reference.id2Answers.get(i).equals(newData.id2Answers.get(i))) { differentAnswers.add(i); - } + } + } } } @@ -1641,4 +1659,27 @@ in.close(); out.close(); } + + @Test public void diffXML() + { + String oldXML = "eval/eval2.xml"; + String newXML = "log/test_limitNONE_offset0_timeoutSeconds_120_threads4_mode-BEST_QUERY_generateAnswers-true.xml"; + QueryTestData oldData = QueryTestData.readQaldXml(new File(oldXML)); + QueryTestData newData = QueryTestData.readQaldXml(new File(newXML)); + Diff diff = new Diff(oldData, newData); + + for(Integer id: diff.differentQueries) + { + System.out.println(oldData.id2Question.get(id)+"*******************************************************************************"); + System.out.println(id+" with "+newData.id2Answers.get(id).size()+" answers, old query: "+oldData.id2Query.get(id)+"\n new query:"+newData.id2Query.get(id)); + } + + // TODO: are there correct questions that are different now? + +// for(Integer id: oldData.id2AnswerStatus.keySet()) +// { +// if(oldData.id2AnswerStatus.get(id).type) +// } + } + } \ 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: <lor...@us...> - 2013-11-17 19:29:10
|
Revision: 4150 http://sourceforge.net/p/dl-learner/code/4150 Author: lorenz_b Date: 2013-11-17 19:29:06 +0000 (Sun, 17 Nov 2013) Log Message: ----------- Set JAVA compiler version to 1.7 Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2013-11-17 14:55:56 UTC (rev 4149) +++ trunk/pom.xml 2013-11-17 19:29:06 UTC (rev 4150) @@ -10,7 +10,7 @@ <url>http://aksw.org/Projects/DLLearner</url> <properties> <!-- tell the compiler we can use 1.6 --> - <compiler.version>1.6</compiler.version> + <compiler.version>1.7</compiler.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- convenience to define GWT version in one place --> <gwt.version>2.3.0</gwt.version> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <far...@us...> - 2013-11-17 14:56:01
|
Revision: 4149 http://sourceforge.net/p/dl-learner/code/4149 Author: farshadbadie Date: 2013-11-17 14:55:56 +0000 (Sun, 17 Nov 2013) Log Message: ----------- EvKnowledge folder added. Added Paths: ----------- trunk/test/fuzzydll/EvKnowledge/ trunk/test/fuzzydll/EvKnowledge/EvKnowledge.csv trunk/test/fuzzydll/EvKnowledge/EvKnowledge.rdf trunk/test/fuzzydll/EvKnowledge/EvKnowledge.xls Added: trunk/test/fuzzydll/EvKnowledge/EvKnowledge.csv =================================================================== --- trunk/test/fuzzydll/EvKnowledge/EvKnowledge.csv (rev 0) +++ trunk/test/fuzzydll/EvKnowledge/EvKnowledge.csv 2013-11-17 14:55:56 UTC (rev 4149) @@ -0,0 +1,259 @@ + USER,SEX,STG,SCG,STR,LPR,PEG, UNS +USER1,MALE,0,0,0,0,0,very_low +USER2,MALE,0.08,0.08,0.1,0.24,0.9,High +USER3,MALE,0.06,0.06,0.05,0.25,0.33,Low +USER4,FEMALE,0.1,0.1,0.15,0.65,0.3,Middle +USER5,FEMALE,0.08,0.08,0.08,0.98,0.24,Low +USER6,FEMALE,0.09,0.15,0.4,0.1,0.66,Middle +USER7,MALE,0.1,0.1,0.43,0.29,0.56,Middle +USER8,MALE,0.15,0.02,0.34,0.4,0.01,very_low +USER9,FEMALE,0.2,0.14,0.35,0.72,0.25,Low +USER10,MALE,0,0,0.5,0.2,0.85,High +USER11,FEMALE,0.18,0.18,0.55,0.3,0.81,High +USER12,FEMALE,0.06,0.06,0.51,0.41,0.3,Low +USER13,FEMALE,0.1,0.1,0.52,0.78,0.34,Middle +USER14,FEMALE,0.1,0.1,0.7,0.15,0.9,High +USER15,FEMALE,0.2,0.2,0.7,0.3,0.6,Middle +USER16,MALE,0.12,0.12,0.75,0.35,0.8,High +USER17,MALE,0.05,0.07,0.7,0.01,0.05,very_low +USER18,MALE,0.1,0.25,0.1,0.08,0.33,Low +USER19,MALE,0.15,0.32,0.05,0.27,0.29,Low +USER20,MALE,0.2,0.29,0.25,0.49,0.56,Middle +USER21,MALE,0.12,0.28,0.2,0.78,0.2,Low +USER22,MALE,0.18,0.3,0.37,0.12,0.66,Middle +USER23,MALE,0.1,0.27,0.31,0.29,0.65,Middle +USER24,MALE,0.18,0.31,0.32,0.42,0.28,Low +USER25,FEMALE,0.06,0.29,0.35,0.76,0.25,Low +USER26,MALE,0.09,0.3,0.68,0.18,0.85,High +USER27,MALE,0.04,0.28,0.55,0.25,0.1,very_low +USER28,FEMALE,0.09,0.255,0.6,0.45,0.25,Low +USER29,FEMALE,0.08,0.325,0.62,0.94,0.56,High +USER30,FEMALE,0.15,0.275,0.8,0.21,0.81,High +USER31,FEMALE,0.12,0.245,0.75,0.31,0.59,Middle +USER32,FEMALE,0.15,0.295,0.75,0.65,0.24,Low +USER33,MALE,0.1,0.256,0.7,0.76,0.16,Low +USER34,MALE,0.18,0.32,0.04,0.19,0.82,High +USER35,FEMALE,0.2,0.45,0.28,0.31,0.78,High +USER36,MALE,0.06,0.35,0.12,0.43,0.29,Low +USER37,MALE,0.1,0.42,0.22,0.72,0.26,Low +USER38,FEMALE,0.18,0.4,0.32,0.08,0.33,Low +USER39,FEMALE,0.09,0.33,0.31,0.26,0,very_low +USER40,FEMALE,0.19,0.38,0.38,0.49,0.45,Middle +USER41,FEMALE,0.02,0.33,0.36,0.76,0.1,Low +USER42,FEMALE,0.2,0.49,0.6,0.2,0.78,High +USER43,MALE,0.14,0.49,0.55,0.29,0.6,Middle +USER44,MALE,0.18,0.33,0.61,0.64,0.25,Middle +USER45,MALE,0.115,0.35,0.65,0.27,0.04,very_low +USER46,MALE,0.17,0.36,0.8,0.14,0.66,Middle +USER47,MALE,0.1,0.39,0.75,0.31,0.62,Middle +USER48,MALE,0.13,0.39,0.85,0.38,0.77,High +USER49,MALE,0.18,0.34,0.71,0.71,0.9,High +USER50,MALE,0.09,0.51,0.02,0.18,0.67,Middle +USER51,FEMALE,0.06,0.5,0.09,0.28,0.25,Low +USER52,FEMALE,0.23,0.7,0.19,0.51,0.45,Middle +USER53,FEMALE,0.09,0.55,0.12,0.78,0.05,Low +USER54,FEMALE,0.24,0.75,0.32,0.18,0.86,High +USER55,FEMALE,0.18,0.72,0.37,0.29,0.55,Middle +USER56,FEMALE,0.1,0.6,0.33,0.42,0.26,Low +USER57,FEMALE,0.2,0.52,0.36,0.84,0.25,Middle +USER58,FEMALE,0.09,0.6,0.66,0.19,0.59,Middle +USER59,MALE,0.18,0.51,0.58,0.33,0.82,High +USER60,FEMALE,0.08,0.58,0.6,0.64,0.1,Low +USER61,MALE,0.09,0.61,0.53,0.75,0.01,Low +USER62,FEMALE,0.06,0.77,0.72,0.19,0.56,Middle +USER63,MALE,0.15,0.79,0.78,0.3,0.51,Middle +USER64,MALE,0.2,0.68,0.73,0.48,0.28,Low +USER65,MALE,0.24,0.58,0.76,0.8,0.28,Middle +USER66,MALE,0.25,0.1,0.03,0.09,0.15,very_low +USER67,FEMALE,0.32,0.2,0.06,0.26,0.24,very_low +USER68,FEMALE,0.29,0.06,0.19,0.55,0.51,Middle +USER69,FEMALE,0.28,0.1,0.12,0.28,0.32,Low +USER70,FEMALE,0.3,0.08,0.4,0.02,0.67,Middle +USER71,MALE,0.27,0.12,0.37,0.29,0.58,Middle +USER72,MALE,0.31,0.1,0.41,0.42,0.75,High +USER73,FEMALE,0.29,0.15,0.33,0.66,0.08,very_low +USER74,MALE,0.3,0.2,0.52,0.3,0.53,Middle +USER75,MALE,0.28,0.16,0.69,0.33,0.78,High +USER76,MALE,0.255,0.18,0.5,0.4,0.1,very_low +USER77,FEMALE,0.265,0.06,0.57,0.75,0.1,Low +USER78,FEMALE,0.275,0.1,0.72,0.1,0.3,Low +USER79,FEMALE,0.245,0.1,0.71,0.26,0.2,very_low +USER80,FEMALE,0.295,0.2,0.86,0.44,0.28,Low +USER81,MALE,0.32,0.12,0.79,0.76,0.24,Low +USER82,FEMALE,0.295,0.25,0.26,0.12,0.67,Middle +USER83,MALE,0.315,0.32,0.29,0.29,0.62,Middle +USER84,MALE,0.25,0.29,0.15,0.48,0.26,Low +USER85,FEMALE,0.27,0.1,0.1,0.7,0.25,Low +USER86,FEMALE,0.248,0.3,0.31,0.2,0.03,very_low +USER87,MALE,0.325,0.25,0.38,0.31,0.79,High +USER88,MALE,0.27,0.31,0.32,0.41,0.28,Low +USER89,MALE,0.29,0.29,0.4,0.78,0.18,Low +USER90,FEMALE,0.29,0.3,0.52,0.09,0.67,Middle +USER91,MALE,0.258,0.28,0.64,0.29,0.56,Middle +USER92,MALE,0.32,0.255,0.55,0.78,0.34,Middle +USER93,MALE,0.251,0.265,0.57,0.6,0.09,very_low +USER94,FEMALE,0.288,0.31,0.79,0.23,0.24,Low +USER95,FEMALE,0.323,0.32,0.89,0.32,0.8,High +USER96,FEMALE,0.255,0.305,0.86,0.62,0.15,Low +USER97,FEMALE,0.295,0.25,0.73,0.77,0.19,Low +USER98,MALE,0.258,0.25,0.295,0.33,0.77,High +USER99,MALE,0.29,0.25,0.29,0.29,0.57,Middle +USER100,MALE,0.243,0.27,0.08,0.42,0.29,Low +USER101,MALE,0.27,0.28,0.18,0.48,0.26,Low +USER102,FEMALE,0.299,0.32,0.31,0.33,0.87,High +USER103,FEMALE,0.3,0.27,0.31,0.31,0.54,Middle +USER104,FEMALE,0.245,0.26,0.38,0.49,0.27,Low +USER105,MALE,0.295,0.29,0.31,0.76,0.1,Low +USER106,MALE,0.29,0.3,0.56,0.25,0.67,Middle +USER107,MALE,0.26,0.28,0.6,0.29,0.59,Middle +USER108,MALE,0.305,0.255,0.63,0.4,0.54,Middle +USER109,FEMALE,0.32,0.27,0.52,0.81,0.3,Middle +USER110,FEMALE,0.299,0.295,0.8,0.37,0.84,High +USER111,MALE,0.276,0.255,0.81,0.27,0.33,Low +USER112,MALE,0.258,0.31,0.88,0.4,0.3,Low +USER113,MALE,0.32,0.28,0.72,0.89,0.58,High +USER114,FEMALE,0.329,0.55,0.02,0.4,0.79,High +USER115,MALE,0.295,0.59,0.29,0.31,0.55,Middle +USER116,MALE,0.285,0.64,0.18,0.61,0.45,Middle +USER117,MALE,0.265,0.6,0.28,0.66,0.07,very_low +USER118,FEMALE,0.315,0.69,0.28,0.8,0.7,High +USER119,FEMALE,0.28,0.78,0.44,0.17,0.66,Middle +USER120,FEMALE,0.325,0.61,0.46,0.32,0.81,High +USER121,MALE,0.28,0.65,0.4,0.65,0.13,Low +USER122,FEMALE,0.255,0.75,0.35,0.72,0.25,Low +USER123,MALE,0.305,0.55,0.5,0.11,0.333,Low +USER124,FEMALE,0.3,0.85,0.54,0.25,0.83,Middle +USER125,MALE,0.325,0.9,0.52,0.49,0.76,High +USER126,FEMALE,0.312,0.8,0.67,0.92,0.5,High +USER127,MALE,0.299,0.7,0.95,0.22,0.66,High +USER128,MALE,0.265,0.76,0.8,0.28,0.28,Low +USER129,FEMALE,0.255,0.72,0.72,0.63,0.14,Low +USER130,FEMALE,0.295,0.6,0.72,0.88,0.28,Middle +USER131,FEMALE,0.39,0.05,0.02,0.06,0.34,Low +USER132,MALE,0.4,0.18,0.26,0.26,0.67,Middle +USER133,MALE,0.45,0.04,0.18,0.55,0.07,very_low +USER134,MALE,0.48,0.12,0.28,0.7,0.71,High +USER135,FEMALE,0.4,0.12,0.41,0.1,0.65,Middle +USER136,MALE,0.41,0.18,0.33,0.31,0.5,Middle +USER137,FEMALE,0.38,0.1,0.4,0.48,0.26,Low +USER138,FEMALE,0.37,0.06,0.32,0.78,0.1,Low +USER139,FEMALE,0.41,0.09,0.58,0.18,0.58,Middle +USER140,MALE,0.38,0.01,0.53,0.27,0.3,Low +USER141,MALE,0.33,0.04,0.5,0.55,0.1,very_low +USER142,MALE,0.42,0.15,0.66,0.78,0.4,Middle +USER143,MALE,0.44,0.08,0.8,0.22,0.56,Middle +USER144,MALE,0.39,0.15,0.81,0.22,0.29,Low +USER145,MALE,0.42,0.21,0.87,0.56,0.48,Middle +USER146,MALE,0.46,0.2,0.76,0.95,0.65,High +USER147,FEMALE,0.365,0.243,0.19,0.24,0.35,Low +USER148,FEMALE,0.33,0.27,0.2,0.33,0.1,very_low +USER149,FEMALE,0.345,0.299,0.1,0.64,0.13,Low +USER150,FEMALE,0.48,0.3,0.15,0.65,0.77,High +USER151,MALE,0.49,0.245,0.38,0.14,0.86,High +USER152,FEMALE,0.334,0.295,0.33,0.32,0.3,Low +USER153,MALE,0.36,0.29,0.37,0.48,0.13,very_low +USER154,FEMALE,0.39,0.26,0.39,0.77,0.14,Low +USER155,MALE,0.43,0.305,0.51,0.09,0.64,Middle +USER156,MALE,0.44,0.32,0.55,0.33,0.52,Middle +USER157,FEMALE,0.45,0.299,0.63,0.36,0.51,Middle +USER158,FEMALE,0.495,0.276,0.58,0.77,0.83,High +USER159,FEMALE,0.465,0.258,0.73,0.18,0.59,Middle +USER160,MALE,0.475,0.32,0.79,0.31,0.54,Middle +USER161,MALE,0.348,0.329,0.83,0.61,0.18,Low +USER162,MALE,0.385,0.26,0.76,0.84,0.3,Middle +USER163,FEMALE,0.445,0.39,0.02,0.24,0.88,High +USER164,FEMALE,0.43,0.45,0.27,0.27,0.89,High +USER165,MALE,0.33,0.34,0.1,0.49,0.12,very_low +USER166,FEMALE,0.4,0.33,0.12,0.3,0.9,High +USER167,MALE,0.34,0.4,0.38,0.2,0.61,Middle +USER168,FEMALE,0.38,0.36,0.46,0.49,0.78,High +USER169,MALE,0.35,0.38,0.32,0.6,0.16,Low +USER170,FEMALE,0.41,0.49,0.34,0.21,0.92,High +USER171,FEMALE,0.42,0.36,0.63,0.04,0.25,Low +USER172,FEMALE,0.43,0.38,0.62,0.33,0.49,Middle +USER173,MALE,0.44,0.33,0.59,0.53,0.85,High +USER174,FEMALE,0.4,0.42,0.58,0.75,0.16,Low +USER175,MALE,0.46,0.44,0.89,0.12,0.66,Middle +USER176,MALE,0.38,0.39,0.79,0.33,0.3,Low +USER177,FEMALE,0.39,0.42,0.83,0.65,0.19,Low +USER178,FEMALE,0.49,0.34,0.88,0.75,0.71,High +USER179,MALE,0.46,0.64,0.22,0.22,0.6,Middle +USER180,FEMALE,0.44,0.55,0.11,0.26,0.83,High +USER181,MALE,0.365,0.68,0.1,0.63,0.18,Low +USER182,MALE,0.45,0.65,0.19,0.99,0.55,High +USER183,FEMALE,0.46,0.78,0.38,0.24,0.89,High +USER184,FEMALE,0.37,0.55,0.41,0.29,0.3,Low +USER185,FEMALE,0.38,0.59,0.31,0.62,0.2,Low +USER186,MALE,0.49,0.64,0.34,0.78,0.21,Low +USER187,MALE,0.495,0.82,0.67,0.01,0.93,High +USER188,MALE,0.44,0.69,0.61,0.29,0.57,Middle +USER189,FEMALE,0.365,0.57,0.59,0.55,0.25,Low +USER190,FEMALE,0.49,0.9,0.52,0.9,0.47,High +USER191,MALE,0.445,0.7,0.82,0.16,0.64,Middle +USER192,MALE,0.42,0.7,0.72,0.3,0.8,High +USER193,FEMALE,0.37,0.6,0.77,0.4,0.5,Middle +USER194,FEMALE,0.4,0.61,0.71,0.88,0.67,High +USER195,MALE,0.6,0.14,0.22,0.11,0.66,Middle +USER196,MALE,0.55,0.1,0.27,0.25,0.29,Low +USER197,FEMALE,0.68,0.19,0.19,0.48,0.1,very_low +USER198,FEMALE,0.73,0.2,0.07,0.72,0.26,Low +USER199,FEMALE,0.78,0.15,0.38,0.18,0.63,Middle +USER200,FEMALE,0.55,0.1,0.34,0.3,0.1,very_low +USER201,FEMALE,0.59,0.18,0.31,0.55,0.09,very_low +USER202,FEMALE,0.64,0.09,0.33,0.65,0.5,Middle +USER203,MALE,0.6,0.19,0.55,0.08,0.1,very_low +USER204,MALE,0.69,0.02,0.62,0.3,0.29,Low +USER205,MALE,0.78,0.21,0.68,0.65,0.75,High +USER206,MALE,0.62,0.14,0.52,0.81,0.15,Low +USER207,MALE,0.7,0.18,0.88,0.09,0.66,Middle +USER208,FEMALE,0.75,0.015,0.78,0.31,0.53,Middle +USER209,FEMALE,0.55,0.17,0.71,0.48,0.11,very_low +USER210,FEMALE,0.85,0.05,0.91,0.8,0.68,High +USER211,FEMALE,0.78,0.27,0.13,0.14,0.62,Middle +USER212,MALE,0.8,0.29,0.06,0.31,0.51,Middle +USER213,MALE,0.9,0.26,0.19,0.58,0.79,High +USER214,MALE,0.76,0.258,0.07,0.83,0.34,Middle +USER215,FEMALE,0.72,0.32,0.48,0.2,0.6,Middle +USER216,MALE,0.6,0.251,0.39,0.29,0.3,Low +USER217,FEMALE,0.52,0.288,0.32,0.5,0.3,Low +USER218,FEMALE,0.6,0.31,0.31,0.87,0.58,High +USER219,FEMALE,0.51,0.255,0.55,0.17,0.64,Middle +USER220,MALE,0.58,0.295,0.62,0.28,0.3,Low +USER221,FEMALE,0.61,0.258,0.56,0.62,0.24,Low +USER222,FEMALE,0.77,0.267,0.59,0.78,0.28,Middle +USER223,MALE,0.79,0.28,0.88,0.2,0.66,Middle +USER224,MALE,0.68,0.27,0.78,0.31,0.57,Middle +USER225,MALE,0.58,0.299,0.73,0.63,0.21,Low +USER226,MALE,0.77,0.29,0.74,0.82,0.68,High +USER227,FEMALE,0.71,0.475,0.13,0.23,0.59,Middle +USER228,FEMALE,0.58,0.348,0.06,0.29,0.31,Low +USER229,FEMALE,0.88,0.335,0.19,0.55,0.78,High +USER230,FEMALE,0.99,0.49,0.07,0.7,0.69,High +USER231,MALE,0.73,0.43,0.32,0.12,0.65,Middle +USER232,FEMALE,0.61,0.33,0.36,0.28,0.28,Low +USER233,MALE,0.51,0.4,0.4,0.59,0.23,Low +USER234,FEMALE,0.83,0.44,0.49,0.91,0.66,High +USER235,FEMALE,0.66,0.38,0.55,0.15,0.62,Middle +USER236,FEMALE,0.58,0.35,0.51,0.27,0.3,Low +USER237,MALE,0.523,0.41,0.55,0.6,0.22,Low +USER238,MALE,0.66,0.36,0.56,0.4,0.83,High +USER239,FEMALE,0.62,0.37,0.81,0.13,0.64,Middle +USER240,FEMALE,0.52,0.44,0.82,0.3,0.52,Middle +USER241,FEMALE,0.5,0.4,0.73,0.62,0.2,Low +USER242,FEMALE,0.71,0.46,0.95,0.78,0.86,High +USER243,FEMALE,0.64,0.55,0.15,0.18,0.63,Middle +USER244,FEMALE,0.52,0.85,0.06,0.27,0.25,Low +USER245,FEMALE,0.62,0.62,0.24,0.65,0.25,Middle +USER246,MALE,0.91,0.58,0.26,0.89,0.88,High +USER247,MALE,0.62,0.67,0.39,0.1,0.66,Middle +USER248,MALE,0.58,0.58,0.31,0.29,0.29,Low +USER249,FEMALE,0.89,0.68,0.49,0.65,0.9,High +USER250,MALE,0.72,0.6,0.45,0.79,0.45,Middle +USER251,FEMALE,0.68,0.63,0.65,0.09,0.66,Middle +USER252,MALE,0.56,0.6,0.6,0.31,0.5,Middle +USER253,FEMALE,0.54,0.51,0.55,0.64,0.19,Low +USER254,MALE,0.61,0.78,0.69,0.92,0.58,High +USER255,FEMALE,0.78,0.61,0.71,0.19,0.6,Middle +USER256,FEMALE,0.54,0.82,0.71,0.29,0.77,High +USER257,FEMALE,0.5,0.75,0.81,0.61,0.26,Middle +USER258,FEMALE,0.66,0.9,0.76,0.87,0.74,High Added: trunk/test/fuzzydll/EvKnowledge/EvKnowledge.rdf =================================================================== --- trunk/test/fuzzydll/EvKnowledge/EvKnowledge.rdf (rev 0) +++ trunk/test/fuzzydll/EvKnowledge/EvKnowledge.rdf 2013-11-17 14:55:56 UTC (rev 4149) @@ -0,0 +1,2847 @@ +<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:foaf="http://xmlns.com/foaf/0.1/" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + +<rdf:Description rdf:about="http://UserKnowledge0"> + <foaf:name>USER1</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">very_low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge1"> + <foaf:name>USER2</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.08</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.08</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.24</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.9</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">High</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge2"> + <foaf:name>USER3</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.06</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.06</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.05</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.25</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.33</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge3"> + <foaf:name>USER4</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.15</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.65</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.3</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge4"> + <foaf:name>USER5</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.08</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.08</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.08</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.98</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.24</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge5"> + <foaf:name>USER6</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.09</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.15</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.4</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.66</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge6"> + <foaf:name>USER7</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.43</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.29</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.56</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge7"> + <foaf:name>USER8</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.15</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.02</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.34</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.4</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.01</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">very_low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge8"> + <foaf:name>USER9</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.2</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.14</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.35</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.72</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.25</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge9"> + <foaf:name>USER10</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.5</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.2</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.85</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">High</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge10"> + <foaf:name>USER11</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.18</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.18</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.55</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.3</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.81</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">High</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge11"> + <foaf:name>USER12</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.06</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.06</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.51</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.41</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.3</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge12"> + <foaf:name>USER13</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.52</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.78</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.34</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge13"> + <foaf:name>USER14</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.7</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.15</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.9</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">High</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge14"> + <foaf:name>USER15</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.2</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.2</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.7</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.3</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.6</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge15"> + <foaf:name>USER16</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.12</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.12</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.75</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.35</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.8</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">High</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge16"> + <foaf:name>USER17</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.05</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.07</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.7</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.01</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.05</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">very_low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge17"> + <foaf:name>USER18</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.25</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.08</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.33</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge18"> + <foaf:name>USER19</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.15</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.32</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.05</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.27</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.29</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge19"> + <foaf:name>USER20</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.2</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.29</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.25</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.49</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.56</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge20"> + <foaf:name>USER21</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.12</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.28</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.2</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.78</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.2</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge21"> + <foaf:name>USER22</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.18</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.3</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.37</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.12</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.66</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge22"> + <foaf:name>USER23</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.27</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.31</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.29</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.65</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge23"> + <foaf:name>USER24</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.18</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.31</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.32</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.42</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.28</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge24"> + <foaf:name>USER25</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.06</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.29</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.35</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.76</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.25</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge25"> + <foaf:name>USER26</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.09</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.3</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.68</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.18</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.85</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">High</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge26"> + <foaf:name>USER27</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.04</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.28</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.55</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.25</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">very_low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge27"> + <foaf:name>USER28</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.09</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.255</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.6</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.45</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.25</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge28"> + <foaf:name>USER29</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.08</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.325</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.62</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.94</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.56</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">High</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge29"> + <foaf:name>USER30</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.15</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.275</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.8</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.21</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.81</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">High</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge30"> + <foaf:name>USER31</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.12</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.245</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.75</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.31</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.59</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge31"> + <foaf:name>USER32</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.15</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.295</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.75</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.65</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.24</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge32"> + <foaf:name>USER33</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.256</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.7</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.76</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.16</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge33"> + <foaf:name>USER34</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.18</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.32</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.04</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.19</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.82</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">High</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge34"> + <foaf:name>USER35</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.2</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.45</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.28</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.31</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.78</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">High</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge35"> + <foaf:name>USER36</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.06</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.35</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.12</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.43</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.29</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge36"> + <foaf:name>USER37</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.42</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.22</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.72</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.26</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge37"> + <foaf:name>USER38</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.18</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.4</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.32</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.08</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.33</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge38"> + <foaf:name>USER39</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.09</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.33</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.31</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.26</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">very_low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge39"> + <foaf:name>USER40</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.19</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.38</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.38</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.49</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.45</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge40"> + <foaf:name>USER41</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.02</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.33</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.36</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.76</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge41"> + <foaf:name>USER42</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Female"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.2</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.49</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.6</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.2</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.78</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">High</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge42"> + <foaf:name>USER43</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.14</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.49</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.55</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.29</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.6</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge43"> + <foaf:name>USER44</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.18</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.33</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.61</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.64</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.25</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge44"> + <foaf:name>USER45</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.115</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.35</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.65</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.27</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.04</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">very_low</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge45"> + <foaf:name>USER46</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.17</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.36</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.8</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.14</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.66</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge46"> + <foaf:name>USER47</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.1</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.39</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.75</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.31</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.62</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">Middle</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge47"> + <foaf:name>USER48</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.13</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.39</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.85</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.38</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.77</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">High</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge48"> + <foaf:name>USER49</foaf:name> + <foaf:gender rdf:resource="http://www.w3.org/2006/vcard/ns#Male"/> + <TimeUsedForStudy xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.18</TimeUsedForStudy> + <DegreeRepititionNo xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.34</DegreeRepititionNo> + <DegreeStudyTime xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.71</DegreeStudyTime> + <ExamPerformanceEverything xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.71</ExamPerformanceEverything> + <ExamPerformanceGoal xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.9</ExamPerformanceGoal> + <KnowledgeLevel xmlns="http://127.0.0.1:3333/" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">High</KnowledgeLevel> +</rdf:Description> + +<rdf:Description rdf:about="http://UserKnowledge49"> + <foaf:name>USER50</foaf:name> + <foaf:gender rdf:... [truncated message content] |
From: <dc...@us...> - 2013-11-14 09:06:44
|
Revision: 4148 http://sourceforge.net/p/dl-learner/code/4148 Author: dcherix Date: 2013-11-14 09:06:41 +0000 (Thu, 14 Nov 2013) Log Message: ----------- Changes for debian package Modified Paths: -------------- trunk/interfaces/pom.xml Added Paths: ----------- trunk/interfaces/src/debian/interfaces.log Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2013-11-14 06:15:56 UTC (rev 4147) +++ trunk/interfaces/pom.xml 2013-11-14 09:06:41 UTC (rev 4148) @@ -334,7 +334,7 @@ </mapper> </data> <data> - <src>${basedir}/log/interfaces.log</src> + <src>${basedir}/src/debian/interfaces.log</src> <type>file</type> <mapper> <type>perm</type> Added: trunk/interfaces/src/debian/interfaces.log =================================================================== --- trunk/interfaces/src/debian/interfaces.log (rev 0) +++ trunk/interfaces/src/debian/interfaces.log 2013-11-14 09:06:41 UTC (rev 4148) @@ -0,0 +1,2 @@ + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dc...@us...> - 2013-11-14 06:15:59
|
Revision: 4147 http://sourceforge.net/p/dl-learner/code/4147 Author: dcherix Date: 2013-11-14 06:15:56 +0000 (Thu, 14 Nov 2013) Log Message: ----------- Adapt changelog for the CI with jenkins Modified Paths: -------------- trunk/interfaces/src/debian/changelog Modified: trunk/interfaces/src/debian/changelog =================================================================== --- trunk/interfaces/src/debian/changelog 2013-11-12 14:29:49 UTC (rev 4146) +++ trunk/interfaces/src/debian/changelog 2013-11-14 06:15:56 UTC (rev 4147) @@ -1 +1,5 @@ +dl-learner-cli (1.0) UNRELEASED; urgency=low + * Initial release. (Closes: #XXXXXX) + + -- dcherix <dcherix@jl-Latitude-E6420> Thu, 14 Nov 2013 07:12:07 +0100 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-11-12 14:29:52
|
Revision: 4146 http://sourceforge.net/p/dl-learner/code/4146 Author: lorenz_b Date: 2013-11-12 14:29:49 +0000 (Tue, 12 Nov 2013) Log Message: ----------- Added experiment for QTL/LGG on QALD3 trainset. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeFactory.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/impl/QueryTreeFactoryImpl.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/impl/QueryTreeFactoryImpl2.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/LGGGeneratorImpl.java trunk/components-core/src/main/resources/log4j.properties Added Paths: ----------- trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/QALDExperiment.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeFactory.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeFactory.java 2013-11-12 13:41:05 UTC (rev 4145) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeFactory.java 2013-11-12 14:29:49 UTC (rev 4146) @@ -19,6 +19,8 @@ */ package org.dllearner.algorithms.qtl; +import java.util.Set; + import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; import org.dllearner.algorithms.qtl.filters.Filter; @@ -49,5 +51,9 @@ void setStatementSelector(Selector selector); void setStatementFilter(com.hp.hpl.jena.util.iterator.Filter<Statement> filter); + + void addAllowedNamespaces(Set<String> allowedNamespaces); + + void addIgnoredPropperties(Set<String> ignoredProperties); } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/impl/QueryTreeFactoryImpl.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/impl/QueryTreeFactoryImpl.java 2013-11-12 13:41:05 UTC (rev 4145) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/impl/QueryTreeFactoryImpl.java 2013-11-12 14:29:49 UTC (rev 4146) @@ -35,6 +35,7 @@ import org.dllearner.algorithms.qtl.filters.QuestionBasedStatementFilter; import org.dllearner.algorithms.qtl.filters.ZeroFilter; +import com.google.common.collect.Sets; import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Model; @@ -44,6 +45,7 @@ import com.hp.hpl.jena.rdf.model.Selector; import com.hp.hpl.jena.rdf.model.SimpleSelector; import com.hp.hpl.jena.rdf.model.Statement; +import com.hp.hpl.jena.vocabulary.RDF; /** * @@ -63,6 +65,9 @@ private int maxDepth = 3; + private Set<String> allowedNamespaces = Sets.newHashSet(RDF.getURI()); + private Set<String> ignoredProperties = Sets.newHashSet(); + public QueryTreeFactoryImpl(){ comparator = new StatementComparator(); predicateFilters = new HashSet<String>(Filters.getAllFilterProperties()); @@ -172,7 +177,52 @@ } private void fillMap(Resource s, Model model, SortedMap<String, SortedSet<Statement>> resource2Statements){ - Iterator<Statement> it = model.listStatements(s, null, (RDFNode)null).filterKeep(keepFilter); + com.hp.hpl.jena.util.iterator.Filter<Statement> nsFilter = null; + if(allowedNamespaces.size() > 1){ + nsFilter = new com.hp.hpl.jena.util.iterator.Filter<Statement>() { + + @Override + public boolean accept(Statement st) { + boolean valid = false; + if(st.getSubject().isURIResource()){ + for (String ns : allowedNamespaces) { + if(st.getSubject().getURI().startsWith(ns)){ + valid = true; + break; + } + } + } else { + valid = true; + } + if(valid){ + valid = false; + if(!ignoredProperties.contains(st.getPredicate().getURI())){ + for (String ns : allowedNamespaces) { + if(st.getPredicate().getURI().startsWith(ns)){ + valid = true; + break; + } + } + } + } + if(valid){ + if(st.getObject().isURIResource()){ + valid = false; + for (String ns : allowedNamespaces) { + if(st.getObject().asResource().getURI().startsWith(ns)){ + valid = true; + break; + } + } + } + } + + return valid; + } + }; + } + Iterator<Statement> it = model.listStatements(s, null, (RDFNode)null).filterKeep(nsFilter); + Statement st; SortedSet<Statement> statements; while(it.hasNext()){ @@ -193,18 +243,21 @@ nodeId = 0; SortedMap<String, SortedSet<Statement>> resource2Statements = new TreeMap<String, SortedSet<Statement>>(); - Statement st; - SortedSet<Statement> statements; - Iterator<Statement> it = model.listStatements(statementSelector); - while(it.hasNext()){ - st = it.next(); - statements = resource2Statements.get(st.getSubject().toString()); - if(statements == null){ - statements = new TreeSet<Statement>(comparator); - resource2Statements.put(st.getSubject().toString(), statements); - } - statements.add(st); - } +// Statement st; +// SortedSet<Statement> statements; +// Iterator<Statement> it = model.listStatements(statementSelector); +// while(it.hasNext()){ +// st = it.next(); +// statements = resource2Statements.get(st.getSubject().toString()); +// if(statements == null){ +// statements = new TreeSet<Statement>(comparator); +// resource2Statements.put(st.getSubject().toString(), statements); +// } +// statements.add(st); +// } + + fillMap(s, model, resource2Statements); + QueryTreeImpl<String> tree = new QueryTreeImpl<String>(s.toString()); int depth = 0; fillTree(tree, resource2Statements, depth); @@ -341,4 +394,20 @@ return encodedHtml.toString(); } + /* (non-Javadoc) + * @see org.dllearner.algorithms.qtl.QueryTreeFactory#addAllowedNamespaces(java.util.Set) + */ + @Override + public void addAllowedNamespaces(Set<String> allowedNamespaces) { + this.allowedNamespaces.addAll(allowedNamespaces); + } + + /* (non-Javadoc) + * @see org.dllearner.algorithms.qtl.QueryTreeFactory#addIgnoredPropperties(java.util.Set) + */ + @Override + public void addIgnoredPropperties(Set<String> ignoredProperties) { + this.ignoredProperties.addAll(ignoredProperties); + } + } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/impl/QueryTreeFactoryImpl2.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/impl/QueryTreeFactoryImpl2.java 2013-11-12 13:41:05 UTC (rev 4145) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/impl/QueryTreeFactoryImpl2.java 2013-11-12 14:29:49 UTC (rev 4146) @@ -317,4 +317,18 @@ return encodedHtml.toString(); } + /* (non-Javadoc) + * @see org.dllearner.algorithms.qtl.QueryTreeFactory#addAllowedNamespaces(java.util.Set) + */ + @Override + public void addAllowedNamespaces(Set<String> allowedNamespaces) { + } + + /* (non-Javadoc) + * @see org.dllearner.algorithms.qtl.QueryTreeFactory#addIgnoredPropperties(java.util.Set) + */ + @Override + public void addIgnoredPropperties(Set<String> ignoredProperties) { + } + } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/LGGGeneratorImpl.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/LGGGeneratorImpl.java 2013-11-12 13:41:05 UTC (rev 4145) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/LGGGeneratorImpl.java 2013-11-12 14:29:49 UTC (rev 4146) @@ -66,7 +66,7 @@ QueryTree<N> lgg = computeLGG(tree1, tree2, learnFilters); mon.stop(); addNumbering(lgg); - System.out.println("Calls needed: " + calls); + logger.debug("Calls needed: " + calls); return lgg; } Modified: trunk/components-core/src/main/resources/log4j.properties =================================================================== --- trunk/components-core/src/main/resources/log4j.properties 2013-11-12 13:41:05 UTC (rev 4145) +++ trunk/components-core/src/main/resources/log4j.properties 2013-11-12 14:29:49 UTC (rev 4146) @@ -14,4 +14,5 @@ log4j.appender.FA.layout.ConversionPattern=%d{ABSOLUTE} %p [%c] %L - %m%n -log4j.category.org.dllearner.algorithms=DEBUG +log4j.category.org.dllearner.algorithms=INFO +log4j.category.org.dllearner.algorithms.isle=DEBUG Added: trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/QALDExperiment.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/QALDExperiment.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/QALDExperiment.java 2013-11-12 14:29:49 UTC (rev 4146) @@ -0,0 +1,240 @@ +/** + * + */ +package org.dllearner.algorithms.qtl; + +import java.io.IOException; +import java.net.URL; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.aksw.jena_sparql_api.cache.core.QueryExecutionFactoryCacheEx; +import org.aksw.jena_sparql_api.cache.extra.CacheCoreEx; +import org.aksw.jena_sparql_api.cache.extra.CacheCoreH2; +import org.aksw.jena_sparql_api.cache.extra.CacheEx; +import org.aksw.jena_sparql_api.cache.extra.CacheExImpl; +import org.aksw.jena_sparql_api.core.QueryExecutionFactory; +import org.apache.log4j.Logger; +import org.dllearner.algorithms.qtl.datastructures.QueryTree; +import org.dllearner.algorithms.qtl.impl.QueryTreeFactoryImpl; +import org.dllearner.algorithms.qtl.operations.lgg.LGGGenerator; +import org.dllearner.algorithms.qtl.operations.lgg.LGGGeneratorImpl; +import org.dllearner.kb.sparql.ConciseBoundedDescriptionGenerator; +import org.dllearner.kb.sparql.ConciseBoundedDescriptionGeneratorImpl; +import org.dllearner.kb.sparql.QueryExecutionFactoryHttp; +import org.dllearner.kb.sparql.SparqlEndpoint; +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import com.google.common.collect.Sets; +import com.hp.hpl.jena.query.QuerySolution; +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.rdf.model.Model; + +/** + * @author Lorenz Buehmann + * + */ +public class QALDExperiment { + + + private static final Logger logger = Logger.getLogger(QALDExperiment.class.getName()); + + String qaldQuestionsURL = "http://greententacle.techfak.uni-bielefeld.de/~cunger/qald/3/dbpedia-train.xml"; + SparqlEndpoint endpoint = SparqlEndpoint.getEndpointDBpedia(); + Set<String> allowedNamespaces = Sets.newHashSet("http://dbpedia.org/ontology/", "http://dbpedia.org/resource/"); + Set<String> ignoredProperties = Sets.newHashSet("http://dbpedia.org/ontology/wikiPageID","http://dbpedia.org/ontology/wikiPageRevisionID"); + + QueryExecutionFactory qef; + String cacheDirectory = "cache"; + int nrOfPositiveExamples = 5; + int maxDepth = 1; + + QueryTreeFactory<String> queryTreeFactory; + ConciseBoundedDescriptionGenerator cbdGen; + private LGGGenerator<String> lggGenerator; + + + public QALDExperiment() { + qef = new QueryExecutionFactoryHttp(endpoint.getURL().toString(), endpoint.getDefaultGraphURIs()); + if(cacheDirectory != null){ + try { + long timeToLive = TimeUnit.DAYS.toMillis(60); + CacheCoreEx cacheBackend = CacheCoreH2.create(cacheDirectory, timeToLive, true); + CacheEx cacheFrontend = new CacheExImpl(cacheBackend); + qef = new QueryExecutionFactoryCacheEx(qef, cacheFrontend); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + queryTreeFactory = new QueryTreeFactoryImpl(); + queryTreeFactory.addAllowedNamespaces(allowedNamespaces); + queryTreeFactory.addIgnoredPropperties(ignoredProperties); + cbdGen = new ConciseBoundedDescriptionGeneratorImpl(endpoint); + cbdGen.setRecursionDepth(maxDepth); + + lggGenerator = new LGGGeneratorImpl<String>(); + } + + public void run(){ + List<String> sparqlQueries = loadSPARQLQueries(); + + for (String sparqlQuery : sparqlQueries) { + logger.info("Processing query\n" + sparqlQuery); + try { + //get result set of SPARQL query + List<String> resources = getResult(sparqlQuery); + + if(resources.size() >= nrOfPositiveExamples){ + //shuffle the list to avoid bias + Collections.shuffle(resources, new Random(123)); + + //pick some positive examples from the list + List<String> positiveExamples = resources.subList(0, Math.min(nrOfPositiveExamples, resources.size())); + + //convert examples to query trees + List<QueryTree<String>> queryTrees = getQueryTrees(positiveExamples); + + //run LGG + QueryTree<String> lgg = lggGenerator.getLGG(queryTrees); + logger.info("Computed LGG:\n" + lgg.getStringRepresentation()); + String learnedSPARQLQuery = lgg.toSPARQLQueryString(); + + double fmeasure = fMeasure(sparqlQuery, learnedSPARQLQuery); + logger.info("F-Score: " + fmeasure); + } + } catch (Exception e) { + logger.error("Error occured.", e); + } + } + } + + private List<QueryTree<String>> getQueryTrees(List<String> resources){ + List<QueryTree<String>> trees = new ArrayList<QueryTree<String>>(); + + for (String resource : resources) { + Model cbd = cbdGen.getConciseBoundedDescription(resource); + QueryTree<String> tree = queryTreeFactory.getQueryTree(resource, cbd); + trees.add(tree); + } + + return trees; + } + + private List<String> getResult(String sparqlQuery){ + List<String> resources = new ArrayList<String>(); + + ResultSet rs = qef.createQueryExecution(sparqlQuery).execSelect(); + QuerySolution qs; + while(rs.hasNext()){ + qs = rs.next(); + if(qs.get("uri") != null){ + resources.add(qs.getResource("uri").getURI()); + } + } + return resources; + } + + private List<String> loadSPARQLQueries(){ + List<String> queries = new ArrayList<String>(); + try { + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document doc = db.parse(new URL(qaldQuestionsURL).openStream()); + doc.getDocumentElement().normalize(); + NodeList questionNodes = doc.getElementsByTagName("question"); + + for( int i = 0; i < questionNodes.getLength(); i++){ + + Element questionNode = (Element) questionNodes.item(i); + + int id = Integer.valueOf(questionNode.getAttribute("id")); + String answerType = questionNode.getAttribute("answerType"); + boolean aggregation = Boolean.valueOf(questionNode.getAttribute("aggregation")); + boolean onlydbo = Boolean.valueOf(questionNode.getAttribute("onlydbo")); + + // Read SPARQL query + String sparqlQuery = ((Element)questionNode.getElementsByTagName("query").item(0)).getChildNodes().item(0).getNodeValue().trim(); + + // check if OUT OF SCOPE marked + boolean outOfScope = sparqlQuery.toUpperCase().contains("OUT OF SCOPE"); + + //check if ASK query + boolean askQuery = sparqlQuery.toUpperCase().contains("ASK"); + + if(!aggregation && !outOfScope && !askQuery){ + queries.add(sparqlQuery); + } + } + } + catch (DOMException e) { + e.printStackTrace(); + } + catch (ParserConfigurationException e) { + e.printStackTrace(); + } + catch (SAXException e) { + e.printStackTrace(); + } + catch (IOException e) { + e.printStackTrace(); + } + return queries; + } + + private double fMeasure(String referenceSparqlQuery, String learnedSPARQLQuery){ + //get the reference resources + Set<String> referenceResources = new HashSet<String>(); + ResultSet rs = qef.createQueryExecution(referenceSparqlQuery).execSelect(); + QuerySolution qs; + while(rs.hasNext()){ + qs = rs.next(); + if(qs.get("uri") != null){ + referenceResources.add(qs.getResource("uri").getURI()); + } + } + //get the learned resources + Set<String> learnedResources = new HashSet<String>(); + rs = qef.createQueryExecution(learnedSPARQLQuery).execSelect(); + while (rs.hasNext()) { + qs = rs.next(); + if (qs.get("x0") != null) { + learnedResources.add(qs.getResource("x0").getURI()); + } + } + + int overlap = Sets.intersection(referenceResources, learnedResources).size(); + + double precision = overlap / (double) learnedResources.size(); + double recall = overlap / (double) referenceResources.size(); + + double fMeasure = 0; + if(precision + recall > 0){ + fMeasure = 2 * precision * recall / (precision + recall); + } + + return fMeasure; + } + + public static void main(String[] args) throws Exception { + new QALDExperiment().run(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-11-12 13:41:08
|
Revision: 4145 http://sourceforge.net/p/dl-learner/code/4145 Author: lorenz_b Date: 2013-11-12 13:41:05 +0000 (Tue, 12 Nov 2013) Log Message: ----------- Fixed bug caused to leading/trailing spaces in trie. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SimpleEntityCandidatesTrie.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SimpleEntityCandidatesTrie.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SimpleEntityCandidatesTrie.java 2013-11-11 15:35:44 UTC (rev 4144) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SimpleEntityCandidatesTrie.java 2013-11-12 13:41:05 UTC (rev 4145) @@ -52,7 +52,6 @@ if (text.trim().isEmpty()) { continue; } - text = text.trim(); addEntry(text, entity); addSubsequencesWordNet(entity, text); @@ -150,6 +149,7 @@ @Override public void addEntry(String s, Entity e) { + s = s.trim(); FullTokenEntitySetPair candidates; if (trie.contains(s)) candidates = trie.get(s); @@ -162,6 +162,7 @@ } public void addEntry(String s, Entity e, String originalString) { + s = s.trim(); FullTokenEntitySetPair candidates; if (trie.contains(s)) candidates = trie.get(s); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-11-11 15:35:47
|
Revision: 4144 http://sourceforge.net/p/dl-learner/code/4144 Author: lorenz_b Date: 2013-11-11 15:35:44 +0000 (Mon, 11 Nov 2013) Log Message: ----------- Added exact FScore accuracy method to PosOnlyLP + JUnit test. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/learningproblems/PosOnlyLP.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java Added Paths: ----------- trunk/components-core/src/test/java/org/dllearner/test/junit/LearningProblemTest.java Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/PosOnlyLP.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/learningproblems/PosOnlyLP.java 2013-11-11 14:48:21 UTC (rev 4143) +++ trunk/components-core/src/main/java/org/dllearner/learningproblems/PosOnlyLP.java 2013-11-11 15:35:44 UTC (rev 4144) @@ -28,6 +28,7 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.apache.log4j.Logger; import org.dllearner.core.AbstractLearningProblem; import org.dllearner.core.AbstractReasonerComponent; import org.dllearner.core.ComponentAnn; @@ -39,6 +40,8 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; +import com.google.common.collect.Sets; + /** * A learning problem, where we learn from positive examples only. * @@ -47,16 +50,24 @@ */ @ComponentAnn(name = "positive only learning problem", shortName = "posonlylp", version = 0.6) public class PosOnlyLP extends AbstractLearningProblem { + + private static Logger logger = Logger.getLogger(PosOnlyLP.class); + private long nanoStartTime; protected SortedSet<Individual> positiveExamples; private List<Individual> positiveExamplesShuffled; // protected SortedSet<Individual> pseudoNegatives; private List<Individual> individuals; + + private boolean useApproximations = false; // approximation of accuracy +- 0.03 % private static final double approx = 0.03; + // factor for higher weight on recall (needed for subclass learning) + private double coverageFactor; + public PosOnlyLP() { super(null); } @@ -130,6 +141,13 @@ } /** + * @param useApproximations the useApproximations to set + */ + public void setUseApproximations(boolean useApproximations) { + this.useApproximations = useApproximations; + } + + /** * @return the pseudoNegatives */ // public SortedSet<Individual> getPseudoNegatives() { @@ -139,7 +157,7 @@ // public int coveredPseudoNegativeExamplesOrTooWeak(Description concept) { // return definitionLP.coveredNegativeExamplesOrTooWeak(concept); -// } +// }posOnlyLPLearningTests /* (non-Javadoc) * @see org.dllearner.core.LearningProblem#computeScore(org.dllearner.core.owl.Description) @@ -195,11 +213,8 @@ return getAccuracy(coverage, protusion); } - /* (non-Javadoc) - * @see org.dllearner.core.LearningProblem#getAccuracyOrTooWeak(org.dllearner.core.owl.Description, double) - */ - @Override - public double getAccuracyOrTooWeak(Description description, double noise) { + + public double getAccuracyOrTooWeakApprox(Description description, double noise) { // instead of using the standard operation, we use optimisation // and approximation here @@ -317,6 +332,48 @@ return getAccuracy(coverage, protusion); } + /* (non-Javadoc) + * @see org.dllearner.core.AbstractLearningProblem#getAccuracyOrTooWeak(org.dllearner.core.owl.Description, double) + */ + @Override + public double getAccuracyOrTooWeak(Description description, double noise) { + return useApproximations ? getAccuracyOrTooWeakApprox(description, noise) : getAccuracyOrTooWeakExact(description, noise); + } + + // exact computation for 5 heuristics; each one adapted to super class + // learning; + // each one takes the noise parameter into account + public double getAccuracyOrTooWeakExact(Description description, double noise) { + + nanoStartTime = System.nanoTime(); + + SortedSet<Individual> individualsC = reasoner.getIndividuals(description); + + // computing R(C) restricted to relevant instances + int additionalInstances = Sets.difference(individualsC, positiveExamples).size(); + + // computing R(A) + int coveredInstances = Sets.intersection(individualsC, positiveExamples).size(); + + double recall = coveredInstances / (double) positiveExamples.size(); + + // noise computation is incorrect + // if(recall < 1 - noise) { + // return -1; + // } + + double precision = (additionalInstances + coveredInstances == 0) ? 0 : coveredInstances + / (double) (coveredInstances + additionalInstances); + + // best reachable concept has same recall and precision 1: + if (((1 + Math.sqrt(coverageFactor)) * recall) / (Math.sqrt(coverageFactor) + 1) < 1 - noise) { + return -1; + } else { + return Heuristics.getFScore(recall, precision, coverageFactor); + } + + } + // see paper: expression used in confidence interval estimation private static double p3(double p1, int total) { return 1.96 * Math.sqrt(p1*(1-p1)/(total+4)); Modified: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java 2013-11-11 14:48:21 UTC (rev 4143) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java 2013-11-11 15:35:44 UTC (rev 4144) @@ -53,6 +53,10 @@ public abstract class Experiment { /** + * + */ + private static final int maxExecutionTimeInSeconds = 20; + /** * The number of folds for the cross-validation */ private final int FOLDS = 10; @@ -61,6 +65,8 @@ */ private final boolean LEAVE_ONE_OUT = false; + private boolean equivalence = true; + private PosOnlyLP lp; private RelevanceMetric relevance; private AbstractReasonerComponent reasoner; @@ -221,30 +227,28 @@ lp.init(); //get the start class for the learning algorithms - Description startClass = getStartClass(cls, true, true); + Description startClass = getStartClass(cls, equivalence, true); Map<Entity, Double> entityRelevance = RelevanceUtils.getRelevantEntities(cls, ontology, relevance); NLPHeuristic heuristic = new NLPHeuristic(entityRelevance); - // heuristic.setStartNodeBonus(100); - heuristic.init(); ClassLearningProblem clp = new ClassLearningProblem(reasoner); clp.setClassToDescribe(cls); + clp.setEquivalence(equivalence); clp.init(); - System.out.println(reasoner.getObjectProperties()); - RhoDRDown rop = new RhoDRDown(); rop.setReasoner(reasoner); rop.setUseNegation(true); rop.init(); // perform cross validation with ISLE - ISLE isle = new ISLE(clp, reasoner); + ISLE isle = new ISLE(lp, reasoner); isle.setHeuristic(heuristic); - isle.setMaxNrOfResults(1); + isle.setMaxNrOfResults(3); isle.setOperator(rop); -// isle.setStartClass(startClass); + isle.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); + isle.setStartClass(startClass); new File(testFolder).mkdirs(); isle.setSearchTreeFile(testFolder + "searchTreeISLE.txt"); isle.setWriteSearchTree(true); Added: trunk/components-core/src/test/java/org/dllearner/test/junit/LearningProblemTest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test/junit/LearningProblemTest.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/test/junit/LearningProblemTest.java 2013-11-11 15:35:44 UTC (rev 4144) @@ -0,0 +1,79 @@ +/** + * + */ +package org.dllearner.test.junit; + +import static org.junit.Assert.*; + +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.core.AbstractKnowledgeSource; +import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.owl.ClassAssertionAxiom; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.KB; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Thing; +import org.dllearner.kb.KBFile; +import org.dllearner.learningproblems.PosNegLPStandard; +import org.dllearner.learningproblems.PosOnlyLP; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.reasoning.OWLAPIReasoner; +import org.junit.Test; + +import com.google.common.collect.Sets; + +/** + * @author Lorenz Buehmann + * + */ +public class LearningProblemTest { + + @Test + public void posOnlyLPLearningTests() throws ComponentInitException { + // create artificial ontology + KB kb = new KB(); + String ns = "http://dl-learner.org/junit/"; + NamedClass[] nc = new NamedClass[5]; + for(int i=0; i<5; i++) { + nc[i] = new NamedClass(ns + "A" + i); + } + Individual[] ind = new Individual[100]; + for(int i=0; i<100; i++) { + ind[i] = new Individual(ns + "i" + i); + } + + // assert individuals to owl:Thing (such that they exist in the knowledge base) + for(int i=0; i<100; i++) { + kb.addAxiom(new ClassAssertionAxiom(Thing.instance,ind[i])); + } + + // A0 + kb.addAxiom(new ClassAssertionAxiom(nc[0],ind[0])); + kb.addAxiom(new ClassAssertionAxiom(nc[0],ind[1])); + kb.addAxiom(new ClassAssertionAxiom(nc[0],ind[5])); + + // A1 + kb.addAxiom(new ClassAssertionAxiom(nc[1],ind[0])); + kb.addAxiom(new ClassAssertionAxiom(nc[1],ind[1])); + kb.addAxiom(new ClassAssertionAxiom(nc[1],ind[2])); + kb.addAxiom(new ClassAssertionAxiom(nc[1],ind[5])); + + AbstractKnowledgeSource ks = new KBFile(kb); + + AbstractReasonerComponent reasoner = new FastInstanceChecker(ks); + reasoner.init(); + + SortedSet<Individual> positiveExamples = new TreeSet<Individual>(Sets.newHashSet(ind[0], ind[1], ind[2], ind[3], ind[4])); + PosOnlyLP lp = new PosOnlyLP(reasoner); + lp.setPositiveExamples(positiveExamples); + + assertEquals(lp.getAccuracyOrTooWeak(nc[0], 1.0), 2/3d, 0.000000001d); // P=2/3, R=2/5 + assertEquals(lp.getAccuracyOrTooWeak(nc[1], 1.0), 3/4d, 0.000000001d); // P=3/4, R=3/5 + assertEquals(lp.getAccuracyOrTooWeak(nc[2], 1.0), 0d, 0.000000001d); // P=0, R=0 + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2013-11-11 14:48:24
|
Revision: 4143 http://sourceforge.net/p/dl-learner/code/4143 Author: jenslehmann Date: 2013-11-11 14:48:21 +0000 (Mon, 11 Nov 2013) Log Message: ----------- ISLE Bible Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java Modified: trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java 2013-11-11 13:38:04 UTC (rev 4142) +++ trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java 2013-11-11 14:48:21 UTC (rev 4143) @@ -84,7 +84,7 @@ * domain/range restrictions. Furthermore, it makes use of disjoint * classes in the knowledge base. * - * TODO Some of the code has moved to {@link Utility} in a modified + * Note: Some of the code has moved to {@link Utility} in a modified * form to make it accessible for implementations of other refinement * operators. These utility methods may be completed and carefully * integrated back later. @@ -232,48 +232,12 @@ } -// public RhoDRDown(AbstractReasonerComponent reasoningService) { -//// this(reasoningService, reasoningService.getClassHierarchy(), null, true, true, true, true, true, 3, true, true, true, true, null); -// this.reasoner = reasoningService; -// this.subHierarchy = reasoner.getClassHierarchy(); -// init(); -// } - - // TODO constructor which takes a RhoDRDownConfigurator object; - // this should be an interface implemented e.g. by ExampleBasedROLComponentConfigurator; - // the goal is to use the configurator system while still being flexible enough to - // use one refinement operator in several learning algorithms -// public RhoDRDown(AbstractReasonerComponent reasoningService, ClassHierarchy subHierarchy, boolean applyAllFilter, boolean applyExistsFilter, boolean useAllConstructor, -// boolean useExistsConstructor, boolean useHasValueConstructor, int valueFrequencyThreshold, boolean useCardinalityRestrictions,boolean useNegation, boolean useBooleanDatatypes, boolean useDoubleDatatypes, NamedClass startClass, -// int cardinalityLimit, boolean useStringDatatypes, boolean instanceBasedDisjoints) { -// this.reasoner = reasoningService; -// this.subHierarchy = subHierarchy; -// this.applyAllFilter = applyAllFilter; -// this.applyExistsFilter = applyExistsFilter; -// this.useAllConstructor = useAllConstructor; -// this.useExistsConstructor = useExistsConstructor; -// this.useHasValueConstructor = useHasValueConstructor; -// this.frequencyThreshold = valueFrequencyThreshold; -// this.useCardinalityRestrictions = useCardinalityRestrictions; -// this.cardinalityLimit = cardinalityLimit; -// this.useNegation = useNegation; -// this.useBooleanDatatypes = useBooleanDatatypes; -// this.useDoubleDatatypes = useDoubleDatatypes; -// this.useStringDatatypes = useStringDatatypes; -// this.instanceBasedDisjoints = instanceBasedDisjoints; -// if(startClass != null) { -// this.startClass = startClass; -// } -// init(); -// } - -// subHierarchy = rs.getClassHierarchy(); public void init() throws ComponentInitException { if(isInitialised) { throw new ComponentInitException("Refinement operator cannot be nitialised twice."); } // System.out.println("subHierarchy: " + subHierarchy); -// System.out.println("object properties: " + ); +// System.out.println("object properties: " + reasoner.getObjectProperties()); // query reasoner for domains and ranges // (because they are used often in the operator) Modified: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java 2013-11-11 13:38:04 UTC (rev 4142) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java 2013-11-11 14:48:21 UTC (rev 4143) @@ -225,7 +225,8 @@ Map<Entity, Double> entityRelevance = RelevanceUtils.getRelevantEntities(cls, ontology, relevance); NLPHeuristic heuristic = new NLPHeuristic(entityRelevance); - heuristic.setStartNodeBonus(100); + // heuristic.setStartNodeBonus(100); + heuristic.init(); ClassLearningProblem clp = new ClassLearningProblem(reasoner); clp.setClassToDescribe(cls); @@ -235,13 +236,13 @@ RhoDRDown rop = new RhoDRDown(); rop.setReasoner(reasoner); - rop.setUseNegation(false); + rop.setUseNegation(true); rop.init(); // perform cross validation with ISLE ISLE isle = new ISLE(clp, reasoner); isle.setHeuristic(heuristic); - isle.setMaxNrOfResults(30); + isle.setMaxNrOfResults(1); isle.setOperator(rop); // isle.setStartClass(startClass); new File(testFolder).mkdirs(); @@ -251,6 +252,7 @@ // isle.setTerminateOnNoiseReached(true); isle.setIgnoredConcepts(Collections.singleton(cls)); isle.setReplaceSearchTree(true); + isle.setMaxExecutionTimeInSeconds(10); isle.init(); isle.start();System.exit(1); List<? extends EvaluatedDescription> currentlyBestDescriptions = isle.getCurrentlyBestEvaluatedDescriptions(20); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-11-11 13:38:08
|
Revision: 4142 http://sourceforge.net/p/dl-learner/code/4142 Author: lorenz_b Date: 2013-11-11 13:38:04 +0000 (Mon, 11 Nov 2013) Log Message: ----------- isle. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/PatternBasedAxiomLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner2.java trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/owl/Description.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyDomainAxiom.java trunk/components-core/src/main/java/org/dllearner/reasoning/OWLAPIReasoner.java trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/PrefixTrie.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLClassExpressionToSPARQLConverter.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/CrossValidation.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/SemanticBibleExperiment.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/LGGTest.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/pom.xml 2013-11-11 13:38:04 UTC (rev 4142) @@ -172,7 +172,7 @@ </dependency> <dependency> - <groupId>fuzzydll</groupId> + <groupId>org.fuzzy</groupId> <artifactId>fuzzydl</artifactId> <version>1.0</version> </dependency> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/PatternBasedAxiomLearningAlgorithm.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/PatternBasedAxiomLearningAlgorithm.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/PatternBasedAxiomLearningAlgorithm.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -47,6 +47,7 @@ import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; +import com.hp.hpl.jena.rdf.arp.ARPOptions; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; @@ -255,6 +256,8 @@ + " }" + " FILTER ( ?cnt1 = ?cnt2 ) }"; + query = "SELECT ?x WHERE {?x a <http://ex.org/A>. FILTER NOT EXISTS{?x <http://ex.org/p> ?s1. FILTER NOT EXISTS{?s1 a <http://ex.org/B>.}}} "; + rs = QueryExecutionFactory.create(query, model).execSelect(); System.out.println(ResultSetFormatter.asText(rs)); Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner2.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner2.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/ObjectPropertyDomainAxiomLearner2.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -20,6 +20,7 @@ package org.dllearner.algorithms.properties; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -33,19 +34,28 @@ import org.dllearner.core.EvaluatedAxiom; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.ObjectPropertyEditor; +import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.KBElement; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectPropertyDomainAxiom; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.SubClassAxiom; +import org.dllearner.core.owl.Thing; import org.dllearner.kb.SparqlEndpointKS; import org.dllearner.kb.sparql.SparqlEndpoint; +import org.dllearner.learningproblems.AxiomScore; +import org.dllearner.learningproblems.Heuristics; import org.dllearner.reasoning.SPARQLReasoner; +import org.dllearner.utilities.owl.OWLClassExpressionToSPARQLConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.hp.hpl.jena.query.ParameterizedSparqlString; +import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.rdf.model.Model; @@ -113,6 +123,113 @@ logger.info("...finished in {}ms.", (System.currentTimeMillis()-startTime)); } + private void buildSampleFragment(){ + workingModel = ModelFactory.createDefaultModel(); + int limit = 10000; + int offset = 0; + String filter = ""; + for (String ns : allowedNamespaces) { + filter += "FILTER(STRSTARTS(STR(?type), '" + ns + "'))"; + } + ParameterizedSparqlString queryTemplate = new ParameterizedSparqlString("CONSTRUCT {?s a ?type.} WHERE {?s ?p ?o. ?s a ?type. " + filter + "}"); + queryTemplate.setIri("p", propertyToDescribe.getName()); + Query query = queryTemplate.asQuery(); + query.setLimit(limit); + Model tmp = executeConstructQuery(query.toString()); + workingModel.add(tmp); + while(!tmp.isEmpty() && !terminationCriteriaSatisfied()){ + //increase offset by limit + offset += limit; + query.setOffset(offset); + //run query + tmp = executeConstructQuery(query.toString()); + workingModel.add(tmp); + } + } + + private void run(){ + //extract sample fragment from KB + buildSampleFragment(); + + //generate a set of axiom candidates + computeAxiomCandidates(); + + //compute evidence score on the whole KB + List<Axiom> axioms = getCurrentlyBestAxioms(); + currentlyBestAxioms = new ArrayList<EvaluatedAxiom>(); + //get total number of instances of A + int cntA = reasoner.getPopularity(propertyToDescribe); + OWLClassExpressionToSPARQLConverter converter = new OWLClassExpressionToSPARQLConverter(); + for (Axiom axiom : axioms) { + //get total number of instances of B + NamedClass domain = ((ObjectPropertyDomainAxiom)axiom).getDomain().asNamedClass(); + int cntB = reasoner.getPopularity(domain); + + //get number of instances of (A AND B) + Query query = converter.asCountQuery(new Intersection(domain, new ObjectSomeRestriction(propertyToDescribe, new Thing()))); +// System.out.println(query); + int cntAB = executeSelectQuery(query.toString()).next().getLiteral("cnt").getInt(); + + //precision (A AND B)/B + double precision = Heuristics.getConfidenceInterval95WaldAverage(cntB, cntAB); + + //recall (A AND B)/A + double recall = Heuristics.getConfidenceInterval95WaldAverage(cntA, cntAB); + + //beta + double beta = 3.0; + + //F score + double fscore = Heuristics.getFScore(recall, precision, beta); + System.out.println(axiom + ":" + fscore + "(P=" + precision + "|R=" + recall + ")"); + currentlyBestAxioms.add(new EvaluatedAxiom(axiom, new AxiomScore(fscore))); +// System.out.println(new EvaluatedAxiom(axiom, new AxiomScore(fscore))); + } + } + + private void computeAxiomCandidates() { + currentlyBestAxioms = new ArrayList<EvaluatedAxiom>(); + // get number of distinct subjects + String query = "SELECT (COUNT(DISTINCT ?s) AS ?all) WHERE {?s a ?type.}"; + ResultSet rs = executeSelectQuery(query, workingModel); + QuerySolution qs; + int all = 1; + while (rs.hasNext()) { + qs = rs.next(); + all = qs.getLiteral("all").getInt(); + } + + // get class and number of instances + query = "SELECT ?type (COUNT(DISTINCT ?s) AS ?cnt) WHERE {?s a ?type.} GROUP BY ?type ORDER BY DESC(?cnt)"; + rs = executeSelectQuery(query, workingModel); + + if (all > 0) { + currentlyBestAxioms.clear(); + while (rs.hasNext()) { + qs = rs.next(); + Resource type = qs.get("type").asResource(); + // omit owl:Thing as trivial domain + if (type.equals(OWL.Thing)) { + continue; + } + currentlyBestAxioms.add(new EvaluatedAxiom(new ObjectPropertyDomainAxiom(propertyToDescribe, + new NamedClass(type.getURI())), computeScore(all, qs.get("cnt").asLiteral().getInt()))); + } + } + } + + private void computeLocalScore(){ + + } + + private void computeScore(Set<ObjectPropertyDomainAxiom> axioms){ + OWLClassExpressionToSPARQLConverter converter = new OWLClassExpressionToSPARQLConverter(); + for (ObjectPropertyDomainAxiom axiom : axioms) { + SubClassAxiom sub = axiom.asSubClassOfAxiom(); + String subClassQuery = converter.convert("?s", sub.getSubConcept()); + } + } + private void runSPARQL1_0_Mode() { workingModel = ModelFactory.createDefaultModel(); int limit = 1000; @@ -193,29 +310,34 @@ org.apache.log4j.Logger.getRootLogger().setLevel(Level.INFO); org.apache.log4j.Logger.getLogger(DataPropertyDomainAxiomLearner.class).setLevel(Level.INFO); - SparqlEndpointKS ks = new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia()); + SparqlEndpointKS ks = new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia(), "cache"); - SPARQLReasoner reasoner = new SPARQLReasoner(ks); + SPARQLReasoner reasoner = new SPARQLReasoner(ks, "cache"); reasoner.prepareSubsumptionHierarchy(); ObjectPropertyDomainAxiomLearner2 l = new ObjectPropertyDomainAxiomLearner2(ks); l.setReasoner(reasoner); - l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/league")); - l.setMaxFetchedRows(20000); - l.setMaxExecutionTimeInSeconds(20); - l.addFilterNamespace("http://dbpedia.org/ontology/"); -// l.setReturnOnlyNewAxioms(true); - l.init(); - l.start(); + for (ObjectProperty p : reasoner.getOWLObjectProperties("http://dbpedia.org/ontology/")) { + System.out.println(p); + l.setPropertyToDescribe(p); + l.setMaxExecutionTimeInSeconds(10); + l.addFilterNamespace("http://dbpedia.org/ontology/"); +// l.setReturnOnlyNewAxioms(true); + l.init(); +// l.start(); + l.run(); + List<EvaluatedAxiom> axioms = l.getCurrentlyBestEvaluatedAxioms(10, 0.5); +// System.out.println(axioms); + System.out.println(l.getBestEvaluatedAxiom()); + } - List<EvaluatedAxiom> axioms = l.getCurrentlyBestEvaluatedAxioms(10, 0.3); - System.out.println(axioms); - for(EvaluatedAxiom axiom : axioms){ - printSubset(l.getPositiveExamples(axiom), 10); - printSubset(l.getNegativeExamples(axiom), 10); - l.explainScore(axiom); - } + +// for(EvaluatedAxiom axiom : axioms){ +// printSubset(l.getPositiveExamples(axiom), 10); +// printSubset(l.getNegativeExamples(axiom), 10); +// l.explainScore(axiom); +// } } } Modified: trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/main/java/org/dllearner/core/AbstractAxiomLearningAlgorithm.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -118,7 +118,7 @@ protected boolean fullDataLoaded = false; - private List<String> filterNamespaces = new ArrayList<String>(); + protected List<String> allowedNamespaces = new ArrayList<String>(); protected ParameterizedSparqlString iterativeQueryTemplate; @@ -274,6 +274,13 @@ return returnList; } + public EvaluatedAxiom getBestEvaluatedAxiom(){ + if(!currentlyBestAxioms.isEmpty()){ + return new TreeSet<EvaluatedAxiom>(currentlyBestAxioms).last(); + } + return null; + } + protected Set<NamedClass> getAllClasses() { if(ks.isRemote()){ return new SPARQLTasks(((SparqlEndpointKS) ks).getEndpoint()).getAllClasses(); @@ -457,7 +464,7 @@ private Query buildQuery(){ Query query = iterativeQueryTemplate.asQuery(); - for(String ns : filterNamespaces){ + for(String ns : allowedNamespaces){ ((ElementGroup)query.getQueryPattern()).addElementFilter( new ElementFilter( new E_Regex( @@ -470,7 +477,7 @@ } public void addFilterNamespace(String namespace){ - filterNamespaces.add(namespace); + allowedNamespaces.add(namespace); } public Set<KBElement> getPositiveExamples(EvaluatedAxiom axiom){ Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/Description.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/Description.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/Description.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -239,8 +239,9 @@ } else if(propertyExpression instanceof DatatypeProperty){ entities.add((DatatypeProperty)propertyExpression); } - entities.addAll(getChild(0).getSignature()); - + if(!(this instanceof ObjectValueRestriction || this instanceof DatatypeValueRestriction) ){ + entities.addAll(getChild(0).getSignature()); + } } else { for (Description child : children) { entities.addAll(child.getSignature()); Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyDomainAxiom.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyDomainAxiom.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyDomainAxiom.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -70,6 +70,12 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); } + + public SubClassAxiom asSubClassOfAxiom(){ + Description subClass = new ObjectSomeRestriction(getProperty(), new Thing()); + Description superClass = getDomain(); + return new SubClassAxiom(subClass, superClass); + } /* (non-Javadoc) * @see org.dllearner.core.owl.KBElement#toManchesterSyntaxString(java.lang.String, java.util.Map) Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/OWLAPIReasoner.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/OWLAPIReasoner.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -357,6 +357,7 @@ if (!inconsistentOntology) { reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY, InferenceType.CLASS_ASSERTIONS); } else { + reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY); throw new ComponentInitException("Inconsistent ontologies."); } Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -766,6 +766,34 @@ } return types; } + + public Set<ObjectProperty> getOWLObjectProperties() { + Set<ObjectProperty> types = new HashSet<ObjectProperty>(); + String query = String.format("SELECT DISTINCT ?p WHERE {?p a <%s>.}",OWL.ObjectProperty.getURI()); + ResultSet rs = executeSelectQuery(query); + QuerySolution qs; + while(rs.hasNext()){ + qs = rs.next(); + types.add(new ObjectProperty(qs.getResource("p").getURI())); + } + return types; + } + + public SortedSet<ObjectProperty> getOWLObjectProperties(String namespace) { + SortedSet<ObjectProperty> types = new TreeSet<ObjectProperty>(); + String query = "SELECT DISTINCT ?p WHERE {?p a <" + OWL.ObjectProperty.getURI() + ">."; + if(namespace != null){ + query += "FILTER(REGEX(STR(?p),'" + namespace + "'))"; + } + query += "}"; + ResultSet rs = executeSelectQuery(query); + QuerySolution qs; + while(rs.hasNext()){ + qs = rs.next(); + types.add(new ObjectProperty(qs.getResource("p").getURI())); + } + return types; + } /** * Returns a set of classes which are siblings, i.e. on the same level Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -20,25 +20,17 @@ package org.dllearner.reasoning.fuzzydll; import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintStream; import java.io.PrintWriter; import java.io.StringWriter; -import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Scanner; import java.util.Set; -import java.util.TreeSet; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.semanticweb.owlapi.model.AxiomType; -import org.semanticweb.owlapi.model.IRI; import org.semanticweb.owlapi.model.OWLAxiom; import org.semanticweb.owlapi.model.OWLClass; import org.semanticweb.owlapi.model.OWLClassExpression; @@ -69,23 +61,25 @@ import org.semanticweb.owlapi.reasoner.UnsupportedEntailmentTypeException; import org.semanticweb.owlapi.reasoner.impl.DefaultNode; import org.semanticweb.owlapi.reasoner.impl.NodeFactory; -import org.semanticweb.owlapi.reasoner.impl.OWLClassNode; -import org.semanticweb.owlapi.reasoner.impl.OWLClassNodeSet; -import org.semanticweb.owlapi.reasoner.impl.OWLNamedIndividualNode; import org.semanticweb.owlapi.reasoner.impl.OWLNamedIndividualNodeSet; import org.semanticweb.owlapi.util.SimpleShortFormProvider; import org.semanticweb.owlapi.util.Version; -import uk.ac.manchester.cs.owl.owlapi.OWLNamedIndividualImpl; - import com.clarkparsia.pellet.owlapiv3.PelletReasoner; import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; -import fuzzydl.*; +import fuzzydl.AllInstancesQuery; +import fuzzydl.Concept; +import fuzzydl.ConfigReader; +import fuzzydl.Individual; +import fuzzydl.KnowledgeBase; +import fuzzydl.MinInstanceQuery; +import fuzzydl.Query; import fuzzydl.exception.FuzzyOntologyException; import fuzzydl.milp.Solution; -import fuzzydl.parser.*; -import fuzzydll.fuzzyowl2fuzzydlparser.*; +import fuzzydl.parser.Parser; +import fuzzydll.fuzzyowl2fuzzydlparser.FuzzyOwl2toFuzzyDL; +import fuzzydll.fuzzyowl2fuzzydlparser.OWLAPI_fuzzyDLObjectParser; public class FuzzyDLReasonerManager implements OWLReasoner { @@ -182,10 +176,11 @@ Individual fIndividual = fuzzyKB.getIndividual(shortFormParser.getShortForm((OWLEntity) i)); Concept fConcept = OWLAPI_fuzzyDLObjectParser.getFuzzyDLExpresion(oce); - + try { + Query q = new MinInstanceQuery(fConcept, fIndividual); - try { + KnowledgeBase clonedFuzzyKB = fuzzyKB.clone(); // TODO: just for testing, remove @@ -368,8 +363,8 @@ } @Override - public NodeSet<OWLNamedIndividual> getInstances(OWLClassExpression arg0, - boolean arg1) throws InconsistentOntologyException, + public NodeSet<OWLNamedIndividual> getInstances(OWLClassExpression cls, + boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { @@ -379,34 +374,50 @@ // added by Josue in order to use fuzzyDL and not Pellet to answer this OWLAPI method boolean differentInstances = false; Solution localQuerySolution = null; - NodeSet<OWLNamedIndividual> owlApiOutput = crispReasoner.getInstances(arg0, arg1); + //get all instances using OWL API + NodeSet<OWLNamedIndividual> owlApiOutput = crispReasoner.getInstances(cls, direct); Set<OWLNamedIndividual> owlApiInstances = owlApiOutput.getFlattened(); - for (Individual fuzzyIndividual : fuzzyKB.individuals.values()) { - // TODO this "query process" is repeated several times --> create a (private) method - Query localQuery = new MinInstanceQuery(OWLAPI_fuzzyDLObjectParser.getFuzzyDLExpresion(arg0), fuzzyIndividual); - try { - KnowledgeBase clonedFuzzyKB = fuzzyKB.clone(); - localQuerySolution = localQuery.solve(clonedFuzzyKB); - if (!localQuerySolution.isConsistentKB()){ - System.err.println("Fuzzy KB is inconsistent."); - System.err.println("This may be a fuzzyDL reasoner bug. Press enter to continue."); - System.err.println("concept: " + arg0 + " individual: " + fuzzyIndividual); - Scanner sc = new Scanner(System.in); - sc.nextLine(); + //get all instances using FuzzyDL + try { + Concept fuzzyConcept = OWLAPI_fuzzyDLObjectParser.getFuzzyDLExpresion(cls); + AllInstancesQuery query = new AllInstancesQuery(fuzzyConcept); + Solution solution = query.solve(fuzzyKB); + if(solution.isConsistentKB() && solution.getSolution() == 0){ + List<Individual> individuals = query.getIndividuals(); + for (Individual individual : individuals) { + } - } catch (Exception e) { - e.printStackTrace(); } - if (localQuerySolution.getSolution() == 0) { - for (OWLNamedIndividual owlApiSingleInstance : owlApiOutput.getFlattened()) { - String a = baseURI.concat(fuzzyIndividual.toString()); - String b = owlApiSingleInstance.toStringID(); - if (a.equals(b)) { - owlApiInstances.remove(owlApiSingleInstance); - differentInstances = true; } - } - } + + } catch (FuzzyOntologyException e1) { + e1.printStackTrace(); } +// for (Individual fuzzyIndividual : fuzzyKB.) { +// // TODO this "query process" is repeated several times --> create a (private) method +// Query localQuery = new MinInstanceQuery(OWLAPI_fuzzyDLObjectParser.getFuzzyDLExpresion(cls), fuzzyIndividual); +// try { +// KnowledgeBase clonedFuzzyKB = fuzzyKB.clone(); +// localQuerySolution = localQuery.solve(clonedFuzzyKB); +// if (!localQuerySolution.isConsistentKB()){ +// System.err.println("Fuzzy KB is inconsistent."); +// System.err.println("This may be a fuzzyDL reasoner bug. Press enter to continue."); +// System.err.println("concept: " + cls + " individual: " + fuzzyIndividual); +// Scanner sc = new Scanner(System.in); +// sc.nextLine(); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// if (localQuerySolution.getSolution() == 0) { +// for (OWLNamedIndividual owlApiSingleInstance : owlApiOutput.getFlattened()) { +// String a = baseURI.concat(fuzzyIndividual.toString()); +// String b = owlApiSingleInstance.toStringID(); +// if (a.equals(b)) { +// owlApiInstances.remove(owlApiSingleInstance); +// differentInstances = true; } +// } +// } +// } if (differentInstances){ Set<Node<OWLNamedIndividual>> instances = new HashSet<Node<OWLNamedIndividual>>(); Modified: trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/PrefixTrie.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/PrefixTrie.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/PrefixTrie.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -150,7 +150,7 @@ * @return A Map mapping each prefix to its corresponding value. */ public Map<String, T> toMap() { - Map<String, T> map = com.google.common.collect.Maps.newLinkedHashMap(); + Map<String, T> map = com.google.common.collect.Maps.newTreeMap(); addEntries(root, new StringBuilder(), map); return map; } Modified: trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLClassExpressionToSPARQLConverter.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLClassExpressionToSPARQLConverter.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLClassExpressionToSPARQLConverter.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -348,13 +348,16 @@ sparql += triple(variables.peek(), propertyExpression.getNamedProperty(), objectVariable); } OWLClassExpression filler = ce.getFiller(); - if(filler.isAnonymous()){ - variables.push(objectVariable); - filler.accept(this); - variables.pop(); - } else { - sparql += triple(objectVariable, "a", filler.asOWLClass()); - } + variables.push(objectVariable); + filler.accept(this); + variables.pop(); +// if(filler.isAnonymous()){ +// variables.push(objectVariable); +// filler.accept(this); +// variables.pop(); +// } else { +// sparql += triple(objectVariable, "a", filler.asOWLClass()); +// } } Modified: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/CrossValidation.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/CrossValidation.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/CrossValidation.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -29,20 +29,25 @@ import java.util.Set; import java.util.TreeSet; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.AbstractLearningProblem; +import org.dllearner.core.AbstractReasonerComponent; import org.dllearner.core.ComponentInitException; -import org.dllearner.core.AbstractCELA; -import org.dllearner.core.AbstractReasonerComponent; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.learningproblems.Heuristics; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyLP; +import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; import org.dllearner.utilities.datastructures.Datastructures; import org.dllearner.utilities.statistics.Stat; -import org.dllearner.utilities.Files; +import com.google.common.base.Charsets; +import com.google.common.hash.HashCode; +import com.google.common.hash.HashFunction; +import com.google.common.hash.Hashing; + /** * Performs cross validation for the given problem. Supports * k-fold cross-validation and leave-one-out cross-validation. @@ -69,6 +74,8 @@ protected Stat testingCompletenessStat = new Stat(); protected Stat testingCorrectnessStat = new Stat(); + static HashFunction hf = Hashing.crc32(); + public CrossValidation() { } @@ -90,7 +97,7 @@ posExamples = ((PosNegLP)lp).getPositiveExamples(); negExamples = ((PosNegLP)lp).getNegativeExamples(); } else if(lp instanceof PosOnlyLP){ - posExamples = ((PosNegLP)lp).getPositiveExamples(); + posExamples = ((PosOnlyLP)lp).getPositiveExamples(); negExamples = new HashSet<Individual>(); } else { throw new IllegalArgumentException("Only PosNeg and PosOnly learning problems are supported"); @@ -184,7 +191,7 @@ int trainingCorrectNegClassified = getCorrectNegClassified(rs, concept, trainingSetsNeg.get(currFold)); int trainingCorrectExamples = trainingCorrectPosClassified + trainingCorrectNegClassified; double trainingAccuracy = 100*((double)trainingCorrectExamples/(trainingSetsPos.get(currFold).size()+ - trainingSetsNeg.get(currFold).size())); + trainingSetsNeg.get(currFold).size())); HashFunction hf = Hashing.md5(); accuracyTraining.addNumber(trainingAccuracy); // calculate test accuracies int correctPosClassified = getCorrectPosClassified(rs, concept, testSetsPos.get(currFold)); @@ -308,5 +315,18 @@ public Stat getfMeasureTraining() { return fMeasureTraining; } - + + /** + * Returns for a given URI the fold number to which the URI is supposed to belong to. + * @param uri + * @param nrOfFolds + * @return + */ + public static int belongsToFoldNumber(String uri, int nrOfFolds){ + HashCode hc = hf.newHasher() + .putString(uri, Charsets.UTF_8) + .hash(); + int fold = hc.asInt() % nrOfFolds; + return fold; + } } Modified: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -4,15 +4,15 @@ package org.dllearner.algorithms.isle; import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.text.DecimalFormat; +import java.util.Collections; import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Set; +import java.util.SortedSet; import org.dllearner.algorithms.celoe.CELOE; -import org.dllearner.algorithms.isle.index.RemoteDataProvider; import org.dllearner.algorithms.isle.index.TextDocument; import org.dllearner.algorithms.isle.index.semantic.SemanticIndex; import org.dllearner.algorithms.isle.index.semantic.simple.SimpleSemanticIndex; @@ -21,22 +21,28 @@ import org.dllearner.algorithms.isle.metrics.RelevanceUtils; import org.dllearner.core.AbstractReasonerComponent; import org.dllearner.core.ComponentInitException; +import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Entity; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Thing; import org.dllearner.kb.OWLAPIOntology; import org.dllearner.learningproblems.ClassLearningProblem; +import org.dllearner.learningproblems.PosOnlyLP; import org.dllearner.reasoning.FastInstanceChecker; -import org.dllearner.utilities.Helper; -import org.semanticweb.owlapi.apibinding.OWLManager; -import org.semanticweb.owlapi.model.IRI; +import org.dllearner.refinementoperators.CustomStartRefinementOperator; +import org.dllearner.refinementoperators.LengthLimitedRefinementOperator; +import org.dllearner.refinementoperators.OperatorInverter; +import org.dllearner.refinementoperators.ReasoningBasedRefinementOperator; +import org.dllearner.refinementoperators.RhoDRDown; import org.semanticweb.owlapi.model.OWLClass; import org.semanticweb.owlapi.model.OWLOntology; -import org.semanticweb.owlapi.model.OWLOntologyManager; -import com.google.common.base.Charsets; +import com.clarkparsia.sparqlowl.parser.antlr.SparqlOwlParser.whereClause_return; import com.google.common.collect.Sets; -import com.google.common.io.Files; /** * Experimental setup: @@ -55,7 +61,7 @@ */ private final boolean LEAVE_ONE_OUT = false; - private ClassLearningProblem lp; + private PosOnlyLP lp; private RelevanceMetric relevance; private AbstractReasonerComponent reasoner; @@ -65,6 +71,7 @@ private Set<TextDocument> documents; private boolean initialized = false; + private RhoDRDown operator; protected abstract OWLOntology getOntology(); @@ -87,7 +94,15 @@ reasoner = new FastInstanceChecker(ks); reasoner.init(); // set learning problem - lp = new ClassLearningProblem(reasoner); +// lp = new ClassLearningProblem(reasoner); + lp = new PosOnlyLP(reasoner); + + //refinement operator for getting a start class + operator = new RhoDRDown(); + if(operator instanceof ReasoningBasedRefinementOperator) { + ((ReasoningBasedRefinementOperator)operator).setReasoner(reasoner); + } + operator.init(); } catch (ComponentInitException e) { e.printStackTrace(); } @@ -124,6 +139,73 @@ } } + private Description getStartClass(NamedClass cls, boolean isEquivalenceProblem, boolean reuseExistingDescription){ + //get instances of class to describe + SortedSet<Individual> individuals = reasoner.getIndividuals(cls); + + //set start class to owl:Thing first + Description startClass = Thing.instance; + if(operator instanceof CustomStartRefinementOperator) { + ((CustomStartRefinementOperator)operator).setStartClass(startClass); + } + if(isEquivalenceProblem) { + Set<Description> existingDefinitions = reasoner.getAssertedDefinitions(cls); + if(reuseExistingDescription && (existingDefinitions.size() > 0)) { + // the existing definition is reused, which in the simplest case means to + // use it as a start class or, if it is already too specific, generalise it + + // pick the longest existing definition as candidate + Description existingDefinition = null; + int highestLength = 0; + for(Description exDef : existingDefinitions) { + if(exDef.getLength() > highestLength) { + existingDefinition = exDef; + highestLength = exDef.getLength(); + } + } + + LinkedList<Description> startClassCandidates = new LinkedList<Description>(); + startClassCandidates.add(existingDefinition); + // hack for RhoDRDown + if(operator instanceof RhoDRDown) { + ((RhoDRDown)operator).setDropDisjuncts(true); + } + LengthLimitedRefinementOperator upwardOperator = (LengthLimitedRefinementOperator) new OperatorInverter(operator); + + // use upward refinement until we find an appropriate start class + boolean startClassFound = false; + Description candidate; + do { + candidate = startClassCandidates.pollFirst(); + SortedSet<Individual> candidateIndividuals = reasoner.getIndividuals(candidate); + double recall = Sets.intersection(individuals, candidateIndividuals).size() / (double)individuals.size(); + if(recall < 1.0) { + // add upward refinements to list + Set<Description> refinements = upwardOperator.refine(candidate, candidate.getLength()); + LinkedList<Description> refinementList = new LinkedList<Description>(refinements); +// Collections.reverse(refinementList); +// System.out.println("list: " + refinementList); + startClassCandidates.addAll(refinementList); +// System.out.println("candidates: " + startClassCandidates); + } else { + startClassFound = true; + } + } while(!startClassFound); + startClass = candidate; + } else { + Set<Description> superClasses = reasoner.getClassHierarchy().getSuperClasses(cls); + if(superClasses.size() > 1) { + startClass = new Intersection(new LinkedList<Description>(superClasses)); + } else if(superClasses.size() == 1){ + startClass = (Description) superClasses.toArray()[0]; + } else { + startClass = Thing.instance; + } + } + } + return startClass; + } + /** * Run the experiment on the given class. * @param cls @@ -132,26 +214,56 @@ public void run(NamedClass cls) throws ComponentInitException { initIfNecessary(); - lp.setClassToDescribe(cls); +// lp.setClassToDescribe(cls); + //get the positive examples, here just the instances of the class to describe + SortedSet<Individual> individuals = reasoner.getIndividuals(cls); + lp.setPositiveExamples(individuals); lp.init(); + //get the start class for the learning algorithms + Description startClass = getStartClass(cls, true, true); + Map<Entity, Double> entityRelevance = RelevanceUtils.getRelevantEntities(cls, ontology, relevance); NLPHeuristic heuristic = new NLPHeuristic(entityRelevance); + heuristic.setStartNodeBonus(100); + ClassLearningProblem clp = new ClassLearningProblem(reasoner); + clp.setClassToDescribe(cls); + clp.init(); + + System.out.println(reasoner.getObjectProperties()); + + RhoDRDown rop = new RhoDRDown(); + rop.setReasoner(reasoner); + rop.setUseNegation(false); + rop.init(); + // perform cross validation with ISLE - ISLE isle = new ISLE(lp, reasoner); + ISLE isle = new ISLE(clp, reasoner); isle.setHeuristic(heuristic); -// isle.setSearchTreeFile(testFolder + "searchTreeISLE.txt"); -// isle.setWriteSearchTree(true); + isle.setMaxNrOfResults(30); + isle.setOperator(rop); +// isle.setStartClass(startClass); + new File(testFolder).mkdirs(); + isle.setSearchTreeFile(testFolder + "searchTreeISLE.txt"); + isle.setWriteSearchTree(true); // isle.setReplaceSearchTree(true); - isle.setTerminateOnNoiseReached(true); +// isle.setTerminateOnNoiseReached(true); + isle.setIgnoredConcepts(Collections.singleton(cls)); + isle.setReplaceSearchTree(true); isle.init(); + isle.start();System.exit(1); + List<? extends EvaluatedDescription> currentlyBestDescriptions = isle.getCurrentlyBestEvaluatedDescriptions(20); + for (EvaluatedDescription description : currentlyBestDescriptions) { + System.out.println(description); + } CrossValidation crossValidationISLE = new CrossValidation(isle, lp, reasoner, FOLDS, LEAVE_ONE_OUT); // perform cross validation with CELOE CELOE celoe = new CELOE(lp, reasoner); -// celoe.setSearchTreeFile(testFolder + "searchTreeCELOE.txt"); -// celoe.setWriteSearchTree(true); + celoe.setStartClass(startClass); + celoe.setSearchTreeFile(testFolder + "searchTreeCELOE.txt"); + celoe.setWriteSearchTree(true); // celoe.setReplaceSearchTree(true); celoe.setTerminateOnNoiseReached(true); celoe.init(); Modified: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/SemanticBibleExperiment.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/SemanticBibleExperiment.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/SemanticBibleExperiment.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -10,6 +10,7 @@ import java.util.HashSet; import java.util.Set; +import org.aksw.jena_sparql_api.model.QueryExecutionFactoryModel; import org.dllearner.algorithms.isle.index.RemoteDataProvider; import org.dllearner.algorithms.isle.index.TextDocument; import org.dllearner.core.owl.NamedClass; @@ -22,6 +23,9 @@ import com.google.common.base.Charsets; import com.google.common.collect.Sets; import com.google.common.io.Files; +import com.hp.hpl.jena.query.ResultSetFormatter; +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; /** * @author Lorenz Buehmann @@ -41,6 +45,11 @@ OWLOntology mergedOntology = man.createOntology(IRI.create("http://semanticbible.com/merged.owl")); man.addAxioms(mergedOntology, schema.getAxioms()); man.addAxioms(mergedOntology, instances.getAxioms()); +// Model model = ModelFactory.createDefaultModel(); +// model.read("http://www.semanticbible.com/2006/11/NTNames.owl"); +// model.read("http://www.semanticbible.com/2006/11/NTN-individuals.owl"); +// QueryExecutionFactoryModel qef = new QueryExecutionFactoryModel(model); +// System.out.println(ResultSetFormatter.asText(qef.createQueryExecution("SELECT ?s ?p WHERE {?s a <http://semanticbible.org/ns/2006/NTNames#Woman>. ?s ?p ?o.}").execSelect())); return mergedOntology; } catch (OWLOntologyCreationException e) { e.printStackTrace(); Modified: trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/LGGTest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/LGGTest.java 2013-11-08 09:29:40 UTC (rev 4141) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/LGGTest.java 2013-11-11 13:38:04 UTC (rev 4142) @@ -21,6 +21,7 @@ import java.io.File; import java.io.FileInputStream; +import java.net.URL; import java.util.ArrayList; import java.util.List; @@ -34,6 +35,9 @@ import org.dllearner.algorithms.qtl.operations.lgg.LGGGenerator; import org.dllearner.algorithms.qtl.operations.lgg.LGGGeneratorImpl; import org.dllearner.algorithms.qtl.operations.lgg.NoiseSensitiveLGG; +import org.dllearner.kb.sparql.ConciseBoundedDescriptionGenerator; +import org.dllearner.kb.sparql.ConciseBoundedDescriptionGeneratorImpl; +import org.dllearner.kb.sparql.SparqlEndpoint; import org.junit.Assert; import org.junit.Test; @@ -427,6 +431,31 @@ System.out.println("Covered negatives:" + coveredNegatives); } } + + @Test + public void testTCGA() throws Exception{ + URL url = new URL("http://vmlion14.deri.ie/node43/8080/sparql"); + SparqlEndpoint endpoint = new SparqlEndpoint(url); + List<String> posExamples = Lists.newArrayList("http://tcga.deri.ie/TCGA-BI-A0VS","http://tcga.deri.ie/TCGA-BI-A20A"); + + ConciseBoundedDescriptionGenerator cbdGen = new ConciseBoundedDescriptionGeneratorImpl(endpoint); + + QueryTreeFactory<String> queryTreeFactory = new QueryTreeFactoryImpl(); + + List<QueryTree<String>> posExampleTrees = new ArrayList<QueryTree<String>>(); + for (String ex : posExamples) { + Model cbd = cbdGen.getConciseBoundedDescription(ex, 0); + System.out.println(cbd.size()); + QueryTreeImpl<String> tree = queryTreeFactory.getQueryTree(ex, cbd); + posExampleTrees.add(tree); + } + + NoiseSensitiveLGG<String> lggGenerator = new NoiseSensitiveLGG<String>(); + List<EvaluatedQueryTree<String>> lggs = lggGenerator.computeLGG(posExampleTrees); + for (EvaluatedQueryTree<String> lgg : lggs) { + System.out.println(lgg); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-11-08 09:29:43
|
Revision: 4141 http://sourceforge.net/p/dl-learner/code/4141 Author: lorenz_b Date: 2013-11-08 09:29:40 +0000 (Fri, 08 Nov 2013) Log Message: ----------- Added experiment class. Modified Paths: -------------- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETestCorpus.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETestNoCorpus.java Added Paths: ----------- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/CrossValidation.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/SemanticBibleExperiment.java Added: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/CrossValidation.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/CrossValidation.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/CrossValidation.java 2013-11-08 09:29:40 UTC (rev 4141) @@ -0,0 +1,312 @@ +/** + * 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.algorithms.isle; + +import java.io.File; +import java.text.DecimalFormat; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Random; +import java.util.Set; +import java.util.TreeSet; + +import org.dllearner.core.AbstractLearningProblem; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.AbstractCELA; +import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; +import org.dllearner.learningproblems.Heuristics; +import org.dllearner.learningproblems.PosNegLP; +import org.dllearner.learningproblems.PosOnlyLP; +import org.dllearner.utilities.Helper; +import org.dllearner.utilities.datastructures.Datastructures; +import org.dllearner.utilities.statistics.Stat; +import org.dllearner.utilities.Files; + +/** + * Performs cross validation for the given problem. Supports + * k-fold cross-validation and leave-one-out cross-validation. + * + * @author Jens Lehmann + * + */ +public class CrossValidation { + + // statistical values + protected Stat runtime = new Stat(); + protected Stat accuracy = new Stat(); + protected Stat length = new Stat(); + protected Stat accuracyTraining = new Stat(); + protected Stat fMeasure = new Stat(); + protected Stat fMeasureTraining = new Stat(); + protected static boolean writeToFile = false; + protected static File outputFile; + + + protected Stat trainingCompletenessStat = new Stat(); + protected Stat trainingCorrectnessStat = new Stat(); + + protected Stat testingCompletenessStat = new Stat(); + protected Stat testingCorrectnessStat = new Stat(); + + public CrossValidation() { + + } + + public CrossValidation(AbstractCELA la, AbstractLearningProblem lp, AbstractReasonerComponent rs, int folds, boolean leaveOneOut) { + + DecimalFormat df = new DecimalFormat(); + + // the training and test sets used later on + List<Set<Individual>> trainingSetsPos = new LinkedList<Set<Individual>>(); + List<Set<Individual>> trainingSetsNeg = new LinkedList<Set<Individual>>(); + List<Set<Individual>> testSetsPos = new LinkedList<Set<Individual>>(); + List<Set<Individual>> testSetsNeg = new LinkedList<Set<Individual>>(); + + // get examples and shuffle them too + Set<Individual> posExamples; + Set<Individual> negExamples; + if(lp instanceof PosNegLP){ + posExamples = ((PosNegLP)lp).getPositiveExamples(); + negExamples = ((PosNegLP)lp).getNegativeExamples(); + } else if(lp instanceof PosOnlyLP){ + posExamples = ((PosNegLP)lp).getPositiveExamples(); + negExamples = new HashSet<Individual>(); + } else { + throw new IllegalArgumentException("Only PosNeg and PosOnly learning problems are supported"); + } + List<Individual> posExamplesList = new LinkedList<Individual>(posExamples); + List<Individual> negExamplesList = new LinkedList<Individual>(negExamples); + Collections.shuffle(posExamplesList, new Random(1)); + Collections.shuffle(negExamplesList, new Random(2)); + + // sanity check whether nr. of folds makes sense for this benchmark + if(!leaveOneOut && (posExamples.size()<folds && negExamples.size()<folds)) { + System.out.println("The number of folds is higher than the number of " + + "positive/negative examples. This can result in empty test sets. Exiting."); + System.exit(0); + } + + if(leaveOneOut) { + // note that leave-one-out is not identical to k-fold with + // k = nr. of examples in the current implementation, because + // with n folds and n examples there is no guarantee that a fold + // is never empty (this is an implementation issue) + int nrOfExamples = posExamples.size() + negExamples.size(); + for(int i = 0; i < nrOfExamples; i++) { + // ... + } + System.out.println("Leave-one-out not supported yet."); + System.exit(1); + } else { + // calculating where to split the sets, ; note that we split + // positive and negative examples separately such that the + // distribution of positive and negative examples remains similar + // (note that there are better but more complex ways to implement this, + // which guarantee that the sum of the elements of a fold for pos + // and neg differs by at most 1 - it can differ by 2 in our implementation, + // e.g. with 3 folds, 4 pos. examples, 4 neg. examples) + int[] splitsPos = calculateSplits(posExamples.size(),folds); + int[] splitsNeg = calculateSplits(negExamples.size(),folds); + +// System.out.println(splitsPos[0]); +// System.out.println(splitsNeg[0]); + + // calculating training and test sets + for(int i=0; i<folds; i++) { + Set<Individual> testPos = getTestingSet(posExamplesList, splitsPos, i); + Set<Individual> testNeg = getTestingSet(negExamplesList, splitsNeg, i); + testSetsPos.add(i, testPos); + testSetsNeg.add(i, testNeg); + trainingSetsPos.add(i, getTrainingSet(posExamples, testPos)); + trainingSetsNeg.add(i, getTrainingSet(negExamples, testNeg)); + } + + } + + // run the algorithm + for(int currFold=0; currFold<folds; currFold++) { + + Set<String> pos = Datastructures.individualSetToStringSet(trainingSetsPos.get(currFold)); + Set<String> neg = Datastructures.individualSetToStringSet(trainingSetsNeg.get(currFold)); + if(lp instanceof PosNegLP){ + ((PosNegLP)lp).setPositiveExamples(trainingSetsPos.get(currFold)); + ((PosNegLP)lp).setNegativeExamples(trainingSetsNeg.get(currFold)); + } else if(lp instanceof PosOnlyLP){ + ((PosOnlyLP)lp).setPositiveExamples(new TreeSet<Individual>(trainingSetsPos.get(currFold))); + } + + + try { + lp.init(); + la.init(); + } catch (ComponentInitException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + long algorithmStartTime = System.nanoTime(); + la.start(); + long algorithmDuration = System.nanoTime() - algorithmStartTime; + runtime.addNumber(algorithmDuration/(double)1000000000); + + Description concept = la.getCurrentlyBestDescription(); + + Set<Individual> tmp = rs.hasType(concept, testSetsPos.get(currFold)); + Set<Individual> tmp2 = Helper.difference(testSetsPos.get(currFold), tmp); + Set<Individual> tmp3 = rs.hasType(concept, testSetsNeg.get(currFold)); + + outputWriter("test set errors pos: " + tmp2); + outputWriter("test set errors neg: " + tmp3); + + // calculate training accuracies + int trainingCorrectPosClassified = getCorrectPosClassified(rs, concept, trainingSetsPos.get(currFold)); + int trainingCorrectNegClassified = getCorrectNegClassified(rs, concept, trainingSetsNeg.get(currFold)); + int trainingCorrectExamples = trainingCorrectPosClassified + trainingCorrectNegClassified; + double trainingAccuracy = 100*((double)trainingCorrectExamples/(trainingSetsPos.get(currFold).size()+ + trainingSetsNeg.get(currFold).size())); + accuracyTraining.addNumber(trainingAccuracy); + // calculate test accuracies + int correctPosClassified = getCorrectPosClassified(rs, concept, testSetsPos.get(currFold)); + int correctNegClassified = getCorrectNegClassified(rs, concept, testSetsNeg.get(currFold)); + int correctExamples = correctPosClassified + correctNegClassified; + double currAccuracy = 100*((double)correctExamples/(testSetsPos.get(currFold).size()+ + testSetsNeg.get(currFold).size())); + accuracy.addNumber(currAccuracy); + // calculate training F-Score + int negAsPosTraining = rs.hasType(concept, trainingSetsNeg.get(currFold)).size(); + double precisionTraining = trainingCorrectPosClassified + negAsPosTraining == 0 ? 0 : trainingCorrectPosClassified / (double) (trainingCorrectPosClassified + negAsPosTraining); + double recallTraining = trainingCorrectPosClassified / (double) trainingSetsPos.get(currFold).size(); + fMeasureTraining.addNumber(100*Heuristics.getFScore(recallTraining, precisionTraining)); + // calculate test F-Score + int negAsPos = rs.hasType(concept, testSetsNeg.get(currFold)).size(); + double precision = correctPosClassified + negAsPos == 0 ? 0 : correctPosClassified / (double) (correctPosClassified + negAsPos); + double recall = correctPosClassified / (double) testSetsPos.get(currFold).size(); +// System.out.println(precision);System.out.println(recall); + fMeasure.addNumber(100*Heuristics.getFScore(recall, precision)); + + length.addNumber(concept.getLength()); + + outputWriter("fold " + currFold + ":"); + outputWriter(" training: " + pos.size() + " positive and " + neg.size() + " negative examples"); + outputWriter(" testing: " + correctPosClassified + "/" + testSetsPos.get(currFold).size() + " correct positives, " + + correctNegClassified + "/" + testSetsNeg.get(currFold).size() + " correct negatives"); + outputWriter(" concept: " + concept); + outputWriter(" accuracy: " + df.format(currAccuracy) + "% (" + df.format(trainingAccuracy) + "% on training set)"); + outputWriter(" length: " + df.format(concept.getLength())); + outputWriter(" runtime: " + df.format(algorithmDuration/(double)1000000000) + "s"); + + } + + outputWriter(""); + outputWriter("Finished " + folds + "-folds cross-validation."); + outputWriter("runtime: " + statOutput(df, runtime, "s")); + outputWriter("length: " + statOutput(df, length, "")); + outputWriter("F-Measure on training set: " + statOutput(df, fMeasureTraining, "%")); + outputWriter("F-Measure: " + statOutput(df, fMeasure, "%")); + outputWriter("predictive accuracy on training set: " + statOutput(df, accuracyTraining, "%")); + outputWriter("predictive accuracy: " + statOutput(df, accuracy, "%")); + + } + + protected int getCorrectPosClassified(AbstractReasonerComponent rs, Description concept, Set<Individual> testSetPos) { + return rs.hasType(concept, testSetPos).size(); + } + + protected int getCorrectNegClassified(AbstractReasonerComponent rs, Description concept, Set<Individual> testSetNeg) { + return testSetNeg.size() - rs.hasType(concept, testSetNeg).size(); + } + + public static Set<Individual> getTestingSet(List<Individual> examples, int[] splits, int fold) { + int fromIndex; + // we either start from 0 or after the last fold ended + if(fold == 0) + fromIndex = 0; + else + fromIndex = splits[fold-1]; + // the split corresponds to the ends of the folds + int toIndex = splits[fold]; + +// System.out.println("from " + fromIndex + " to " + toIndex); + + Set<Individual> testingSet = new HashSet<Individual>(); + // +1 because 2nd element is exclusive in subList method + testingSet.addAll(examples.subList(fromIndex, toIndex)); + return testingSet; + } + + public static Set<Individual> getTrainingSet(Set<Individual> examples, Set<Individual> testingSet) { + return Helper.difference(examples, testingSet); + } + + // takes nr. of examples and the nr. of folds for this examples; + // returns an array which says where each fold ends, i.e. + // splits[i] is the index of the last element of fold i in the examples + public static int[] calculateSplits(int nrOfExamples, int folds) { + int[] splits = new int[folds]; + for(int i=1; i<=folds; i++) { + // we always round up to the next integer + splits[i-1] = (int)Math.ceil(i*nrOfExamples/(double)folds); + } + return splits; + } + + public static String statOutput(DecimalFormat df, Stat stat, String unit) { + String str = "av. " + df.format(stat.getMean()) + unit; + str += " (deviation " + df.format(stat.getStandardDeviation()) + unit + "; "; + str += "min " + df.format(stat.getMin()) + unit + "; "; + str += "max " + df.format(stat.getMax()) + unit + ")"; + return str; + } + + public Stat getAccuracy() { + return accuracy; + } + + public Stat getLength() { + return length; + } + + public Stat getRuntime() { + return runtime; + } + + protected void outputWriter(String output) { + if(writeToFile) { + Files.appendToFile(outputFile, output +"\n"); + System.out.println(output); + } else { + System.out.println(output); + } + + } + + public Stat getfMeasure() { + return fMeasure; + } + + public Stat getfMeasureTraining() { + return fMeasureTraining; + } + +} Added: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/Experiment.java 2013-11-08 09:29:40 UTC (rev 4141) @@ -0,0 +1,171 @@ +/** + * + */ +package org.dllearner.algorithms.isle; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.dllearner.algorithms.celoe.CELOE; +import org.dllearner.algorithms.isle.index.RemoteDataProvider; +import org.dllearner.algorithms.isle.index.TextDocument; +import org.dllearner.algorithms.isle.index.semantic.SemanticIndex; +import org.dllearner.algorithms.isle.index.semantic.simple.SimpleSemanticIndex; +import org.dllearner.algorithms.isle.metrics.PMIRelevanceMetric; +import org.dllearner.algorithms.isle.metrics.RelevanceMetric; +import org.dllearner.algorithms.isle.metrics.RelevanceUtils; +import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.owl.Entity; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.kb.OWLAPIOntology; +import org.dllearner.learningproblems.ClassLearningProblem; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.utilities.Helper; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; + +import com.google.common.base.Charsets; +import com.google.common.collect.Sets; +import com.google.common.io.Files; + +/** + * Experimental setup: + * + * @author Lorenz Buehmann + * + */ +public abstract class Experiment { + + /** + * The number of folds for the cross-validation + */ + private final int FOLDS = 10; + /** + * Whether to perform k-fold cross-validation or leave-one-out cross-validation + */ + private final boolean LEAVE_ONE_OUT = false; + + private ClassLearningProblem lp; + private RelevanceMetric relevance; + private AbstractReasonerComponent reasoner; + + private String testFolder = "experiments/logs/"; + + private OWLOntology ontology; + private Set<TextDocument> documents; + + private boolean initialized = false; + + + protected abstract OWLOntology getOntology(); + protected abstract Set<TextDocument> getDocuments(); + + private void initIfNecessary() { + if(!initialized){ + ontology = getOntology(); + documents = getDocuments(); + + // build semantic index + SemanticIndex semanticIndex = new SimpleSemanticIndex(ontology, null, false); + semanticIndex.buildIndex(documents); + // set the relevance metric + relevance = new PMIRelevanceMetric(semanticIndex); + try { + // set KB + KnowledgeSource ks = new OWLAPIOntology(ontology); + // set reasoner + reasoner = new FastInstanceChecker(ks); + reasoner.init(); + // set learning problem + lp = new ClassLearningProblem(reasoner); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + initialized = true; + } + } + + /** + * Get the classes on which the experiment is applied. + * @return + */ + private Set<NamedClass> getClasses(){ + Set<NamedClass> classes = new HashSet<NamedClass>(); + + for(OWLClass cls : ontology.getClassesInSignature()){ + classes.add(new NamedClass(cls.toStringID())); + } + + return classes; + } + + /** + * Run the experiment on all classes. + */ + public void run(){ + Set<NamedClass> classes = getClasses(); + + for (NamedClass cls : classes) { + try { + run(cls); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * Run the experiment on the given class. + * @param cls + * @throws ComponentInitException + */ + public void run(NamedClass cls) throws ComponentInitException { + initIfNecessary(); + + lp.setClassToDescribe(cls); + lp.init(); + + Map<Entity, Double> entityRelevance = RelevanceUtils.getRelevantEntities(cls, ontology, relevance); + NLPHeuristic heuristic = new NLPHeuristic(entityRelevance); + + // perform cross validation with ISLE + ISLE isle = new ISLE(lp, reasoner); + isle.setHeuristic(heuristic); +// isle.setSearchTreeFile(testFolder + "searchTreeISLE.txt"); +// isle.setWriteSearchTree(true); +// isle.setReplaceSearchTree(true); + isle.setTerminateOnNoiseReached(true); + isle.init(); + CrossValidation crossValidationISLE = new CrossValidation(isle, lp, reasoner, FOLDS, LEAVE_ONE_OUT); + + // perform cross validation with CELOE + CELOE celoe = new CELOE(lp, reasoner); +// celoe.setSearchTreeFile(testFolder + "searchTreeCELOE.txt"); +// celoe.setWriteSearchTree(true); +// celoe.setReplaceSearchTree(true); + celoe.setTerminateOnNoiseReached(true); + celoe.init(); + CrossValidation crossValidationCELOE = new CrossValidation(isle, lp, reasoner, FOLDS, LEAVE_ONE_OUT); + + System.out.println(crossValidationISLE.getfMeasure()); + +// DecimalFormat df = new DecimalFormat("#00.00"); +// System.out.println("Summary ISLE vs. CELOE"); +// System.out.println("======================"); +// System.out.println("accuracy: " + df.format(100*isle.getCurrentlyBestAccuracy())+"% vs. " + df.format(100*celoe.getCurrentlyBestAccuracy())+"%"); +// System.out.println("expressions tested: " + isle.getClassExpressionTests() + " vs. " + celoe.getClassExpressionTests()); +// System.out.println("search tree nodes: " + isle.getNodes().size() + " vs. " + celoe.getNodes().size()); +// System.out.println("runtime: " + Helper.prettyPrintNanoSeconds(isle.getTotalRuntimeNs()) + " vs. " + Helper.prettyPrintNanoSeconds(celoe.getTotalRuntimeNs())); + } + +} Modified: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETestCorpus.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETestCorpus.java 2013-11-08 09:28:17 UTC (rev 4140) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETestCorpus.java 2013-11-08 09:29:40 UTC (rev 4141) @@ -150,6 +150,10 @@ semanticIndex.buildIndex(createDocuments()); Set<AnnotatedDocument> documents = semanticIndex.getDocuments(cls); System.out.println(documents); + relevance = new PMIRelevanceMetric(semanticIndex); + + Map<Entity, Double> entityRelevance = RelevanceUtils.getRelevantEntities(cls, ontology, relevance); + System.out.println(entityRelevance); } @Test Modified: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETestNoCorpus.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETestNoCorpus.java 2013-11-08 09:28:17 UTC (rev 4140) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETestNoCorpus.java 2013-11-08 09:29:40 UTC (rev 4141) @@ -47,7 +47,7 @@ public ISLETestNoCorpus() throws Exception{ manager = OWLManager.createOWLOntologyManager(); - ontology = manager.loadOntologyFromOntologyDocument(new File(testFolder + "ontology.owl")); + ontology = manager.loadOntologyFromOntologyDocument(new File(testFolder + "ontology_with_comments.owl")); textRetriever = new RDFSLabelEntityTextRetriever(ontology); syntacticIndex = new OWLOntologyLuceneSyntacticIndexCreator(ontology, df.getRDFSLabel(), searchField).buildIndex(); @@ -66,7 +66,7 @@ lp.init(); semanticIndex = new SimpleSemanticIndex(ontology, syntacticIndex); - semanticIndex.buildIndex(df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_COMMENT.getIRI()), "en"); + semanticIndex.buildIndex(df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_COMMENT.getIRI()), null); // semanticIndex = new SimpleSemanticIndex(ontology, syntacticIndex); // semanticIndex.buildIndex(createDocuments()); Added: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/SemanticBibleExperiment.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/SemanticBibleExperiment.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/SemanticBibleExperiment.java 2013-11-08 09:29:40 UTC (rev 4141) @@ -0,0 +1,85 @@ +/** + * + */ +package org.dllearner.algorithms.isle; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; + +import org.dllearner.algorithms.isle.index.RemoteDataProvider; +import org.dllearner.algorithms.isle.index.TextDocument; +import org.dllearner.core.owl.NamedClass; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; + +import com.google.common.base.Charsets; +import com.google.common.collect.Sets; +import com.google.common.io.Files; + +/** + * @author Lorenz Buehmann + * + */ +public class SemanticBibleExperiment extends Experiment{ + + /* (non-Javadoc) + * @see org.dllearner.algorithms.isle.Experiment#getOntology() + */ + @Override + protected OWLOntology getOntology() { + try { + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLOntology schema = man.loadOntology(IRI.create("http://www.semanticbible.com/2006/11/NTNames.owl")); + OWLOntology instances = OWLManager.createOWLOntologyManager().loadOntology(IRI.create("http://www.semanticbible.com/2006/11/NTN-individuals.owl")); + OWLOntology mergedOntology = man.createOntology(IRI.create("http://semanticbible.com/merged.owl")); + man.addAxioms(mergedOntology, schema.getAxioms()); + man.addAxioms(mergedOntology, instances.getAxioms()); + return mergedOntology; + } catch (OWLOntologyCreationException e) { + e.printStackTrace(); + } + return null; + } + + /* (non-Javadoc) + * @see org.dllearner.algorithms.isle.Experiment#getDocuments() + */ + @Override + protected Set<TextDocument> getDocuments() { + Set<TextDocument> documents = new HashSet<TextDocument>(); + try { + RemoteDataProvider bibleByChapter = new RemoteDataProvider( + new URL("http://gold.linkeddata.org/data/bible/split_by_chapter.zip")); + File folder = bibleByChapter.getLocalDirectory(); + for (File file : folder.listFiles()) { + if(!file.isDirectory() && !file.isHidden()){ + try { + String text = Files.toString(file, Charsets.UTF_8); + documents.add(new TextDocument(text)); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + documents = Sets.newHashSet(new TextDocument("and in that day seven women shall take hold of one man saying we will eat our own bread and wear our own apparel only let us be called by thy name to take away our reproach in that day shall the branch of the lord be beautiful and glorious and the fruit of the earth excellent and comely for them that are escaped of israel and it shall come to pass left in zion and remaineth in jerusalem shall be called holy every one that is written among the living in jerusalem when the lord shall have washed away the filth of the daughters of zion and shall have purged the blood of jerusalem from the midst thereof by the spirit of judgment and by the spirit of burning and the lord will create upon every dwelling place of mount zion and upon her assemblies a cloud and smoke by day and the shining of a flaming fire by night for upon all the glory a defence and there shall be a tabernacle for a shadow in the daytime from the heat and for a place of refuge and for a covert from storm and from rain")); + + return documents; + } + + public static void main(String[] args) throws Exception { + new SemanticBibleExperiment().run(new NamedClass("http://semanticbible.org/ns/2006/NTNames#Woman")); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-11-08 09:28:20
|
Revision: 4140 http://sourceforge.net/p/dl-learner/code/4140 Author: lorenz_b Date: 2013-11-08 09:28:17 +0000 (Fri, 08 Nov 2013) Log Message: ----------- Decreased log level. Small improvements in toString of trie.. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SimpleEntityCandidatesTrie.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/semantic/SemanticIndex.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/syntactic/LuceneSyntacticIndex.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/syntactic/TextDocumentSyntacticIndexCreator.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SimpleEntityCandidatesTrie.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SimpleEntityCandidatesTrie.java 2013-10-29 15:08:54 UTC (rev 4139) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SimpleEntityCandidatesTrie.java 2013-11-08 09:28:17 UTC (rev 4140) @@ -3,10 +3,12 @@ import org.apache.commons.lang.StringUtils; import org.dllearner.algorithms.isle.textretrieval.EntityTextRetriever; import org.dllearner.core.owl.Entity; +import org.dllearner.utilities.MapUtils; import org.dllearner.utilities.datastructures.PrefixTrie; import org.semanticweb.owlapi.model.OWLOntology; import java.util.*; +import java.util.Map.Entry; public class SimpleEntityCandidatesTrie implements EntityCandidatesTrie { @@ -50,6 +52,7 @@ if (text.trim().isEmpty()) { continue; } + text = text.trim(); addEntry(text, entity); addSubsequencesWordNet(entity, text); @@ -59,6 +62,7 @@ } } } + } /** @@ -188,17 +192,18 @@ } public String toString() { - String output = ""; + StringBuilder output = new StringBuilder(); Map<String,FullTokenEntitySetPair> trieMap = trie.toMap(); - List<String> termsList = new ArrayList<String>(trieMap.keySet()); - Collections.sort(termsList); - for (String key : termsList) { - output += key + " (" + trieMap.get(key).getFullToken() + ") :\n"; - for (Entity candidate: trieMap.get(key).getEntitySet()) { - output += "\t"+candidate+"\n"; + + for (Entry<String, FullTokenEntitySetPair> entry : trieMap.entrySet()) { + String key = entry.getKey(); + FullTokenEntitySetPair pair = entry.getValue(); + output.append(key + " (" + pair.getFullToken() + ") :\n"); + for (Entity candidate: pair.getEntitySet()) { + output.append("\t"+candidate+"\n"); } } - return output; + return output.toString(); } public static void main(String[] args) { Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/semantic/SemanticIndex.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/semantic/SemanticIndex.java 2013-10-29 15:08:54 UTC (rev 4139) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/semantic/SemanticIndex.java 2013-11-08 09:28:17 UTC (rev 4140) @@ -67,7 +67,7 @@ logger.info("Creating semantic index..."); index = new HashMap<Entity, Set<AnnotatedDocument>>(); for (TextDocument document : documents) { - logger.info("Processing document:\n" + document); + logger.debug("Processing document:" + document); AnnotatedDocument annotatedDocument = semanticAnnotator.processDocument(document); for (Entity entity : annotatedDocument.getContainedEntities()) { Set<AnnotatedDocument> existingAnnotatedDocuments = index.get(entity); @@ -77,7 +77,7 @@ } existingAnnotatedDocuments.add(annotatedDocument); } - logger.info("Annotated document:" + annotatedDocument); + logger.debug("Annotated document:" + annotatedDocument); } size = documents.size(); logger.info("...done."); Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/syntactic/LuceneSyntacticIndex.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/syntactic/LuceneSyntacticIndex.java 2013-10-29 15:08:54 UTC (rev 4139) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/syntactic/LuceneSyntacticIndex.java 2013-11-08 09:28:17 UTC (rev 4140) @@ -78,6 +78,20 @@ public int getSize() { return indexReader.numDocs(); } + + public Set<TextDocument> getAllDocuments(){ + Set<TextDocument> documents = new HashSet<TextDocument>(indexReader.numDocs()); + for (int i = 0; i < indexReader.numDocs(); i++) { + try { + Document doc = indexReader.document(i); + String content = doc.get(searchField); + documents.add(new TextDocument(content)); + } catch (IOException e) { + e.printStackTrace(); + } + } + return documents; + } /* (non-Javadoc) * @see org.dllearner.algorithms.isle.SyntacticIndex#count(java.lang.String) Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/syntactic/TextDocumentSyntacticIndexCreator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/syntactic/TextDocumentSyntacticIndexCreator.java 2013-10-29 15:08:54 UTC (rev 4139) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/syntactic/TextDocumentSyntacticIndexCreator.java 2013-11-08 09:28:17 UTC (rev 4140) @@ -14,6 +14,7 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.SimpleFSDirectory; import org.apache.lucene.util.Version; +import org.dllearner.algorithms.isle.index.TextDocument; import java.io.BufferedReader; import java.io.File; @@ -77,14 +78,41 @@ return new LuceneSyntacticIndex(indexDirectory, searchField); } + + public SyntacticIndex buildIndex(Set<TextDocument> documents) throws Exception{ + Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_43); + IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LUCENE_43, analyzer); + IndexWriter writer = new IndexWriter(indexDirectory, indexWriterConfig); + System.out.println( "Creating index ..." ); + Set<org.apache.lucene.document.Document> luceneDocuments = new HashSet<org.apache.lucene.document.Document>(); + FieldType stringType = new FieldType(StringField.TYPE_STORED); + stringType.setStoreTermVectors(false); + FieldType textType = new FieldType(TextField.TYPE_STORED); + textType.setStoreTermVectors(false); + + int id = 1; + for (TextDocument document : documents) { + org.apache.lucene.document.Document luceneDocument = new org.apache.lucene.document.Document(); + luceneDocument.add(new Field("uri", Integer.toString(id++), stringType)); + luceneDocument.add(new Field(searchField, document.getContent(), textType)); + luceneDocuments.add(luceneDocument); + } + writer.addDocuments(luceneDocuments); + + System.out.println("Done."); + writer.close(); + + return new LuceneSyntacticIndex(indexDirectory, searchField); + } + public static SyntacticIndex loadIndex(File indexDirectory) throws Exception { return new LuceneSyntacticIndex(new SimpleFSDirectory(indexDirectory), searchField); } public static void main(String[] args) throws Exception { if (args.length != 2) { - System.err.println("Usage: <input director> <index directory>"); + System.err.println("Usage: <input directory> <index directory>"); System.exit(1); return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dfl...@us...> - 2013-10-29 15:08:58
|
Revision: 4139 http://sourceforge.net/p/dl-learner/code/4139 Author: dfleischhacker Date: 2013-10-29 15:08:54 +0000 (Tue, 29 Oct 2013) Log Message: ----------- Re-enable post processing Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TrieEntityCandidateGenerator.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TrieEntityCandidateGenerator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TrieEntityCandidateGenerator.java 2013-10-29 14:59:57 UTC (rev 4138) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TrieEntityCandidateGenerator.java 2013-10-29 15:08:54 UTC (rev 4139) @@ -124,7 +124,7 @@ for (Annotation annotation: annotations) candidatesMap.put(annotation, getCandidates(annotation)); - //postProcess(candidatesMap, window, stopWordFilter); + postProcess(candidatesMap, window, stopWordFilter); return candidatesMap; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-10-29 15:00:00
|
Revision: 4138 http://sourceforge.net/p/dl-learner/code/4138 Author: lorenz_b Date: 2013-10-29 14:59:57 +0000 (Tue, 29 Oct 2013) Log Message: ----------- Fixed bug ins WSD. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TrieEntityCandidateGenerator.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TrieEntityCandidateGenerator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TrieEntityCandidateGenerator.java 2013-10-29 14:59:40 UTC (rev 4137) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TrieEntityCandidateGenerator.java 2013-10-29 14:59:57 UTC (rev 4138) @@ -25,7 +25,7 @@ this.candidatesTrie = candidatesTrie; } - public Set<Entity> getCandidates(Annotation annotation) {System.out.println(annotation); + public Set<Entity> getCandidates(Annotation annotation) { return candidatesTrie.getCandidateEntities(annotation.getMatchedString()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-10-29 14:59:43
|
Revision: 4137 http://sourceforge.net/p/dl-learner/code/4137 Author: lorenz_b Date: 2013-10-29 14:59:40 +0000 (Tue, 29 Oct 2013) Log Message: ----------- Fixed bug ins WSD. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/StructuralEntityContext.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TrieEntityCandidateGenerator.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/textretrieval/AnnotationEntityTextRetriever.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/StructuralEntityContext.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/StructuralEntityContext.java 2013-10-29 14:51:29 UTC (rev 4136) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/StructuralEntityContext.java 2013-10-29 14:59:40 UTC (rev 4137) @@ -104,17 +104,7 @@ * @return */ public static Set<OWLEntity> getContext(OWLOntology ontology, Entity entity){ - - OWLEntity owlEntity = OWLAPIConverter.getOWLAPIEntity(entity); - if(owlEntity.isOWLClass()){ - return getContext(ontology, owlEntity.asOWLClass()); - } else if(owlEntity.isOWLObjectProperty()){ - return getContext(ontology, owlEntity.asOWLObjectProperty()); - } else if(owlEntity.isOWLDataProperty()){ - return getContext(ontology, owlEntity.asOWLDataProperty()); - } - - throw new UnsupportedOperationException("Unsupported entity type: " + entity); + return getContext(ontology, OWLAPIConverter.getOWLAPIEntity(entity)); } public static Set<OWLEntity> getContext(OWLOntology ontology, OWLObjectProperty property){ Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TrieEntityCandidateGenerator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TrieEntityCandidateGenerator.java 2013-10-29 14:51:29 UTC (rev 4136) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/TrieEntityCandidateGenerator.java 2013-10-29 14:59:40 UTC (rev 4137) @@ -25,7 +25,7 @@ this.candidatesTrie = candidatesTrie; } - public Set<Entity> getCandidates(Annotation annotation) { + public Set<Entity> getCandidates(Annotation annotation) {System.out.println(annotation); return candidatesTrie.getCandidateEntities(annotation.getMatchedString()); } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/textretrieval/AnnotationEntityTextRetriever.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/textretrieval/AnnotationEntityTextRetriever.java 2013-10-29 14:51:29 UTC (rev 4136) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/textretrieval/AnnotationEntityTextRetriever.java 2013-10-29 14:59:40 UTC (rev 4137) @@ -104,7 +104,7 @@ } /** - * Returns for each entity in the ontology all relevant text, i.e. eitherthe annotations or the short form of the IRI as fallback. + * Returns for each entity in the ontology all relevant text, i.e. either the annotations or the short form of the IRI as fallback. * @return */ @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-10-29 14:51:34
|
Revision: 4136 http://sourceforge.net/p/dl-learner/code/4136 Author: lorenz_b Date: 2013-10-29 14:51:29 +0000 (Tue, 29 Oct 2013) Log Message: ----------- Fixed bug ins WSD score. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/wsd/StructureBasedWordSenseDisambiguation.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/wsd/StructureBasedWordSenseDisambiguation.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/wsd/StructureBasedWordSenseDisambiguation.java 2013-10-29 14:43:25 UTC (rev 4135) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/wsd/StructureBasedWordSenseDisambiguation.java 2013-10-29 14:51:29 UTC (rev 4136) @@ -45,7 +45,7 @@ List<String> tokenContext = contextExtractor.extractContext(annotation); //compare this context with the context of each entity candidate - double maxScore = Double.MIN_VALUE; + double maxScore = Double.NEGATIVE_INFINITY; Entity bestEntity = null; for (Entity entity : candidateEntities) { //get the context of the entity by analyzing the structure of the ontology This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |