チェンジセット 42 : BH13SPARQLBuilder
- 更新日時:
- 2014/01/31 13:29:57 (11 年 前)
- パス:
- BH13SPARQLBuilder
- ファイル:
-
- 18 追加
- 2 変更
凡例:
- 変更なし
- 追加
- 削除
-
BH13SPARQLBuilder/.classpath
r2 r42 17 17 </attributes> 18 18 </classpathentry> 19 <classpathentry kind="lib" path="lib2/agraph-4.5.jar"/> 19 20 <classpathentry kind="output" path="target/classes"/> 20 21 </classpath> -
BH13SPARQLBuilder/src/org/biohackathon/SPARQLBuilder/OWL/OWLQueryBuilderImpl.java
r36 r42 61 61 62 62 OWLQueryBuilder builder = new OWLQueryBuilderImpl(sparqlEndpoint); 63 64 /* 63 65 SClass[] clz = builder.getOWLClasses(graphURIs, keyword, false); 64 66 for (SClass cls : clz) { … … 69 71 System.out.println(cls); 70 72 } 71 73 */ 72 74 System.out.println("CLS"); 73 75 74 ClassLink[] cls = builder.getNextClass(null, clz[0].getClassURI(), 100, 75 false); 76 String uri = "http://purl.jp/bio/10/lsd/ontology/201209#EnglishEntry"; 77 78 ClassLink[] cls = builder.getNextClass(null, uri, 100, false); 79 76 80 if (cls != null) { 77 81 for (ClassLink cl : cls) { 78 82 System.out.println(cl.toString()); 79 83 } 80 cls = builder.countLinks(null, clz[0].getClassURI(), cls);84 cls = builder.countLinks(null, uri, cls); 81 85 for (ClassLink cl : cls) { 82 86 System.out.println(cl.toString()); 83 87 } 84 88 } 85 89 /* 86 90 System.out.println("CLS-INS"); 87 91 cls = builder.getNextClassViaInstanceLink(null, clz[0].getClassURI(), … … 100 104 } 101 105 } 102 106 */ 103 107 /* 104 108 * System.out.println("INS-INS"); ins = builder.getInstances(null, … … 112 116 } 113 117 118 119 120 114 121 /** 115 122 * 譏守、コ逧�↓RDF縺ァ譖ク縺九l縺ヲ縺�k繧ッ繝ゥ繧ケ繧貞叙蠕励☆繧� … … 146 153 queryStr.append("WHERE{\n"); 147 154 155 // 148 156 queryStr.append(" {?c rdf:type rdfs:Class} UNION {?c rdf:type owl:Class}\n"); 149 157 // queryStr.append(" ?i rdf:type ?c.\n"); … … 303 311 public ClassLink[] getNextClass(String[] graphURIs, String originClass, 304 312 int limit, boolean countLinks) throws Exception { 305 StringBuffer queryStr = new StringBuffer(); 313 ClassLink[] cLinks = getNextClassSub(graphURIs, originClass, limit, false); 314 if( countLinks ){ 315 cLinks = countLinks(graphURIs, originClass, cLinks); 316 } 317 return cLinks; 318 } 319 320 private ClassLink[] getNextClassSub(String[] graphURIs, String originClass, 321 int limit, boolean countLinks) throws Exception { 322 StringBuffer queryStr = new StringBuffer(); 306 323 queryStr.append("PREFIX owl: <http://www.w3.org/2002/07/owl#>\n"); 307 324 queryStr.append("PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"); … … 714 731 queryStr.append(classLink.getLinkedClassURI()); 715 732 queryStr.append(">.\n"); 716 queryStr.append("?is ?p ?os.\n"); 733 queryStr.append("?is <"); 734 queryStr.append(classLink.getPropertyURI()); 735 queryStr.append("> ?os.\n"); 717 736 queryStr.append("}"); 718 737 } else { … … 724 743 queryStr.append(classLink.getLinkedClassURI()); 725 744 queryStr.append(">.\n"); 726 queryStr.append("?is ?p ?os.\n"); 745 queryStr.append("?is <"); 746 queryStr.append(classLink.getPropertyURI()); 747 queryStr.append("> ?os.\n"); 727 748 queryStr.append("}"); 728 749 } else { … … 733 754 queryStr.append(classLink.getLinkedClassURI()); 734 755 queryStr.append(">.\n"); 735 queryStr.append("{?is ?p ?os.}\n"); 756 queryStr.append("{?is <"); 757 queryStr.append(classLink.getPropertyURI()); 758 queryStr.append("> ?os.}\n"); 736 759 queryStr.append("UNION\n"); 737 queryStr.append("{?os ?p ?is.}\n"); 760 queryStr.append("{?os <"); 761 queryStr.append(classLink.getPropertyURI()); 762 queryStr.append("> ?is.}\n"); 738 763 queryStr.append("}"); 739 764 }