チェンジセット 201 : SPARQLBuilderWWW/src/java
- 更新日時:
- 2014/10/28 16:50:31 (10 年 前)
- パス:
- SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL
- ファイル:
-
- 5 変更
凡例:
- 変更なし
- 追加
- 削除
-
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/ClassLink.java
r171 r201 297 297 298 298 private String getLinkedClassLabel(SClass[] classes){ 299 return QueryPathGenerator.getClassLabel (linkedClassURI, classes);299 return QueryPathGenerator.getClassLabelfromList(linkedClassURI, classes); 300 300 } 301 301 -
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/LabeledMultiDigraph.java
r133 r201 21 21 String label; 22 22 Direction direction; 23 Integer ntriples; 24 25 public LabeledEdge(Integer node, String label, Direction direction, Integer ntriples){ 26 this.node = node; 27 this.label = label; 28 this.direction = direction; 29 this.ntriples = ntriples; 30 } 23 31 } 24 32 … … 30 38 31 39 public void addNode(String label){ 40 labelednodes.put(label, labels.size()); 32 41 labels.add(label); 33 42 adjlist.add(new LinkedList<LabeledEdge>()); 34 43 } 35 44 45 public void addEdge(Integer node1, Integer node2, String elabel, Direction direction, Integer ntriples){ 46 if ( labels.size() < node1 || labels.size() < node2 ){ 47 System.err.println("Error for Edge Addition: No Node for the Edge"); 48 return; 49 } 50 LabeledEdge edge = new LabeledEdge(node2, elabel, direction, ntriples); 51 adjlist.get(node1).add(edge); 52 } 36 53 } -
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java
r197 r201 53 53 limit = 1000; 54 54 prunecut = 100; 55 56 // constructing subgraph57 55 58 56 } … … 90 88 return patharray; 91 89 } 92 90 93 91 private List<List<ClassLink>> searchPaths(RDFSchemaAnalyzer rdfsa, boolean countLinks){ 94 92 List<List<ClassLink>> paths = new ArrayList<>(); … … 235 233 */ 236 234 237 private void setGraph(RDFSchemaAnalyzer rdfsa, boolean countLink){ 238 // BFS 239 240 241 //ClassLink[] classLinks = rdfsa.getNextClass(null, crrlp.classLink.getLinkedClassURI(), limit, countLinks); 235 public void setWholeGraph(RDFSchemaAnalyzer rdfsa){ 236 // setNodes 237 SClass[] classes = null; 238 try{ 239 classes = rdfsa.getOWLClasses(null, null, null, true); 240 }catch(Exception e){ 241 System.err.println(e); return; 242 } 243 for (int i = 0 ; i < classes.length; i++){ 244 addNode(classes[i].getClassURI()); 245 } 246 // setEdges 247 for (int i = 0 ; i < classes.length; i++){ 248 try{ 249 ClassLink[] classLinks = rdfsa.getNextClass(null, classes[i].getClassURI(), limit, true); 250 for (int j = 0 ; j < classLinks.length; j++){ 251 addEdge(i, labelednodes.get(classLinks[j].getLinkedClassURI()), 252 classLinks[j].getPropertyURI(), 253 classLinks[j].getDirection(), 254 classLinks[j].getNumOfLinkedInstances()); 255 } 256 }catch(Exception e){ 257 System.err.println(e); 258 } 259 } 242 260 } 243 244 261 } -
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/Path.java
r167 r201 74 74 String json_str=""; 75 75 json_str+="{\"startClassURI\":\""+ startClass+"\","; 76 json_str+="\"startClassLabel\":\""+QueryPathGenerator.getClassLabel (startClass, classes)+"\",";76 json_str+="\"startClassLabel\":\""+QueryPathGenerator.getClassLabelfromList(startClass, classes)+"\","; 77 77 if (classLinks != null && classLinks.size() != 0) { 78 78 json_str+="\"classLinks\":["; -
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/QueryPathGenerator.java
r197 r201 45 45 //SClass[] cl = qpg.getClasses(null); 46 46 47 /* 47 48 long start1 = System.currentTimeMillis(); 48 49 Path[] path1 = qpg1.getPaths(sc, ec, false); … … 60 61 System.out.println(path1.length); 61 62 System.out.println(path2.length); 63 */ 62 64 } 63 65 … … 119 121 } 120 122 121 public static String getClassLabel (String classURI, SClass[] classes){123 public static String getClassLabelfromList(String classURI, SClass[] classes){ 122 124 if ( classURI == null ){ 123 125 return ""; 124 126 } 127 SClass sclass = null; 125 128 for ( int i = 0 ; i < classes.length; i++ ){ 126 129 if ( classURI.equals(classes[i].getClassURI()) ){ 127 Label[] labels = classes[i].getLabels(); 128 for ( int j = 0 ; j < labels.length; j++ ){ 129 if ( labels[j].getLanguage() == null ){ 130 return labels[j].getLabel(); 131 }else if ( labels[j].getLanguage().equals("en") ){ 132 return labels[j].getLabel(); 133 } 134 } 135 break; 130 return getClassLabelfromClass(classes[i]); 136 131 } 137 132 } 138 String[] url = classURI.split("/"); 133 return ""; 134 } 135 136 public static String getClassLabelfromClass(SClass sclass){ 137 Label[] labels = sclass.getLabels(); 138 for ( int i = 0 ; i < labels.length; i++ ){ 139 if ( labels[i].getLanguage() == null ){ 140 return labels[i].getLabel(); 141 }else if ( labels[i].getLanguage().equals("en") ){ 142 return labels[i].getLabel(); 143 } 144 } 145 String[] url = sclass.getClassURI().split("/"); 139 146 String tmplabel = url[url.length-1]; 140 147 String[] tmplabel2 = tmplabel.split("#");