チェンジセット 90 : BH13SPARQLBuilder/src/org/biohackathon
- 更新日時:
- 2014/07/01 14:19:29 (10 年 前)
- パス:
- BH13SPARQLBuilder/src/org/biohackathon/SPARQLBuilder/OWL
- ファイル:
-
- 3 変更
凡例:
- 変更なし
- 追加
- 削除
-
BH13SPARQLBuilder/src/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java
r82 r90 35 35 } 36 36 37 public LinkAndPath(ClassLink classLink, List<ClassLink> path, String ori nalClassURI, boolean converge){37 public LinkAndPath(ClassLink classLink, List<ClassLink> path, String originalClassURI, boolean converge){ 38 38 this.classLink = classLink; 39 39 this.path = path; … … 49 49 this.endClass = endClass; 50 50 addNode(endClass); 51 nsteps = 3;51 nsteps = 10; 52 52 limit = 1000; 53 th = 0;54 concut = 2.0;55 divcut = - 2.0;53 //th = 0; 54 //concut = 2.0; 55 //divcut = - 2.0; 56 56 } 57 57 … … 83 83 private List<List<ClassLink>> searchPaths(RDFSchemaAnalyzer rdfsa, boolean countLinks){ 84 84 List<List<ClassLink>> paths = new ArrayList<>(); 85 ClassLink crrLink = new ClassLink(null,startClass,Direction.both,0,0,0,0,0);86 85 List<LinkAndPath> lp = new LinkedList<>(); 87 lp.add(new LinkAndPath( crrLink, new LinkedList<ClassLink>()));86 lp.add(new LinkAndPath(new ClassLink("",startClass,Direction.both,0,0,0,0,0), new LinkedList<ClassLink>(), "", false)); 88 87 try{ 89 88 for ( int i = 0; i < nsteps; i++ ){ … … 92 91 while ( lit.hasNext() ){ 93 92 LinkAndPath crrlp = lit.next(); 94 ClassLink[] classLinks = null; 95 classLinks = rdfsa.getNextClass(null, crrlp.classLink.getLinkedClassURI(), limit, countLinks); 93 ClassLink[] classLinks = rdfsa.getNextClass(null, crrlp.classLink.getLinkedClassURI(), limit, countLinks); 96 94 for ( int j = 0 ; j < classLinks.length; j++ ){ 97 95 List<ClassLink> crrpath = new LinkedList<>(crrlp.path); … … 104 102 continue; 105 103 } 106 nextlp.add(new LinkAndPath(classLinks[j],crrpath)); 104 if ( crrlp.classLink.getPropertyURI().equals(classLinks[j].getPropertyURI()) && 105 crrlp.classLink.getDirection() != classLinks[j].getDirection() && 106 crrlp.originalClassURI.equals( classLinks[j].getLinkedClassURI()) ){ 107 continue; 108 } 109 110 nextlp.add(new LinkAndPath(classLinks[j], crrpath, crrlp.classLink.getLinkedClassURI(), false)); 107 111 } 108 112 } -
BH13SPARQLBuilder/src/org/biohackathon/SPARQLBuilder/OWL/QueryPathGenerator.java
r83 r90 11 11 * @author atsuko 12 12 */ 13 13 14 public class QueryPathGenerator { 14 private String sparqlEndpoint; 15 private RDFSchemaAnalyzer analyzer; 15 private String sparqlEndpoint = null; 16 private RDFSchemaAnalyzerFactory factory = null; 17 private RDFSchemaAnalyzer analyzer = null; 18 //private OWLClassGraph graph; 19 20 /* 21 public static void main(String[] args){ 22 // For Test 23 String sp = "http://data.allie.dbcls.jp/sparql"; 24 String sc = "http://purl.org/allie/ontology/201108#ShortForm"; 25 String ec = "http://purl.org/allie/ontology/201108#LongForm"; 26 QueryPathGenerator qpg = new QueryPathGenerator(sp); 27 Path[] path = qpg.getPaths(sc, ec, false); 28 System.out.println(path.length); 29 }*/ 16 30 17 public void setSPARQLendpoint(String sparqlEndpoint){18 this.sparqlEndpoint = sparqlEndpoint;31 public QueryPathGenerator(){ 32 factory = new RDFSchemaAnalyzerFactory(); 19 33 } 20 34 21 public SClass[] getClasses(){22 // KOKO23 return new SClass[10];35 public QueryPathGenerator(String sparqlEndpoint){ 36 factory = new RDFSchemaAnalyzerFactory(); 37 setSPARQLendpoint(sparqlEndpoint); 24 38 } 25 39 40 public SClass[] getClasses(String keyword){ 41 String[] keywords = null; 42 if ( keyword != null ){ // KOKO 43 keywords = new String[1]; 44 keywords[0] = keyword; 45 } 46 try { 47 return analyzer.getOWLClasses(null, keywords, sparqlEndpoint, false); 48 }catch(Exception e){ 49 System.err.println(e); 50 return null; 51 } 52 } 53 26 54 public Path[] getPaths(String startClass, String endClass, boolean countLink){ 27 // KOKO 28 return new Path[10]; 55 if ( analyzer == null ){ 56 System.err.println("ERROR. SPARQL endpoint is not decided."); 57 } 58 OWLClassGraph graph = new OWLClassGraph(startClass, endClass); 59 return graph.getPaths(analyzer, countLink); 29 60 } 30 61 62 private void setSPARQLendpoint(String sparqlEndpoint){ 63 this.sparqlEndpoint = sparqlEndpoint; 64 setAnalyzer(); 65 } 66 67 private void setAnalyzer(){ 68 //analyzer = new EndpointAnalyzer(sparqlEndpoint); //ForTest 69 try { 70 analyzer = factory.create(sparqlEndpoint); 71 } catch (Exception e) { 72 System.err.println(e); 73 } 74 } 31 75 } -
BH13SPARQLBuilder/src/org/biohackathon/SPARQLBuilder/OWL/RDFSchemaAnalyzerFactory.java
r87 r90 10 10 11 11 private Map<String, String> acquiredRDFFiles = null; 12 private static final String FILENAME = " tmpname";12 private static final String FILENAME = "./crawleddata/"; 13 13 14 14 public RDFSchemaAnalyzerFactory(){ … … 33 33 } 34 34 35 36 35 public RDFSchemaAnalyzer create(String uri) throws Exception{ 37 36 if( acquiredRDFFiles == null || !acquiredRDFFiles.containsKey(uri)){