- 更新日時:
- 2015/04/08 17:05:11 (10 年 前)
- ファイル:
-
- 1 変更
凡例:
- 変更なし
- 追加
- 削除
-
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java
r250 r251 17 17 int limit = 100; 18 18 int th = 1; 19 double cth = 1.0; // 0.0(no path) - 1.0(all paths) 20 19 21 List<String> nodeType; 20 22 ArrayList<HashSet<Integer>> connectionTable; … … 24 26 List<Map<Integer, Integer>> edgeweight; 25 27 List<Integer> nodeweight; 28 Map<String, Boolean> checkedpaths; 26 29 27 30 public class LinkAndPath{ … … 56 59 } 57 60 58 public OWLClassGraph(RDFSchemaAnalyzer rdfsa){ // not used61 public OWLClassGraph(RDFSchemaAnalyzer rdfsa){ // for experiment 59 62 super(); 60 63 nodeType = new LinkedList<String>(); 64 this.askcheck = false; 65 setClassGraph(rdfsa); 61 66 } 62 67 … … 124 129 private List<List<ClassLink>> searchPaths(String startClass, String endClass){ 125 130 //int asked = 0; 126 Map<String,Boolean>checkedpaths = new HashMap<String, Boolean>();131 checkedpaths = new HashMap<String, Boolean>(); 127 132 List<List<ClassLink>> paths = new ArrayList<>(); 128 133 Integer snode = labelednodes.get(startClass); … … 163 168 nextpath.add(nextnode); 164 169 // tmp 165 if ( i >= 1 ){170 if ( i >= 1 && askcheck == true ){ 166 171 int wn = nodeweight.get(crrnode); 167 172 int in = edgeweight.get(crrpath.get(crrpath.size()-2)).get(crrnode); … … 182 187 } 183 188 }else{ 184 boolean chk = EndpointAccess.check3SimplePath withJoin(nextnode, crrpath.get(crrpath.size()-1),189 boolean chk = EndpointAccess.check3SimplePath(nextnode, crrpath.get(crrpath.size()-1), 185 190 crrpath.get(crrpath.size()-2), this, sparqlEndpoint); 186 191 checkedpaths.put(key1, chk); … … 235 240 addedpath.add(cl); 236 241 // check 237 //if ( EndpointAccess.checkPath(startClass, addedpath, sparqlEndpoint)){242 if (checkPath(startClass, addedpath)){ 238 243 tmppaths.add(addedpath); 239 //}244 } 240 245 } 241 246 } … … 246 251 } 247 252 248 /* 249 private void setClassGraph(RDFSchemaAnalyzer rdfsa){ 250 // setNodes 251 SClass[] classes = null; 252 try{ 253 classes = rdfsa.getOWLClasses(null, null, null, true); 254 }catch(Exception e){ 255 System.err.println(e); return; 256 } 257 for (int i = 0 ; i < classes.length; i++){ 258 addNode(classes[i].getClassURI()); 259 nodeType.add("class"); 260 } 261 // setEdges 262 for (int i = 0 ; i < classes.length; i++ ){ 263 try{ 264 ClassLink[] classLinks = rdfsa.getNextClass(null, classes[i].getClassURI(), limit, true); 265 for (int j = 0 ; j < classLinks.length; j++){ 266 Integer n = labelednodes.get(classLinks[j].getLinkedClassURI()); 267 if ( n != null ){ 268 addEdge(i, n, classLinks[j]); 269 }else{ 270 n = labelednodes.get(classLinks[j].getLinkedLiteralDatatypeURI()); 271 if ( n == null ){ 253 private void setClassGraph(RDFSchemaAnalyzer rdfsa){ 254 // setNodes 255 SClass[] classes = null; 256 try{ 257 classes = rdfsa.getOWLClasses(null, null, null, true); 258 }catch(Exception e){ 259 System.err.println(e); return; 260 } 261 for (int i = 0 ; i < classes.length; i++){ 262 addNode(classes[i].getClassURI()); 263 nodeType.add("class"); 264 } 265 // setEdges 266 for (int i = 0 ; i < classes.length; i++ ){ 267 try{ 268 ClassLink[] classLinks = rdfsa.getNextClass(null, classes[i].getClassURI(), limit, true); 269 for (int j = 0 ; j < classLinks.length; j++){ 270 Integer n = labelednodes.get(classLinks[j].getLinkedClassURI()); 271 if ( n != null ){ 272 addEdge(i, n, classLinks[j]); 273 }else{ 274 n = labelednodes.get(classLinks[j].getLinkedLiteralDatatypeURI()); 275 if ( n == null ){ 272 276 addNode(classLinks[j].getLinkedLiteralDatatypeURI()); 273 277 n = nodeType.size(); 274 278 nodeType.add("literal"); 275 }276 addEdge(i, n, classLinks[j]);277 }278 }279 }catch(Exception e){280 System.err.println(e);281 }282 }283 }*/279 } 280 addEdge(i, n, classLinks[j]); 281 } 282 } 283 }catch(Exception e){ 284 System.err.println(e); 285 } 286 } 287 } 284 288 285 289 public void setPartClassGraph(RDFSchemaAnalyzer rdfsa, String sparqlEndpoint, String startClass){ … … 332 336 visited.addAll(nodes); 333 337 } 334 // cut visited 338 // cut visited 335 339 Iterator<Integer> nit = visited.iterator(); 336 340 while(nit.hasNext()){ … … 405 409 } 406 410 411 private boolean checkPath(String startClass, List<ClassLink> paths){ 412 // KOKO 413 return false; 414 } 407 415 // old codes 408 416 /*