| 1 | /* |
|---|
| 2 | * To change this license header, choose License Headers in Project Properties. |
|---|
| 3 | * To change this template file, choose Tools | Templates |
|---|
| 4 | * and open the template in the editor. |
|---|
| 5 | */ |
|---|
| 6 | package org.biohackathon.SPARQLBuilder.OWL; |
|---|
| 7 | |
|---|
| 8 | /** |
|---|
| 9 | * |
|---|
| 10 | * @author atsuko |
|---|
| 11 | */ |
|---|
| 12 | |
|---|
| 13 | import java.util.*; |
|---|
| 14 | import java.io.*; |
|---|
| 15 | |
|---|
| 16 | public class OWLLabelReader { |
|---|
| 17 | static Map<String, String> readLabels(String dir){ |
|---|
| 18 | Map<String, String> labels = new HashMap<String, String> (); |
|---|
| 19 | File fdir = new File(dir); |
|---|
| 20 | if ( fdir.exists() ){ |
|---|
| 21 | File[] files = fdir.listFiles(); |
|---|
| 22 | for (int i = 0 ; i < files.length; i++ ){ |
|---|
| 23 | try{ |
|---|
| 24 | BufferedReader in = new BufferedReader(new FileReader(files[i])); |
|---|
| 25 | String buf; |
|---|
| 26 | while( (buf = in.readLine()) != null){ |
|---|
| 27 | String[] data = buf.split("[\\s]+"); |
|---|
| 28 | if ( data[1].equals("<http://www.w3.org/2000/01/rdf-schema#label>") ){ |
|---|
| 29 | String[] lit = data[2].split("\""); |
|---|
| 30 | labels.put(data[0].substring(1,data[0].length() -1 ), lit[1]); |
|---|
| 31 | //System.out.println(data[0].substring(1,data[0].length() -1 )); |
|---|
| 32 | //System.out.println(lit[1]); |
|---|
| 33 | } |
|---|
| 34 | } |
|---|
| 35 | in.close(); |
|---|
| 36 | }catch(IOException e){ |
|---|
| 37 | System.err.println(e); |
|---|
| 38 | } |
|---|
| 39 | } |
|---|
| 40 | } |
|---|
| 41 | return labels; |
|---|
| 42 | } |
|---|
| 43 | } |
|---|