チェンジセット 5 : BH13SPARQLBuilder
- 更新日時:
- 2014/01/30 10:50:28 (11 年 前)
- パス:
- BH13SPARQLBuilder
- ファイル:
-
- 2 変更
凡例:
- 変更なし
- 追加
- 削除
-
BH13SPARQLBuilder/pom.xml
r2 r5 19 19 <dependencies> 20 20 <dependency> 21 <groupId> com.hp.hpl.jena</groupId>22 <artifactId>jena </artifactId>23 <version>2. 6.4</version>21 <groupId>org.apache.jena</groupId> 22 <artifactId>jena-arq</artifactId> 23 <version>2.11.0</version> 24 24 </dependency> 25 25 <dependency> 26 <groupId> com.hp.hpl.jena</groupId>27 <artifactId> arq</artifactId>28 <version>2. 8.8</version>26 <groupId>org.apache.jena</groupId> 27 <artifactId>jena-core</artifactId> 28 <version>2.11.0</version> 29 29 </dependency> 30 30 <dependency> 31 <groupId>org.apache.httpcomponents</groupId> 32 <artifactId>httpcore</artifactId> 33 <version>4.3</version> 34 </dependency> 35 <dependency> 36 <groupId>org.apache.httpcomponents</groupId> 37 <artifactId>httpclient</artifactId> 38 <version>4.3.1</version> 31 <groupId>org.apache.jena</groupId> 32 <artifactId>jena</artifactId> 33 <version>2.11.0</version> 34 <type>pom</type> 39 35 </dependency> 40 36 </dependencies> -
BH13SPARQLBuilder/src/org/biohackathon/SPARQLBuilder/OWL/OWLQueryBuilderImpl.java
r2 r5 15 15 import org.apache.http.client.entity.UrlEncodedFormEntity; 16 16 import org.apache.http.client.methods.HttpPost; 17 import org.apache.http.impl.client.HttpClientBuilder;17 //import org.apache.http.impl.client.HttpClientBuilder; 18 18 import org.apache.http.message.BasicNameValuePair; 19 19 import org.apache.http.util.EntityUtils; … … 26 26 import com.hp.hpl.jena.query.ResultSet; 27 27 import com.hp.hpl.jena.rdf.model.Resource; 28 28 29 /** 29 30 * 繧ッ繧ィ繝ェ繧堤函謌舌☆繧九◆繧√�讖溯�繧呈署萓帙☆繧区ク繧ッ繝ゥ繧ケ … … 269 270 queryStr.append("PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"); 270 271 queryStr.append("PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"); 271 queryStr.append("SELECT DISTINCT ?p ?pDirection ?c \n");272 queryStr.append("SELECT DISTINCT ?p ?pDirection ?c (COUNT(?s) AS ?numOfLinks) \n"); 272 273 if (graphURIs != null) { 273 274 for (String graphURI : graphURIs) { … … 281 282 queryStr.append(" { ?p rdfs:domain <"); 282 283 queryStr.append(originClass); 283 queryStr.append(">.\n ?p rdfs:range ?c. }\n UNION\n");284 queryStr.append(">.\n ?p rdfs:range ?c.\n ?o ?p ?s.}\n UNION\n"); 284 285 queryStr.append(" { ?p rdfs:range <"); 285 286 queryStr.append(originClass); 286 queryStr.append(">.\n ?p rdfs:domain ?c.}\n"); 287 queryStr.append(" ?p ?pDirection ?c.\n"); 288 queryStr.append("}\n"); 287 queryStr.append(">.\n"); 288 queryStr.append(" ?p rdfs:domain ?c.\n"); 289 queryStr.append(" ?s ?p ?o.}\n"); 290 291 queryStr.append(" ?p ?pDirection ?c.\n"); 292 293 294 queryStr.append(" ?s rdf:type ?c.\n"); 295 queryStr.append(" ?o rdf:type <"); 296 queryStr.append(originClass); 297 queryStr.append(">.\n"); 298 queryStr.append("}\nGROUP BY ?p ?pDirection ?c\n"); 289 299 if (limit > 0) { 290 300 queryStr.append("limit "); … … 293 303 } 294 304 295 //System.out.println(queryStr.toString());305 System.out.println(queryStr.toString()); 296 306 297 307 Query query = QueryFactory.create(queryStr.toString()); … … 325 335 } 326 336 // System.out.println(direction); 327 ClassLink cl = new ClassLink(proURI, clsURI, direction, 0); 337 int numOfLinks = sol.getLiteral("numOfLinks").getInt(); 338 // System.out.println(numOfLinks); 339 ClassLink cl = new ClassLink(proURI, clsURI, direction, numOfLinks); 328 340 solCLs.add(cl); 329 341 }