From: <ki...@us...> - 2012-09-26 14:44:53
|
Revision: 3849 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3849&view=rev Author: kirdie Date: 2012-09-26 14:44:42 +0000 (Wed, 26 Sep 2012) Log Message: ----------- test case now successfully disambiguates the Mean Hamster Software example from the hmm paper. Modified Paths: -------------- branches/hmm/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner2.java branches/hmm/components-ext/src/test/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner3Test.java Modified: branches/hmm/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner2.java =================================================================== --- branches/hmm/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner2.java 2012-09-21 14:12:34 UTC (rev 3848) +++ branches/hmm/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner2.java 2012-09-26 14:44:42 UTC (rev 3849) @@ -71,17 +71,21 @@ import com.jamonapi.Monitor; import com.jamonapi.MonitorFactory; -public class SPARQLTemplateBasedLearner2 implements SparqlQueryLearningAlgorithm{ - - enum Mode{ - BEST_QUERY, BEST_NON_EMPTY_QUERY - } - +/** The old learner taken over by Konrad Höffner for experiments with the Hidden Markov Algorithm by Saedeeh Shekarpur. + * + * */ +public class SPARQLTemplateBasedLearner2 implements SparqlQueryLearningAlgorithm +{ + enum Mode {BEST_QUERY, BEST_NON_EMPTY_QUERY} private Mode mode = Mode.BEST_QUERY; + + /** used to create a label out of the URI when there is no label available in the SPARQL endpoint.*/ private static SimpleIRIShortFormProvider sfp = new SimpleIRIShortFormProvider(); private static final Logger logger = Logger.getLogger(SPARQLTemplateBasedLearner2.class); + /** synonyms are great but are not used yet by the HMM algorithm. **/ private static final boolean CREATE_SYNONYMS = false; + /** The minimum score of items that are accepted from the Sindice search BOA index. **/ private static final Double BOA_THRESHOLD = 0.9; private Monitor templateMon = MonitorFactory.getTimeMonitor("template"); private Monitor sparqlMon = MonitorFactory.getTimeMonitor("sparql"); @@ -511,8 +515,8 @@ keywords.add(slot.getWords().get(0)); } if(template.getSlots().size()!=3) {continue;} - if(!keywords.contains("Mean Hamster Software")) {continue;} - if(!keywords.contains("published")) {continue;} +// if(!keywords.contains("Mean Hamster Software")) {continue;} +// if(!keywords.contains("published")) {continue;} System.out.println("\"keywords\": "+keywords); } System.out.println(template); @@ -542,7 +546,8 @@ for(String word: slot.getWords()) {max = Math.max(max, Similarity.getSimilarity(word, info.getLabel()));} if(max<0||max>1) throw new AssertionError("max is not in [0,1], max="+max); info.setStringSimilarityScore(max); - + if(!info.setTypeFromDBpediaURI()) throw new AssertionError("could not set type for info "+info); + System.err.println("info with type: "+info); resourceInfos.add(info); } segmentToURIs.put(segment,resourceInfos); 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 2012-09-21 14:12:34 UTC (rev 3848) +++ branches/hmm/components-ext/src/test/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner3Test.java 2012-09-26 14:44:42 UTC (rev 3849) @@ -105,7 +105,7 @@ private static final boolean DBPEDIA_PRETAGGED = true; private static final boolean OXFORD_PRETAGGED = false; - /*@Test*/ public void testDBpedia() throws Exception + @Test public void testDBpedia() throws Exception { File file = generateTestDataIfNecessary( new File(getClass().getClassLoader().getResource("tbsl/evaluation/qald2-dbpedia-train-tagged(ideal).xml").getFile()), @@ -162,7 +162,7 @@ /** For debugging one question in particular. */ - @Test public void testSingleQueryDBpedia() + /*@Test*/ public void testSingleQueryDBpedia() { // Logger.getLogger(Templator.class).setLevel(Level.DEBUG); // Logger.getLogger(Parser.class).setLevel(Level.DEBUG); @@ -681,7 +681,7 @@ return testData; } - /** + /** Updates question file by removing questions without nonempty resource list answer and adding answers. * @param file * @param updatedFile * @throws ParserConfigurationException This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |