@Test public void testPrefixTermGenerator() throws Exception { JCas cas = JCasFactory.createJCas("de.julielab.jcore.types.jcore-all-types"); cas.setDocumentText("tra 1234567"); Annotation a = new Annotation(cas, 4, 5); assertEquals("1", TermGenerators.prefixTermGenerator(1).asStream(a).reduce(concatentor).get()); assertEquals("1", TermGenerators.prefixTermGenerator(3).asStream(a).reduce(concatentor).get()); a = new Annotation(cas, 4, 9); assertEquals("12345", TermGenerators.prefixTermGenerator(5).asStream(a).reduce(concatentor).get()); }
public static IndexTermGenerator<String> prefixTermGenerator(int maxLength) { return a -> { try { String documentText = a.getCAS().getJCas().getDocumentText(); return documentText.substring(a.getBegin(), a.getBegin() + Math.min(maxLength, a.getEnd() - a.getBegin())); } catch (CASException e) { e.printStackTrace(); } return Stream.empty(); }; }
TermGenerators { public static IndexTermGenerator<String> prefixTermGenerator(int maxLength) { return a -> { try { String documentText = a.getCAS().getJCas().getDocumentText(); return documentText.substring(a.getBegin(), a.getBegin() + Math.min(maxLength, a.getEnd() - a.getBegin())); } catch (CASException e) { e.printStackTrace(); } return Stream.empty(); }; } }
TermGenerators { public static IndexTermGenerator<String> prefixTermGenerator(int maxLength) { return a -> { try { String documentText = a.getCAS().getJCas().getDocumentText(); return documentText.substring(a.getBegin(), a.getBegin() + Math.min(maxLength, a.getEnd() - a.getBegin())); } catch (CASException e) { e.printStackTrace(); } return Stream.empty(); }; }  }
TermGenerators { public static IndexTermGenerator<String> prefixTermGenerator(int maxLength) { return a -> { try { String documentText = a.getCAS().getJCas().getDocumentText(); return documentText.substring(a.getBegin(), a.getBegin() + Math.min(maxLength, a.getEnd() - a.getBegin())); } catch (CASException e) { e.printStackTrace(); } return Stream.empty(); }; }  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> prefixTermGenerator(int maxLength) { return a -> { try { String documentText = a.getCAS().getJCas().getDocumentText(); return documentText.substring(a.getBegin(), a.getBegin() + Math.min(maxLength, a.getEnd() - a.getBegin())); } catch (CASException e) { e.printStackTrace(); } return Stream.empty(); }; }  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();  }