/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.biohackathon.SPARQLBuilder.OWL;

/**
 *
 * @author atsuko
 */

import java.util.*;
import java.io.*;

public class OWLLabelReader {
    static Map<String, String> readLabels(String dir){
        Map<String, String> labels = new HashMap<String, String> ();
        File fdir = new File(dir);
        if ( fdir.exists() ){
            File[] files = fdir.listFiles();
            for (int i = 0 ; i < files.length; i++ ){
                try{
                    BufferedReader in = new BufferedReader(new FileReader(files[i]));
                    String buf;
                    while( (buf = in.readLine()) != null){
                        String[] data = buf.split("[\\s]+");
                        if ( data[1].equals("<http://www.w3.org/2000/01/rdf-schema#label>") ){
                            String[] lit = data[2].split("\"");                            
                            labels.put(data[0].substring(1,data[0].length() -1 ), lit[1]);
                            //System.out.println(data[0].substring(1,data[0].length() -1 ));
                            //System.out.println(lit[1]);
                        }
                    }
                    in.close();
                }catch(IOException e){
                    System.err.println(e);
                }
            }
        }
        return labels;
    }
}
