チェンジセット 280 : SPARQLBuilderWWW/src/java/org

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

新ランキング関数追加

ファイル:
1 変更

凡例:

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

    r263 r280  
    246246        this.sparqlEndpoint = sparqlEndpoint; 
    247247        visited = new HashSet<Integer>(); 
    248         edgeweight = new LinkedList<Map<Integer,Integer>>(); 
     248        //edgeweight = new LinkedList<Map<Integer,Integer>>(); 
    249249        nodeweight = new LinkedList<Integer>(); 
    250250        // setNodes for all classes 
     
    258258           addNode(classes[i].getClassURI()); 
    259259           nodeType.add("class"); 
    260            edgeweight.add(new HashMap<Integer,Integer>()); 
     260           //edgeweight.add(new HashMap<Integer,Integer>()); 
    261261           nodeweight.add(classes[i].getNumOfInstances()); 
    262262        } 
     
    282282                        } 
    283283                        addEdge(crr, nn, classLinks[j]); 
    284                         updateWeight(crr, nn, classLinks[j]); 
     284                        //updateWeight(crr, nn, classLinks[j]); 
    285285                    } 
    286286                }catch(Exception e){ 
     
    292292        } 
    293293        // cut visited 
     294        /* 
    294295        Iterator<Integer> nit = visited.iterator(); 
    295296        while(nit.hasNext()){ 
     
    302303            } 
    303304        } 
    304     }        
     305        */ 
     306    } 
    305307    
     308    /* 
    306309    private void updateWeight(Integer node1, Integer node2, ClassLink edge){ 
    307310        Map<Integer, Integer> weight = edgeweight.get(node1); 
     
    326329        } 
    327330    } 
     331    */ 
    328332     
    329333    public List<String> getReachableClasses(){ 
     
    339343        return clURIs; 
    340344    } 
     345     
     346    public double computePrOfPath(Path path){ 
     347        ListIterator<ClassLink> lit = path.getClassLinks().listIterator(); 
     348        ClassLink prev = lit.next(); 
     349        double prob = 1.0; 
     350        while( lit.hasNext() ){ 
     351            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()); 
     358                //classes[labelednodes.get(prev.getLinkedClassURI())].getNumOfInstances(); 
     359                System.out.println(prev.getPropertyURI()); 
     360            } 
     361            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()); 
     365                //classes[labelednodes.get(prev.getLinkedClassURI())].getNumOfInstances(); 
     366                System.out.println(prev.getPropertyURI()); 
     367            } 
     368            prob = prob * prob3 ; 
     369        } 
     370        return prob; 
     371    } 
     372 
    341373}