チェンジセット 281 : SPARQLBuilderWWW
- 更新日時:
- 2016/05/27 10:57:22 (8 年 前)
- パス:
- SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL
- ファイル:
-
- 2 変更
凡例:
- 変更なし
- 追加
- 削除
-
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java
r280 r281 99 99 } 100 100 } 101 path.setMin(min); 101 102 // using length of path 102 103 //int rankwidth = (int) ( ( min * nsteps )/ crrpath.size() ); 103 path.setWidth(500000 - crrpath.size()*100000 - min); 104 //path.setWidth(500000 - crrpath.size()*100000 - min); 105 double prob = computePrOfPath(path); 106 path.setWidth(prob); 104 107 sortedpaths.add(path); 105 108 j++; … … 280 283 if ( !visited.contains(nn) ){ 281 284 nextnodes.add(nn); 285 //visited.add(nn); 282 286 } 283 287 addEdge(crr, nn, classLinks[j]); … … 305 309 */ 306 310 } 307 308 /* 309 private void updateWeight(Integer node1, Integer node2, ClassLink edge){ 310 Map<Integer, Integer> weight = edgeweight.get(node1); 311 Integer crr = weight.get(node2); 312 if (crr == null ){ 313 crr = edge.getNumOfLinkedClassInstances(); 314 weight.put(node2, crr); 315 } 316 if ( crr < edge.getNumOfLinkedClassInstances() ){ 317 crr = edge.getNumOfLinkedClassInstances(); 318 weight.put(node2, crr); 319 } 320 weight = edgeweight.get(node2); 321 crr = weight.get(node1); 322 if (crr == null ){ 323 crr = edge.getNumOfOriginClassInstances(); 324 weight.put(node1, crr); 325 } 326 if ( crr < edge.getNumOfOriginClassInstances() ){ 327 crr = edge.getNumOfOriginInstances(); 328 weight.put(node1, crr); 329 } 330 } 331 */ 332 311 333 312 public List<String> getReachableClasses(){ 334 313 List<String> clURIs = new LinkedList<String>(); … … 348 327 ClassLink prev = lit.next(); 349 328 double prob = 1.0; 329 boolean chk = true; 330 double c1, c2; 350 331 while( lit.hasNext() ){ 351 332 ClassLink crr = lit.next(); 352 double prob2 = 1.0 - 353 ((double) ( crr.getNumOfOriginClassInstances())/ 354 (double) ( nodeweight.get(labelednodes.get(prev.getLinkedClassURI())) )); 355 if ( prob2 > 1.0 ){ 356 System.out.println("Prob2 > 1"); 357 System.out.println(prev.getLinkedClassURI()); 333 c1 = (double) ( crr.getNumOfOriginClassInstances()) / 334 (double) ( nodeweight.get(labelednodes.get(prev.getLinkedClassURI()))); 335 c2 = (double) ( prev.getNumOfLinkedClassInstances()) / 336 (double) ( nodeweight.get(labelednodes.get(prev.getLinkedClassURI()))); 337 if ( c1 < 0.5 && c2 < 0.5 ){ chk = false;} 338 double prob2 = 1.0 - c1; 339 //((double) ( crr.getNumOfOriginClassInstances())/ 340 //(double) ( nodeweight.get(labelednodes.get(prev.getLinkedClassURI())) )); 341 //if ( prob2 > 1.0 || prob2 < 0 ){ 342 // System.out.println("Prob2 > 1 or Prob2 < 0"); 343 // System.out.println(prev.getLinkedClassURI()); 358 344 //classes[labelednodes.get(prev.getLinkedClassURI())].getNumOfInstances(); 359 System.out.println(prev.getPropertyURI());360 }345 // System.out.println(prev.getPropertyURI()); 346 //} 361 347 double prob3 = 1.0 - Math.pow(prob2, (double) prev.getNumOfLinkedClassInstances()); 362 if ( prob3 > 1.0 ){363 System.out.println("Prob3 > 1");364 System.out.println(prev.getLinkedClassURI());348 //if ( prob3 > 1.0 ){ 349 // System.out.println("Prob3 > 1"); 350 // System.out.println(prev.getLinkedClassURI()); 365 351 //classes[labelednodes.get(prev.getLinkedClassURI())].getNumOfInstances(); 366 System.out.println(prev.getPropertyURI());367 }352 // System.out.println(prev.getPropertyURI()); 353 //} 368 354 prob = prob * prob3 ; 369 } 355 prev = crr; 356 } 357 path.setChk(chk); 370 358 return prob; 371 359 } -
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/Path.java
r259 r281 20 20 */ 21 21 private String startClass; 22 private int width; 22 //private int width; 23 private float width; 24 private int min; 25 private boolean chk; 23 26 24 27 /** … … 111 114 } 112 115 json_str += ","; 113 json_str +="\"score\":\""+width+"\""; 116 //json_str +="\"score\":\""+width+"\""; 117 json_str +="\"score\":\""+""+"\""; 114 118 json_str +="}"; 115 119 … … 132 136 } 133 137 134 public int getWidth() {138 public float getWidth() { 135 139 return width; 136 140 } … … 157 161 } 158 162 163 public void setWidth(double width) { 164 this.width = (float) width; 165 } 166 167 public void setMin(int min){ 168 this.min = min; 169 } 170 171 public int getMin(){ 172 return min; 173 } 174 175 public void setChk(boolean chk){ 176 this.chk = chk; 177 } 178 179 public boolean getChk(){ 180 return chk; 181 } 182 159 183 @Override 160 184 public int compareTo(Path path) { 161 return this.width - path.getWidth() ; 185 if ( this.width - path.getWidth() > 0 ){ return 1; } 186 else if ( this.width - path.getWidth() < 0 ){ return -1; } 187 else { 188 if ( this.chk == true && path.getChk() == false ){ return 1; } 189 if ( this.chk == false && path.getChk() == true ){ return -1; } 190 else { 191 if ( path.classLinks.size() - this.classLinks.size() > 0 ){ return 1;} 192 else if ( path.classLinks.size() - this.classLinks.size() < 0 ){ return -1;} 193 else{ 194 if ( this.min - path.getMin() > 0 ){ return 1; } 195 else if ( this.min - path.getMin() < 0 ){ return -1;} 196 return 0; 197 } 198 } 199 } 200 //return this.width - path.getWidth() ; 162 201 //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 163 202 }