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. |