差分発生行の前後
無視リスト:
更新日時:
2016/05/27 10:57:22 (8 年 前)
更新者:
atsuko
ログメッセージ:

新ランキング関数でソート機能追加

パス:
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL
ファイル:
2 変更

凡例:

変更なし
追加
削除
  • SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java

    r280 r281  
    9999                } 
    100100            } 
     101            path.setMin(min); 
    101102            // using length of path 
    102103            //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); 
    104107            sortedpaths.add(path); 
    105108            j++; 
     
    280283                        if ( !visited.contains(nn) ){ 
    281284                            nextnodes.add(nn); 
     285                            //visited.add(nn); 
    282286                        } 
    283287                        addEdge(crr, nn, classLinks[j]); 
     
    305309        */ 
    306310    } 
    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        
    333312    public List<String> getReachableClasses(){ 
    334313        List<String> clURIs = new LinkedList<String>(); 
     
    348327        ClassLink prev = lit.next(); 
    349328        double prob = 1.0; 
     329        boolean chk = true; 
     330        double c1, c2;  
    350331        while( lit.hasNext() ){ 
    351332            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()); 
    358344                //classes[labelednodes.get(prev.getLinkedClassURI())].getNumOfInstances(); 
    359                 System.out.println(prev.getPropertyURI()); 
    360             } 
     345            //    System.out.println(prev.getPropertyURI()); 
     346            //} 
    361347            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()); 
    365351                //classes[labelednodes.get(prev.getLinkedClassURI())].getNumOfInstances(); 
    366                 System.out.println(prev.getPropertyURI()); 
    367             } 
     352            //    System.out.println(prev.getPropertyURI()); 
     353            //} 
    368354            prob = prob * prob3 ; 
    369         } 
     355            prev = crr; 
     356        } 
     357        path.setChk(chk); 
    370358        return prob; 
    371359    } 
  • SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/Path.java

    r259 r281  
    2020         */ 
    2121        private String startClass; 
    22         private int width; 
     22        //private int width; 
     23        private float width; 
     24        private int min; 
     25        private boolean chk; 
    2326 
    2427        /** 
     
    111114                } 
    112115                json_str += ","; 
    113                 json_str +="\"score\":\""+width+"\""; 
     116                //json_str +="\"score\":\""+width+"\""; 
     117                json_str +="\"score\":\""+""+"\""; 
    114118                json_str +="}"; 
    115119                 
     
    132136        } 
    133137 
    134         public int getWidth() { 
     138        public float getWidth() { 
    135139                return width; 
    136140        } 
     
    157161        } 
    158162 
     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                 
    159183    @Override 
    160184    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() ; 
    162201        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
    163202    }