From: <seb...@us...> - 2012-04-11 12:29:57
|
Revision: 3631 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3631&view=rev Author: sebastianwtr Date: 2012-04-11 12:29:50 +0000 (Wed, 11 Apr 2012) Log Message: ----------- [tbsl exploration] fixed some small bugs Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/SQLiteIndex.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/ServerUtil.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java 2012-04-09 18:27:16 UTC (rev 3630) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java 2012-04-11 12:29:50 UTC (rev 3631) @@ -85,6 +85,8 @@ public static ArrayList<String> searchIndexForProperty(String string, SQLiteIndex myindex) throws SQLException{ HashMap<String,Float> hm = new HashMap<String,Float>(); + System.err.println("########"); + System.err.println("In search Index for Property"); // adding or set elements in Map by put method key and value pair /* @@ -100,15 +102,19 @@ String result=null; ArrayList<String> result_List = new ArrayList<String>(); result=myindex.getPropertyURI(string.toLowerCase()); + System.err.println("Result: "+result); if(result!=null){ result_List.add(result); hm.put(result, 1.0f); + System.err.println("Found uri for: "+string.toLowerCase()); } else{ + System.err.println("Didnt find uri for: "+string.toLowerCase()); result_List.add("http://dbpedia.org/ontology/"+string.toLowerCase().replace(" ", "_")); hm.put(result, 0.0f); } + System.err.println("########"); return result_List; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/SQLiteIndex.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/SQLiteIndex.java 2012-04-09 18:27:16 UTC (rev 3630) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/SQLiteIndex.java 2012-04-11 12:29:50 UTC (rev 3631) @@ -135,12 +135,54 @@ public String getPropertyURI(String string) throws SQLException{ Statement stat = conn.createStatement(); ResultSet rs; + ArrayList<String> al = new ArrayList<String>(); try { rs = stat.executeQuery("select uri from property where name='"+string.toLowerCase()+"';"); - return rs.getString("uri"); + while(rs.next()){ + String result_string= rs.getString("uri"); + System.out.println("Property: "+result_string); + //check for double: + boolean found = false; + for(String s: al){ + if(s.equals(result_string))found=true; + } + if(found==false)al.add(result_string); + } + + rs = stat.executeQuery("select uri from ontology where name='"+string.toLowerCase()+"';"); + while(rs.next()){ + String result_string= rs.getString("uri"); + System.out.println("OntologyProperty: "+result_string); + //check for double: + boolean found = false; + for(String s: al){ + if(s.equals(result_string))found=true; + } + if(found==false)al.add(result_string); + } + System.out.println("Anzahl ArrayList: "+al.size()); + if(al.size()==1) return al.get(0); + //check if there is one with an ontology in it + else{ + boolean found = false; + for(String s : al){ + if(s.contains("ontology")){ + System.out.println("Return String: "+s); + found=true; + return s; + } + } + if(found==false){ + System.out.println("Return String: "+al.get(0)); + return al.get(0); + } + } + + return null; } catch (Exception e) { // TODO Auto-generated catch block //e.printStackTrace(); + System.err.println("Error in SQLiteIndex.getProperty!!"); return null; } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java 2012-04-09 18:27:16 UTC (rev 3630) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java 2012-04-11 12:29:50 UTC (rev 3631) @@ -227,12 +227,12 @@ ArrayList<ArrayList<Hypothesis>> final_list_set_hypothesis = new ArrayList<ArrayList<Hypothesis>>(); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - System.out.println("Alle Hypothesen VOR der Verarbeitung"); + /* System.out.println("Alle Hypothesen VOR der Verarbeitung"); for(Hypothesis x : list_of_hypothesis){ x.printAll(); } System.out.println("Alle Hypothesen VOR der Verarbeitung - Done \n\n"); - + */ for(Hypothesis x : list_of_hypothesis){ /* * TODO: Change if ISA only ask classes, else resource @@ -279,14 +279,14 @@ } } - System.out.println("Alle Hypothesen nach der ERSTEN Verarbeitung"); + /* System.out.println("Alle Hypothesen nach der ERSTEN Verarbeitung"); for(ArrayList<Hypothesis> lh : final_list_set_hypothesis){ for(Hypothesis x : lh){ x.printAll(); } } System.out.println("Alle Hypothesen nach der ERSTEN Verarbeitung - Done \n\n"); - + */ //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /* @@ -327,13 +327,14 @@ * BUGFIX: Before adding Hypothesis to template check, if each Hypothesis has an uri * TODO: check all functions before */ - /*for(ArrayList<Hypothesis> al:final_list_set_hypothesis){ + for(ArrayList<Hypothesis> al:final_list_set_hypothesis){ for(Hypothesis h : al){ if(!h.getUri().contains("http")){ if(h.getType().contains("ISA")){ try { ArrayList<String> tmp = Index_utils.searchIndexForClass(h.getUri(), myindex); - h.setUri(tmp.get(0)); + System.out.println("Laenge tmp: "+tmp.size()); + if(tmp.size()>0)h.setUri(tmp.get(0)); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -343,7 +344,8 @@ if(h.getType().contains("RESOURCE")){ try { ArrayList<String> tmp = Index_utils.searchIndexForResource(h.getUri(), myindex); - h.setUri(tmp.get(0)); + System.out.println("Laenge tmp: "+tmp.size()); + if(tmp.size()>0)h.setUri(tmp.get(0)); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -353,8 +355,8 @@ } } } - */ - System.out.println("Alle Hypothesen nach der ZWEITEN Verarbeitung"); + + /*System.out.println("Alle Hypothesen nach der ZWEITEN Verarbeitung"); for(ArrayList<Hypothesis> lh : final_list_set_hypothesis){ for(Hypothesis x : lh){ x.printAll(); @@ -362,9 +364,9 @@ } System.out.println("Alle Hypothesen nach der ZWEITEN Verarbeitung - Done \n\n"); + */ - template.setHypothesen(final_list_set_hypothesis); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/ServerUtil.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/ServerUtil.java 2012-04-09 18:27:16 UTC (rev 3630) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/ServerUtil.java 2012-04-11 12:29:50 UTC (rev 3631) @@ -295,6 +295,10 @@ String temp = m.group(1); temp = temp.replace("\"@en",""); temp = temp.replace("\"",""); + temp = temp.replace("^^<http://www.w3.org/2001/XMLSchema#date>",""); + temp = temp.replace("^^<http://www.w3.org/2001/XMLSchema#int>",""); + temp = temp.replace("^^<http://www.w3.org/2001/XMLSchema#number>",""); + temp = temp.replace("\"",""); //result.add(m.group(1)); result.add(temp); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java 2012-04-09 18:27:16 UTC (rev 3630) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java 2012-04-11 12:29:50 UTC (rev 3631) @@ -199,6 +199,7 @@ else{ //else go_on=false; go_on=true; + //go_on=false; for(String s : answer_tmp){ if(checkAnswer(s)){ boolean test = false; @@ -224,7 +225,7 @@ private static boolean checkAnswer(String answer){ - if(answer.contains("File:")||answer.contains(".png")||answer.contains("upload.wikimedia.org")||answer.contains("dbpedia.org/datatype/")||answer.contains("http://www.w3.org/2001/XMLSchema")) return false; + if(answer.contains("File:")||answer.contains(".png")||answer.contains("upload.wikimedia.org")||answer.contains("dbpedia.org/datatype/")||answer.contains("http://www.w3.org/2001/XMLSchema")||answer.contains("flickerwrappr/photos/")) return false; else return true; } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-04-09 18:27:16 UTC (rev 3630) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-04-11 12:29:50 UTC (rev 3631) @@ -90,12 +90,12 @@ /*System.out.println("Please enter Path of xml File:"); line=in.readLine();*/ - //line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train.xml"; - //line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-withoutnonparsed.xml"; + line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train.xml"; + line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-withoutnonparsed.xml"; //line="/home/swalter/Dokumente/Auswertung/XMLDateien/very_small.xml"; //line="/home/swalter/Dokumente/Auswertung/XMLDateien/berlin.xml"; //line="/home/swalter/Dokumente/Auswertung/XMLDateien/vortragfragen.xml"; - line="/home/swalter/Dokumente/Auswertung/XMLDateien/iteration-test.xml"; + //line="/home/swalter/Dokumente/Auswertung/XMLDateien/iteration-test.xml"; //create Structs ArrayList<queryInformation> list_of_structs = new ArrayList<queryInformation>(); @@ -260,6 +260,7 @@ if(i.contains("http")) input="<uri>"+i+"</uri>\n"; else if (i.contains("true")||i.contains("false")) input="<boolean>"+i+"</boolean>\n"; else if(i.matches("[0-9]*"))input="<number>"+i+"</number>\n"; + else if(i.matches("[0-9]*-[0-9][0-9]-[0-9]*"))input="<date>"+i+"</date>\n"; else input="<string>"+i+"</string>\n"; tmp+="<answer>"+input+"</answer>\n"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |