@Test public void test() { List<String> features = new ArrayList<>(); String[] testSentence = new String[]{ "Every", "John", "has", "its", "day", "." }; AdaptiveFeatureGenerator generator = new InSpanGenerator("john", new SimpleSpecificPersonFinder("John")); generator.createFeatures(features, testSentence, 0, null); Assert.assertEquals(0, features.size()); features.clear(); generator.createFeatures(features, testSentence, 1, null); Assert.assertEquals(2, features.size()); Assert.assertEquals("john:w=dic", features.get(0)); Assert.assertEquals("john:w=dic=John", features.get(1)); }
public void createFeatures(List<String> features, String[] tokens, int index, String[] preds) { if (currentSentence != tokens) { currentSentence = tokens; currentNames = finder.find(tokens); } for (Span currentName : currentNames) { if (currentName.contains(index)) { features.add(prefix + ":w=dic"); features.add(prefix + ":w=dic=" + tokens[index]); break; } } }
InSpanGenerator implements AdaptiveFeatureGenerator { public void createFeatures(List<String> features, String[] tokens, int index, String[] preds) { if (currentSentence != tokens) { currentSentence = tokens; currentNames = finder.find(tokens); } for (Span currentName : currentNames) { if (currentName.contains(index)) { features.add(prefix + ":w=dic"); features.add(prefix + ":w=dic=" + tokens[index]); break; } } } }
InSpanGenerator implements AdaptiveFeatureGenerator { public void createFeatures(List<String> features, String[] tokens, int index, String[] preds) { if (currentSentence != tokens) { currentSentence = tokens; currentNames = finder.find(tokens); } for (Span currentName : currentNames) { if (currentName.contains(index)) { features.add(prefix + ":w=dic"); features.add(prefix + ":w=dic=" + tokens[index]); break; } } } InSpanGenerator(String prefix, TokenNameFinder finder); }
InSpanGenerator implements AdaptiveFeatureGenerator { public void createFeatures(List<String> features, String[] tokens, int index, String[] preds) { if (currentSentence != tokens) { currentSentence = tokens; currentNames = finder.find(tokens); } for (Span currentName : currentNames) { if (currentName.contains(index)) { features.add(prefix + ":w=dic"); features.add(prefix + ":w=dic=" + tokens[index]); break; } } } InSpanGenerator(String prefix, TokenNameFinder finder); void createFeatures(List<String> features, String[] tokens, int index,
      String[] preds); }
InSpanGenerator implements AdaptiveFeatureGenerator { public void createFeatures(List<String> features, String[] tokens, int index, String[] preds) { if (currentSentence != tokens) { currentSentence = tokens; currentNames = finder.find(tokens); } for (Span currentName : currentNames) { if (currentName.contains(index)) { features.add(prefix + ":w=dic"); features.add(prefix + ":w=dic=" + tokens[index]); break; } } } InSpanGenerator(String prefix, TokenNameFinder finder); void createFeatures(List<String> features, String[] tokens, int index,
      String[] preds);  }