CmuDictionaryReader { static Map<String, PhoneType> readPhones(InputStream is) throws IOException { Map<String, PhoneType> phones = new HashMap<>(); BufferedReader bufferedReader = null; try { bufferedReader = new BufferedReader(new InputStreamReader(is)); for (String line = bufferedReader.readLine(); line != null; line = bufferedReader.readLine()) { String[] tokens = line.split("\t"); String symbol = tokens[0]; PhoneType phoneType = PhoneType.valueOf(tokens[1].toUpperCase(Locale.US)); phones.put(symbol, phoneType); } } finally { if (bufferedReader != null) bufferedReader.close(); } return phones; } private  CmuDictionaryReader();   }
@Test public void testLoadPhones() throws IOException { Map<String, PhoneType> phones = readPhones(); Assert.assertNotNull(phones); Assert.assertEquals(39, phones.size()); PhoneType phoneType = phones.get("IY"); Assert.assertEquals(PhoneType.VOWEL, phoneType); phoneType = phones.get("G"); Assert.assertEquals(PhoneType.STOP, phoneType); }