差分発生行の前後
無視リスト:
更新日時:
2015/04/08 17:05:11 (9 年 前)
更新者:
atsuko
ログメッセージ:

コスト関数導入

ファイル:
1 変更

凡例:

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

    r250 r251  
    1717    int limit = 100; 
    1818    int th = 1; 
     19    double cth = 1.0; // 0.0(no path) - 1.0(all paths) 
     20     
    1921    List<String> nodeType; 
    2022    ArrayList<HashSet<Integer>> connectionTable; 
     
    2426    List<Map<Integer, Integer>> edgeweight; 
    2527    List<Integer> nodeweight; 
     28    Map<String, Boolean> checkedpaths; 
    2629     
    2730    public class LinkAndPath{ 
     
    5659    } 
    5760         
    58     public OWLClassGraph(RDFSchemaAnalyzer rdfsa){ // not used 
     61    public OWLClassGraph(RDFSchemaAnalyzer rdfsa){ // for experiment 
    5962        super(); 
    6063        nodeType = new LinkedList<String>(); 
     64        this.askcheck = false; 
     65        setClassGraph(rdfsa); 
    6166    } 
    6267     
     
    124129    private List<List<ClassLink>> searchPaths(String startClass, String endClass){ 
    125130        //int asked = 0; 
    126         Map<String,Boolean> checkedpaths = new HashMap<String, Boolean>(); 
     131        checkedpaths = new HashMap<String, Boolean>(); 
    127132        List<List<ClassLink>> paths = new ArrayList<>(); 
    128133        Integer snode = labelednodes.get(startClass); 
     
    163168                    nextpath.add(nextnode); 
    164169                    // tmp 
    165                     if ( i >= 1 ){ 
     170                    if ( i >= 1  && askcheck == true ){ 
    166171                        int wn = nodeweight.get(crrnode); 
    167172                        int in = edgeweight.get(crrpath.get(crrpath.size()-2)).get(crrnode); 
     
    182187                                } 
    183188                            }else{                       
    184                                 boolean chk = EndpointAccess.check3SimplePathwithJoin(nextnode, crrpath.get(crrpath.size()-1), 
     189                                boolean chk = EndpointAccess.check3SimplePath(nextnode, crrpath.get(crrpath.size()-1), 
    185190                                    crrpath.get(crrpath.size()-2), this, sparqlEndpoint); 
    186191                                checkedpaths.put(key1, chk); 
     
    235240                    addedpath.add(cl); 
    236241                    // check 
    237                     //if ( EndpointAccess.checkPath(startClass, addedpath, sparqlEndpoint) ){ 
     242                    if (checkPath(startClass, addedpath)){ 
    238243                        tmppaths.add(addedpath); 
    239                     //} 
     244                    } 
    240245                } 
    241246            } 
     
    246251    } 
    247252     
    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 ){ 
    272276                           addNode(classLinks[j].getLinkedLiteralDatatypeURI()); 
    273277                           n = nodeType.size(); 
    274278                           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    } 
    284288 
    285289    public void setPartClassGraph(RDFSchemaAnalyzer rdfsa, String sparqlEndpoint, String startClass){ 
     
    332336            visited.addAll(nodes); 
    333337        } 
    334         // cut visited  
     338        // cut visited          
    335339        Iterator<Integer> nit = visited.iterator(); 
    336340        while(nit.hasNext()){ 
     
    405409   } 
    406410    
     411   private boolean checkPath(String startClass, List<ClassLink> paths){ 
     412       // KOKO 
     413       return false; 
     414   } 
    407415   // old codes 
    408416   /*