@Test public void testMiddle() { final int testTokenIndex = 2; AdaptiveFeatureGenerator generator = new BigramNameFeatureGenerator(); generator.createFeatures(features, testSentence, testTokenIndex, null); Assert.assertEquals(4, features.size()); Assert.assertEquals("pw,w=is,an", features.get(0)); Assert.assertEquals("pwc,wc=lc,lc", features.get(1)); Assert.assertEquals("w,nw=an,example", features.get(2)); Assert.assertEquals("wc,nc=lc,lc", features.get(3)); }
public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) { String wc = FeatureGeneratorUtil.tokenFeature(tokens[index]); if (index > 0) { features.add("pw,w=" + tokens[index - 1] + "," + tokens[index]); String pwc = FeatureGeneratorUtil.tokenFeature(tokens[index - 1]); features.add("pwc,wc=" + pwc + "," + wc); } if (index + 1 < tokens.length) { features.add("w,nw=" + tokens[index] + "," + tokens[index + 1]); String nwc = FeatureGeneratorUtil.tokenFeature(tokens[index + 1]); features.add("wc,nc=" + wc + "," + nwc); } }
BigramNameFeatureGenerator implements AdaptiveFeatureGenerator { public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) { String wc = FeatureGeneratorUtil.tokenFeature(tokens[index]); if (index > 0) { features.add("pw,w=" + tokens[index - 1] + "," + tokens[index]); String pwc = FeatureGeneratorUtil.tokenFeature(tokens[index - 1]); features.add("pwc,wc=" + pwc + "," + wc); } if (index + 1 < tokens.length) { features.add("w,nw=" + tokens[index] + "," + tokens[index + 1]); String nwc = FeatureGeneratorUtil.tokenFeature(tokens[index + 1]); features.add("wc,nc=" + wc + "," + nwc); } } }
BigramNameFeatureGenerator implements AdaptiveFeatureGenerator { public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) { String wc = FeatureGeneratorUtil.tokenFeature(tokens[index]); if (index > 0) { features.add("pw,w=" + tokens[index - 1] + "," + tokens[index]); String pwc = FeatureGeneratorUtil.tokenFeature(tokens[index - 1]); features.add("pwc,wc=" + pwc + "," + wc); } if (index + 1 < tokens.length) { features.add("w,nw=" + tokens[index] + "," + tokens[index + 1]); String nwc = FeatureGeneratorUtil.tokenFeature(tokens[index + 1]); features.add("wc,nc=" + wc + "," + nwc); } }  }
BigramNameFeatureGenerator implements AdaptiveFeatureGenerator { public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) { String wc = FeatureGeneratorUtil.tokenFeature(tokens[index]); if (index > 0) { features.add("pw,w=" + tokens[index - 1] + "," + tokens[index]); String pwc = FeatureGeneratorUtil.tokenFeature(tokens[index - 1]); features.add("pwc,wc=" + pwc + "," + wc); } if (index + 1 < tokens.length) { features.add("w,nw=" + tokens[index] + "," + tokens[index + 1]); String nwc = FeatureGeneratorUtil.tokenFeature(tokens[index + 1]); features.add("wc,nc=" + wc + "," + nwc); } }  void createFeatures(List<String> features, String[] tokens, int index,
                             String[] previousOutcomes); }
BigramNameFeatureGenerator implements AdaptiveFeatureGenerator { public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) { String wc = FeatureGeneratorUtil.tokenFeature(tokens[index]); if (index > 0) { features.add("pw,w=" + tokens[index - 1] + "," + tokens[index]); String pwc = FeatureGeneratorUtil.tokenFeature(tokens[index - 1]); features.add("pwc,wc=" + pwc + "," + wc); } if (index + 1 < tokens.length) { features.add("w,nw=" + tokens[index] + "," + tokens[index + 1]); String nwc = FeatureGeneratorUtil.tokenFeature(tokens[index + 1]); features.add("wc,nc=" + wc + "," + nwc); } }  void createFeatures(List<String> features, String[] tokens, int index,
                             String[] previousOutcomes);  }