From: <lor...@us...> - 2011-11-03 14:29:38
|
Revision: 3368 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3368&view=rev Author: lorenz_b Date: 2011-11-03 14:29:32 +0000 (Thu, 03 Nov 2011) Log Message: ----------- Small changes in dbprop handling. Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Allocation.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java 2011-11-03 14:04:11 UTC (rev 3367) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java 2011-11-03 14:29:32 UTC (rev 3368) @@ -595,6 +595,7 @@ double score = alpha * a.getSimilarity() + beta * a.getProminence(); a.setScore(score); } + } private Set<WeightedQuery> getWeightedSPARQLQueries(Set<Template> templates){ @@ -615,6 +616,18 @@ computeScore(allocations); slot2Allocations.put(slot, allocations); + + //for tests add the property URI with http://dbpedia.org/property/ namespace + Set<Allocation> tmp = new HashSet<Allocation>(); + if(slot.getSlotType() == SlotType.PROPERTY || slot.getSlotType() == SlotType.SYMPROPERTY){ + for(Allocation a : allocations){ + String uri = "http://dbpedia.org/property/" + a.getUri().substring(a.getUri().lastIndexOf("/")+1); + Allocation newA = new Allocation(uri, a.getSimilarity(), a.getProminence()); + newA.setScore(a.getScore()-0.000001); + tmp.add(newA); + } + } + allocations.addAll(tmp); } @@ -787,15 +800,7 @@ SolrQueryResultSet rs; for(String word : slot.getWords()){ rs = index.getResourcesWithScores(word, 10); - //for tests add the property URI with http://dbpedia.org/property/ namespace - Set<SolrQueryResultItem> tmp = new HashSet<SolrQueryResultItem>(); - if(slot.getSlotType() == SlotType.PROPERTY || slot.getSlotType() == SlotType.SYMPROPERTY){ - for(SolrQueryResultItem i : rs.getItems()){ - String uri = "http://dbpedia.org/property/" + i.getUri().substring(i.getUri().lastIndexOf("/")+1); - tmp.add(new SolrQueryResultItem(i.getLabel(), uri)); - } - } - rs.addItems(tmp); + // System.out.println(word + "->" + rs); for(SolrQueryResultItem item : rs.getItems()){ int prominence = getProminenceValue(item.getUri(), slot.getSlotType()); @@ -1359,9 +1364,10 @@ // Logger.getLogger(HttpMethodBase.class).setLevel(Level.OFF); // String question = "In which programming language is GIMP written?"; // String question = "Who/WP was/VBD the/DT wife/NN of/IN president/NN Lincoln/NNP"; -// String question = "Who/WP produced/VBD the/DT most/JJS films/NNS"; - String question = "Which/WDT country/NN does/VBZ the/DT Airedale/NNP Terrier/NNP come/VBP from/IN"; + String question = "Who/WP produced/VBD the/DT most/JJS films/NNS"; +// String question = "Which/WDT country/NN does/VBZ the/DT Airedale/NNP Terrier/NNP come/VBP from/IN"; // String question = "Which/WDT software/NN has/VBZ been/VBN developed/VBN by/IN organizations/NNS founded/VBN in/IN California/NNP"; +// String question = "How/WRB many/JJ films/NNS did/VBD Leonardo/NNP DiCaprio/NNP star/VB in/IN"; // String question = "Give me all books written by authors influenced by Ernest Hemingway."; SPARQLTemplateBasedLearner learner = new SPARQLTemplateBasedLearner();learner.setUseIdealTagger(true); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Allocation.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Allocation.java 2011-11-03 14:04:11 UTC (rev 3367) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Allocation.java 2011-11-03 14:29:32 UTC (rev 3368) @@ -10,7 +10,7 @@ private double score; - public Allocation(String uri, int prominence, double similarity) { + public Allocation(String uri, double prominence, double similarity) { this.uri = uri; this.prominence = prominence; this.similarity = similarity; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |