/** * Converts a value into a form that would help a human understand the internals of how the value * is being interpreted. For text-like things, this is likely to be a list of the terms found with * associated weights (if any). * * @param originalForm The original form of the value as a string. * @return A string that a human can read. */ @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(); }
/** * Converts a value into a form that would help a human understand the internals of how the value * is being interpreted. For text-like things, this is likely to be a list of the terms found with * associated weights (if any). * * @param originalForm The original form of the value as a string. * @return A string that a human can read. */ @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(); }
/** * Converts a value into a form that would help a human understand the internals of how the value * is being interpreted. For text-like things, this is likely to be a list of the terms found with * associated weights (if any). * * @param originalForm The original form of the value as a string. * @return A string that a human can read. */ @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(); }
@Test public void testAsString() { Locale.setDefault(Locale.ENGLISH); FeatureVectorEncoder enc = new StaticWordValueEncoder("word"); assertEquals("word:w1:1.0000", enc.asString("w1")); }
@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")); }
@Test public void testAsString() { FeatureVectorEncoder enc = new ContinuousValueEncoder("foo"); assertEquals("foo:123", enc.asString("123")); }
@Test public void testAsString() { FeatureVectorEncoder enc = new ConstantValueEncoder("foo"); assertEquals("foo", enc.asString("123")); }