-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathLanguageMapper.java
More file actions
32 lines (22 loc) · 816 Bytes
/
LanguageMapper.java
File metadata and controls
32 lines (22 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package OpenNLP.languagedetector;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
public class LanguageMapper {
public String getLanguage(String langCode) throws IOException {
HashMap<String, String> langMap = readToHashmap();
return langMap.get(langCode);
}
public HashMap<String, String> readToHashmap() throws IOException {
HashMap<String, String> map = new HashMap<String, String>();
BufferedReader in = new BufferedReader(new FileReader("resources/language_mapping.txt"));
String line = "";
while ((line = in.readLine()) != null) {
String parts[] = line.split("\t");
map.put(parts[0], parts[1]);
}
in.close();
return map;
}
}