File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
src/edu/stanford/nlp/international Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 5
5
6
6
import java .lang .reflect .InvocationTargetException ;
7
7
import java .util .Arrays ;
8
+ import java .util .HashMap ;
9
+ import java .util .Map ;
8
10
9
11
/**
10
12
* Constants and parameters for multilingual NLP (primarily, parsing).
@@ -78,6 +80,21 @@ public enum Language {
78
80
79
81
public static final String langList = StringUtils .join (Arrays .asList (Language .values ()), " " );
80
82
83
+ public static final Map <String , Language > lowerLangNames = new HashMap () {{
84
+ for (Language lang : Language .values ()) {
85
+ String lowerLang = lang .name ().toLowerCase ();
86
+ if (containsKey (lowerLang )) {
87
+ throw new AssertionError ("Duplicate Language names: " + lang .name () + " and " + lowerLangNames .get (lowerLang ).name ());
88
+ }
89
+ put (lowerLang , lang );
90
+ }
91
+ }};
92
+
93
+ /** return a case insensitive search with no exceptions (unknown language becomes null) */
94
+ public static Language valueOfSafe (String language ) {
95
+ return lowerLangNames .get (language .toLowerCase ());
96
+ }
97
+
81
98
public final TreebankLangParserParams params ;
82
99
83
100
Language (TreebankLangParserParams params ) {
You can’t perform that action at this time.
0 commit comments