/** * Replaces all occurrences of the pattern with the specified list. * Use {@link #replaceAllExtended(java.util.List)} to replace with matched groups. * @param replacement What to replace the matched sequence with * @return New list with all occurrences of the pattern replaced * @see #replaceAllExtended(java.util.List) * @see #replaceFirst(java.util.List) * @see #replaceFirstExtended(java.util.List) */ public List<T> replaceAll(List<T> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; while (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); res.addAll(replacement); index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces the first occurrence of the pattern with the specified list. * Use {@link #replaceFirstExtended(java.util.List)} to replace with matched groups. * @param replacement What to replace the matched sequence with * @return New list with the first occurrence of the pattern replaced * @see #replaceAll(java.util.List) * @see #replaceAllExtended(java.util.List) * @see #replaceFirstExtended(java.util.List) */ public List<T> replaceFirst(List<T> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; if (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); res.addAll(replacement); index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces all occurrences of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with all occurrences of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceFirstExtended(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceAllExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; while (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces the first occurrence of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with the first occurrence of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceAll(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceFirstExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; if (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
protected boolean find0(int start, boolean matchStart) { boolean match = false; matched = false; matchingCompleted = false; if (matchStart) { match = findMatchStart(start, false); } else { for (int i = start; i < regionEnd; i++) { match = findMatchStart(i, false); if (match) { break; } } } matched = match; matchingCompleted = true; if (matched) { nextMatchStart = (findType == FindType.FIND_NONOVERLAPPING)? end(): start()+1; } else { nextMatchStart = -1; } return match; }
/** * Replaces the first occurrence of the pattern with the specified list. * Use {@link #replaceFirstExtended(java.util.List)} to replace with matched groups. * @param replacement What to replace the matched sequence with * @return New list with the first occurrence of the pattern replaced * @see #replaceAll(java.util.List) * @see #replaceAllExtended(java.util.List) * @see #replaceFirstExtended(java.util.List) */ public List<T> replaceFirst(List<T> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; if (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); res.addAll(replacement); index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces all occurrences of the pattern with the specified list. * Use {@link #replaceAllExtended(java.util.List)} to replace with matched groups. * @param replacement What to replace the matched sequence with * @return New list with all occurrences of the pattern replaced * @see #replaceAllExtended(java.util.List) * @see #replaceFirst(java.util.List) * @see #replaceFirstExtended(java.util.List) */ public List<T> replaceAll(List<T> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; while (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); res.addAll(replacement); index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces all occurrences of the pattern with the specified list. * Use {@link #replaceAllExtended(java.util.List)} to replace with matched groups. * @param replacement What to replace the matched sequence with * @return New list with all occurrences of the pattern replaced * @see #replaceAllExtended(java.util.List) * @see #replaceFirst(java.util.List) * @see #replaceFirstExtended(java.util.List) */ public List<T> replaceAll(List<T> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; while (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); res.addAll(replacement); index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces the first occurrence of the pattern with the specified list. * Use {@link #replaceFirstExtended(java.util.List)} to replace with matched groups. * @param replacement What to replace the matched sequence with * @return New list with the first occurrence of the pattern replaced * @see #replaceAll(java.util.List) * @see #replaceAllExtended(java.util.List) * @see #replaceFirstExtended(java.util.List) */ public List<T> replaceFirst(List<T> replacement) { List<T> res = new ArrayList<T>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; if (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); res.addAll(replacement); index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
protected boolean find(int start, boolean matchStart) { boolean match = false; matched = false; matchingCompleted = false; if (matchStart) { match = findMatchStart(start, false); } else { for (int i = start; i < regionEnd; i++) { match = findMatchStart(i, false); if (match) { break; } } } matched = match; matchingCompleted = true; if (matched) { nextMatchStart = (findType == FindType.FIND_NONOVERLAPPING)? end(): start+1; } else { nextMatchStart = -1; } return match; }
/** * Replaces the first occurrence of the pattern with the specified list. * Use {@link #replaceFirstExtended(java.util.List)} to replace with matched groups. * @param replacement What to replace the matched sequence with * @return New list with the first occurrence of the pattern replaced * @see #replaceAll(java.util.List) * @see #replaceAllExtended(java.util.List) * @see #replaceFirstExtended(java.util.List) */ public List<T> replaceFirst(List<T> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; if (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); res.addAll(replacement); index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces all occurrences of the pattern with the specified list. * Use {@link #replaceAllExtended(java.util.List)} to replace with matched groups. * @param replacement What to replace the matched sequence with * @return New list with all occurrences of the pattern replaced * @see #replaceAllExtended(java.util.List) * @see #replaceFirst(java.util.List) * @see #replaceFirstExtended(java.util.List) */ public List<T> replaceAll(List<T> replacement) { List<T> res = new ArrayList<T>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; while (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); res.addAll(replacement); index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces all occurrences of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with all occurrences of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceFirstExtended(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceAllExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; while (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces all occurrences of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with all occurrences of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceFirstExtended(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceAllExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; while (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces the first occurrence of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with the first occurrence of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceAll(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceFirstExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; if (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces all occurrences of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with all occurrences of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceFirstExtended(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceAllExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<T>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; while (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
protected boolean find0(int start, boolean matchStart) { boolean match = false; matched = false; matchingCompleted = false; if (matchStart) { match = findMatchStart(start, false); } else { for (int i = start; i < regionEnd; i++) { match = findMatchStart(i, false); if (match) { break; } } } matched = match; matchingCompleted = true; if (matched) { nextMatchStart = (findType == FindType.FIND_NONOVERLAPPING)? end(): start()+1; } else { nextMatchStart = -1; } return match; }
protected boolean find(int start, boolean matchStart) { boolean match = false; matched = false; matchingCompleted = false; if (matchStart) { match = findMatchStart(start, false); } else { for (int i = start; i < regionEnd; i++) { match = findMatchStart(i, false); if (match) { break; } } } matched = match; matchingCompleted = true; if (matched) { nextMatchStart = (findType == FindType.FIND_NONOVERLAPPING)? end(): start()+1; } else { nextMatchStart = -1; } return match; }
public boolean extract(List<? extends CoreMap> tokens, List<TimeExpression> out) { boolean extracted = false; SequenceMatcher<CoreMap> m = pattern.getMatcher(tokens); while (m.find()) { TimeExpression te = new TimeExpression(null, Interval.toInterval(m.start(group), m.end(group), Interval.INTERVAL_OPEN_END), extractor, m.score()); te.includeNested = includeNested; out.add(te); extracted = true; } return extracted; }
protected boolean find0(int start, boolean matchStart) { boolean match = false; matched = false; matchingCompleted = false; if (matchStart) { match = findMatchStart(start, false); } else { for (int i = start; i < regionEnd; i++) { match = findMatchStart(i, false); if (match) { break; } } } matched = match; matchingCompleted = true; if (matched) { nextMatchStart = (findType == FindType.FIND_NONOVERLAPPING)? end(): start()+1; } else { nextMatchStart = -1; } return match; }