1 |
40723
|
giorgos.al
|
package eu.dnetlib.data.mapreduce.hbase.lodImport.utils;
|
2 |
|
|
import java.io.BufferedReader;
|
3 |
|
|
import java.io.IOException;
|
4 |
41002
|
giorgos.al
|
import java.io.InputStream;
|
5 |
|
|
import java.io.InputStreamReader;
|
6 |
40723
|
giorgos.al
|
|
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 |
41007
|
giorgos.al
|
public MapLanguages(){
|
26 |
41002
|
giorgos.al
|
|
27 |
41007
|
giorgos.al
|
}
|
28 |
|
|
|
29 |
|
|
// @SuppressWarnings("resource")
|
30 |
41019
|
giorgos.al
|
public String getLangURI(String iso639_3_Code) throws IOException{
|
31 |
41007
|
giorgos.al
|
|
32 |
41002
|
giorgos.al
|
// File inputFile = new File(MapCountries.class.getClassLoader().getResource("rdfData/lexvo-iso639-3.tsv").getFile());
|
33 |
|
|
// InputStream is = new FileInputStream(path);
|
34 |
41008
|
eri.katsar
|
//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 |
41002
|
giorgos.al
|
// File inputFile = new File(path);
|
38 |
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
39 |
40723
|
giorgos.al
|
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 |
|
|
}
|