SynonymSegmentDictionaryMemImpl extends FileBasedSegmentDictionary { @Override public List<? extends TypedSegment> lookup(String segment) { String label = map.get(segment.toLowerCase()); if (label == null) { return Collections.emptyList(); } SynonymSegment synonymSegment = new SynonymSegment(); synonymSegment.label = label; return Collections.singletonList(synonymSegment); }  @Override List<? extends TypedSegment> lookup(String segment);  }
@Test public void test_synonym() { assertEquals("New York", dict.lookup("new york").get(0).getLabel()); assertEquals("New York", dict.lookup("nyc").get(0).getLabel()); assertEquals("New York", dict.lookup("ny").get(0).getLabel()); assertEquals("Otis Gospodnetic", dict.lookup("otis gospodnetic").get(0).getLabel()); assertEquals("Otis Gospodnetic", dict.lookup("otisg").get(0).getLabel()); }
@Test public void test_single_value() { assertEquals("Boston", dict.lookup("boston").get(0).getLabel()); }