TextValueEncoder extends FeatureVectorEncoder { @Override public String asString(String originalForm) { StringBuilder r = new StringBuilder(); r.append('['); for (String word : tokenize(originalForm)) { if (r.length() > 1) { r.append(", "); } r.append(wordEncoder.asString(word)); } r.append(']'); return r.toString(); } TextValueEncoder(String name); @Override void addToVector(byte[] originalForm, double weight, Vector data); void addText(byte[] originalForm); void addText(CharSequence text); void flush(double weight, Vector data); @Override String asString(String originalForm); final void setWordEncoder(FeatureVectorEncoder wordEncoder);  }
@Test public void testAsString() { Locale.setDefault(Locale.ENGLISH); FeatureVectorEncoder enc = new TextValueEncoder("text"); assertEquals("[text:test1:1.0000, text:and:1.0000, text:more:1.0000]", enc.asString("test1 and more")); }