Project

General

Profile

1
package eu.dnetlib.data.mapreduce.hbase.lodImport.utils;
2
import java.io.BufferedReader;
3
import java.io.IOException;
4
import java.io.InputStream;
5
import java.io.InputStreamReader;
6

    
7
/**
8
 * Method: getLangURI
9
 * 
10
 * @author Giorgos Alexiou
11
 *
12
 */
13

    
14
public class MapLanguages {
15
	
16
/**
17
 * This Method takes ISO iso639_3 codes for languages as input and returns the respective URI from lexvo.org as output.
18
 * For example iso639_3 for Greek is "ell" and the respective URI from lexvo is <http://lexvo.org/id/iso639-3/ell>
19
 * 
20
 * @param iso639_3_Code
21
 * @return
22
 * @throws IOException
23
 */
24
	
25
	public MapLanguages(){
26
		
27
	}
28
	
29
//	@SuppressWarnings("resource")
30
	public String getLangURI(String iso639_3_Code) throws IOException{
31
		
32
//		File inputFile = new File(MapCountries.class.getClassLoader().getResource("rdfData/lexvo-iso639-3.tsv").getFile());
33
//		InputStream is = new FileInputStream(path);
34
		//InputStream is = this.getClass().getResourceAsStream("lodImport/lexvo-iso639-3.tsv");
35
        InputStream is =  ClassLoader.getSystemResourceAsStream("eu/dnetlib/data/mapreduce/hbase/lodImport/lexvo-iso639-3.tsv");
36

    
37
//		File inputFile = new File(path);
38
		BufferedReader reader = new BufferedReader(new InputStreamReader(is));
39
		String currentLine;
40
		while((currentLine = reader.readLine()) != null) {
41
			String[] line = currentLine.split("\t");
42
//			System.out.println(line[0].trim()+"--------------"+line[1].trim());
43

    
44
			if(line[0].toString().trim().equals(iso639_3_Code)){
45
				return line[1].toString().trim();
46
			}
47
			
48
		}
49
		reader.close();
50
		return "";
51
	}
52
	
53
	
54
	
55
//	public static void main(String[] args) throws IOException{
56
//		
57
//		System.out.println(MapLanguages.getLangURI("ell"));
58
//		
59
//		}
60
		
61
		
62
	}
63
	
(3-3/4)