- 更新日時:
- 2015/09/14 11:06:16 (9 年 前)
- ファイル:
-
- 1 変更
凡例:
- 変更なし
- 追加
- 削除
-
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/QueryPathGenerator.java
r251 r254 20 20 private RDFSchemaAnalyzer analyzer = null; 21 21 private OWLClassGraph graph; 22 private boolean askcheck; 22 23 private Map<String, String> clabels; 23 24 24 25 private static final String CDIR = "cdata"; 25 26 private static final String ODIR = "owldata"; 27 28 /* 26 29 public static void main(String[] args){ 27 30 QueryPathGenerator qpg = new QueryPathGenerator(); … … 87 90 } 88 91 } 92 */ 89 93 90 94 public QueryPathGenerator(){ … … 98 102 99 103 public void setOWLClassGraph(String startClass){ 100 //graph = new OWLClassGraph(analyzer, sparqlEndpoint, startClass, askcheck); 101 graph = new OWLClassGraph(analyzer, sparqlEndpoint, startClass, true); 104 graph = new OWLClassGraph(analyzer, sparqlEndpoint, startClass); 102 105 } 103 106 … … 123 126 setOWLClassGraph(startClass); 124 127 } 125 graph.askcheck = askcheck;126 128 return graph.getPaths(startClass, endClass); 127 129 } … … 144 146 } 145 147 148 public String getClassLabel(String classURI){ 149 return clabels.get(classURI); 150 } 151 152 public void setClassLabels(SClass[] classes){ 153 clabels = new HashMap<String, String>(); 154 Map<String, String> extLabels = getClassLabelsFromExternal(); 155 156 for ( int i = 0 ; i < classes.length; i++ ){ 157 String classURI = classes[i].getClassURI(); 158 159 Label[] labels = classes[i].getLabels(); 160 String label = null; 161 for ( int j = 0 ; j < labels.length; j++ ){ 162 if ( labels[j].getLanguage() == null ){ 163 label = labels[j].getLabel(); 164 break; 165 }else if ( labels[j].getLanguage().equals("en") || labels[j].getLanguage().equals("") ){ 166 label = labels[j].getLabel(); 167 break; 168 } 169 } 170 if ( label == null ){ 171 label = extLabels.get(classURI); 172 } 173 if ( label == null ){ 174 String[] uris = classURI.split("/"); 175 String tmplabel = uris[uris.length-1]; 176 String[] tmplabel2 = tmplabel.split("#"); 177 label = tmplabel2[tmplabel2.length-1]; 178 } 179 clabels.put(classURI, label); 180 } 181 } 182 146 183 public static String getClassLabelfromList(String classURI, SClass[] classes){ 147 184 if ( classURI == null ){ … … 152 189 if ( classURI.equals(classes[i].getClassURI()) ){ 153 190 return getClassLabelfromClass(classes[i]); 154 } 191 } 155 192 } 156 193 return ""; … … 173 210 } 174 211 212 public Map<String, String> getClassLabelsFromExternal(){ 213 return OWLLabelReader.readLabels(ODIR); 214 } 215 175 216 public OWLClassGraph getOWLClassGraph(){ 176 217 /*if ( graph == null ){