| 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[] data1 = buf.split("[\\s]+"); |
|---|
| 28 | String[] data2 = buf.split("\""); |
|---|
| 29 | labels.put(data1[0].substring(1,data1[0].length() - 1 ), data2[1]); |
|---|
| 30 | } |
|---|
| 31 | in.close(); |
|---|
| 32 | }catch(IOException e){ |
|---|
| 33 | System.err.println(e); |
|---|
| 34 | } |
|---|
| 35 | } |
|---|
| 36 | } |
|---|
| 37 | return labels; |
|---|
| 38 | } |
|---|
| 39 | } |
|---|