public static <T extends CoreMap> List<T> splitCoreMap(Pattern p, boolean includeMatched, CoreMap cm, CoreTokenFactory<T> factory) { List<T> res = new ArrayList<>(); String text = cm.get(CoreAnnotations.TextAnnotation.class); Matcher m = p.matcher(text); int index = 0; while (m.find()) { int start = m.start(); int end = m.end(); // Include characters from index to m.start() appendCoreMap(res, cm, text, index, start, factory); // Include matched pattern if (includeMatched) { appendCoreMap(res, cm, text, start, end, factory); } index = end; } appendCoreMap(res, cm, text, index, text.length(), factory); return res; }
public static <T extends CoreMap> List<T> splitCoreMap(Pattern p, boolean includeMatched, CoreMap cm, CoreTokenFactory<T> factory) { List<T> res = new ArrayList<>(); String text = cm.get(CoreAnnotations.TextAnnotation.class); Matcher m = p.matcher(text); int index = 0; while (m.find()) { int start = m.start(); int end = m.end(); // Include characters from index to m.start() appendCoreMap(res, cm, text, index, start, factory); // Include matched pattern if (includeMatched) { appendCoreMap(res, cm, text, start, end, factory); } index = end; } appendCoreMap(res, cm, text, index, text.length(), factory); return res; }
public static <T extends CoreMap> List<T> splitCoreMap(Pattern p, boolean includeMatched, CoreMap cm, CoreTokenFactory<T> factory) { List<T> res = new ArrayList<>(); String text = cm.get(CoreAnnotations.TextAnnotation.class); Matcher m = p.matcher(text); int index = 0; while (m.find()) { int start = m.start(); int end = m.end(); // Include characters from index to m.start() appendCoreMap(res, cm, text, index, start, factory); // Include matched pattern if (includeMatched) { appendCoreMap(res, cm, text, start, end, factory); } index = end; } appendCoreMap(res, cm, text, index, text.length(), factory); return res; }
public static <T extends CoreMap> List<T> splitCoreMap(Pattern p, boolean includeMatched, CoreMap cm, CoreTokenFactory<T> factory) { List<T> res = new ArrayList<T>(); String text = cm.get(CoreAnnotations.TextAnnotation.class); Matcher m = p.matcher(text); int index = 0; while (m.find()) { int start = m.start(); int end = m.end(); // Include characters from index to m.start() appendCoreMap(res, cm, text, index, start, factory); // Include matched pattern if (includeMatched) { appendCoreMap(res, cm, text, start, end, factory); } index = end; } appendCoreMap(res, cm, text, index, text.length(), factory); return res; }