@Test public void lengthTest2() { String[] testSentence = new String[] {"This", "is", "an", "example", "sentence"}; int testTokenIndex = 3; int suffixLength = 5; AdaptiveFeatureGenerator generator = new PrefixFeatureGenerator(suffixLength); generator.createFeatures(features, testSentence, testTokenIndex, null); Assert.assertEquals(5, features.size()); Assert.assertEquals("pre=e", features.get(0)); Assert.assertEquals("pre=ex", features.get(1)); Assert.assertEquals("pre=exa", features.get(2)); Assert.assertEquals("pre=exam", features.get(3)); Assert.assertEquals("pre=examp", features.get(4)); }
@Override public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) { String[] prefs = getPrefixes(tokens[index]); for (String pref : prefs) { features.add("pre=" + pref); } }
PrefixFeatureGenerator implements AdaptiveFeatureGenerator { @Override public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) { String[] prefs = getPrefixes(tokens[index]); for (String pref : prefs) { features.add("pre=" + pref); } } }
PrefixFeatureGenerator implements AdaptiveFeatureGenerator { @Override public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) { String[] prefs = getPrefixes(tokens[index]); for (String pref : prefs) { features.add("pre=" + pref); } } PrefixFeatureGenerator();  PrefixFeatureGenerator(int prefixLength); }
PrefixFeatureGenerator implements AdaptiveFeatureGenerator { @Override public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) { String[] prefs = getPrefixes(tokens[index]); for (String pref : prefs) { features.add("pre=" + pref); } } PrefixFeatureGenerator();  PrefixFeatureGenerator(int prefixLength); @Override void createFeatures(List<String> features, String[] tokens, int index,
      String[] previousOutcomes); }
PrefixFeatureGenerator implements AdaptiveFeatureGenerator { @Override public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) { String[] prefs = getPrefixes(tokens[index]); for (String pref : prefs) { features.add("pre=" + pref); } } PrefixFeatureGenerator();  PrefixFeatureGenerator(int prefixLength); @Override void createFeatures(List<String> features, String[] tokens, int index,
      String[] previousOutcomes);  }