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 55
66import java .lang .reflect .InvocationTargetException ;
77import java .util .Arrays ;
8+ import java .util .HashMap ;
9+ import java .util .Map ;
810
911/**
1012 * Constants and parameters for multilingual NLP (primarily, parsing).
@@ -78,6 +80,21 @@ public enum Language {
7880
7981 public static final String langList = StringUtils .join (Arrays .asList (Language .values ()), " " );
8082
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+
8198 public final TreebankLangParserParams params ;
8299
83100 Language (TreebankLangParserParams params ) {
You can’t perform that action at this time.
0 commit comments