@Test public void testEdgeNGramTermGenerator() throws Exception { JCas cas = JCasFactory.createJCas("de.julielab.jcore.types.jcore-all-types"); cas.setDocumentText("tra 1234567"); Annotation a = new Annotation(cas, 4, 9); IndexTermGenerator<String> unigramGenerator = TermGenerators.edgeNGramTermGenerator(5); assertEquals("1 12 123 1234 12345", unigramGenerator.asStream(a).reduce(concatentor).get()); }
public static IndexTermGenerator<String> edgeNGramTermGenerator(int n) { return a -> { String text = a.getCoveredText(); return IntStream.range(0, n).mapToObj(i -> { if (i < text.length()) return text.substring(0, i + 1); return null; }).filter(s -> s != null); }; }
TermGenerators { public static IndexTermGenerator<String> edgeNGramTermGenerator(int n) { return a -> { String text = a.getCoveredText(); return IntStream.range(0, n).mapToObj(i -> { if (i < text.length()) return text.substring(0, i + 1); return null; }).filter(s -> s != null); }; } }
TermGenerators { public static IndexTermGenerator<String> edgeNGramTermGenerator(int n) { return a -> { String text = a.getCoveredText(); return IntStream.range(0, n).mapToObj(i -> { if (i < text.length()) return text.substring(0, i + 1); return null; }).filter(s -> s != null); }; }  }
TermGenerators { public static IndexTermGenerator<String> edgeNGramTermGenerator(int n) { return a -> { String text = a.getCoveredText(); return IntStream.range(0, n).mapToObj(i -> { if (i < text.length()) return text.substring(0, i + 1); return null; }).filter(s -> s != null); }; }  static IndexTermGenerator<String> nGramTermGenerator(int n); static IndexTermGenerator<String> edgeNGramTermGenerator(int n); static IndexTermGenerator<String> prefixTermGenerator(int maxLength); static IndexTermGenerator<String> suffixTermGenerator(int maxLength); static IndexTermGenerator<String> exactPrefixTermGenerator(int length); static IndexTermGenerator<String> exactSuffixTermGenerator(int length); static LongOffsetIndexTermGenerator longOffsetTermGenerator(); }
TermGenerators { public static IndexTermGenerator<String> edgeNGramTermGenerator(int n) { return a -> { String text = a.getCoveredText(); return IntStream.range(0, n).mapToObj(i -> { if (i < text.length()) return text.substring(0, i + 1); return null; }).filter(s -> s != null); }; }  static IndexTermGenerator<String> nGramTermGenerator(int n); static IndexTermGenerator<String> edgeNGramTermGenerator(int n); static IndexTermGenerator<String> prefixTermGenerator(int maxLength); static IndexTermGenerator<String> suffixTermGenerator(int maxLength); static IndexTermGenerator<String> exactPrefixTermGenerator(int length); static IndexTermGenerator<String> exactSuffixTermGenerator(int length); static LongOffsetIndexTermGenerator longOffsetTermGenerator();  }