/** * Create an example text (usually just one sentence) with an error - the error must be marked with {@code <marker>...</marker>}. * @throws IllegalArgumentException if the {@code <marker>...</marker>} is missing * @since 2.5 */ public static IncorrectExample wrong(String example) { requireMarkup(example); return new IncorrectExample(example); }
private IncorrectExample setExample() { IncorrectExample example = null; if (inCorrectExample) { example = new IncorrectExample(correctExample.toString()); } else if (inIncorrectExample) { String[] corrections = exampleCorrection.toString().split("\\|"); if (corrections.length > 0 && corrections[0].length() > 0) { example = new IncorrectExample(incorrectExample.toString(), Arrays.asList(corrections)); } else { example = new IncorrectExample(incorrectExample.toString()); } } else if (inErrorTriggerExample) { throw new RuntimeException("'triggers_error' is not supported for bitext XML"); } correctExample = new StringBuilder(); incorrectExample = new StringBuilder(); exampleCorrection = new StringBuilder(); return example; }
/** * Convenience method to add a pair of sentences: an incorrect sentence and the same sentence * with the error corrected. * @since 2.5 */ protected void addExamplePair(IncorrectExample incorrectSentence, CorrectExample correctSentence) { String correctExample = correctSentence.getExample(); int markerStart= correctExample.indexOf("<marker>"); int markerEnd = correctExample.indexOf("</marker>"); if (markerStart != -1 && markerEnd != -1) { List<String> correction = Collections.singletonList(correctExample.substring(markerStart + "<marker>".length(), markerEnd)); incorrectExamples.add(new IncorrectExample(incorrectSentence.getExample(), correction)); } else { incorrectExamples.add(incorrectSentence); } correctExamples.add(correctSentence); }
corrections.add(""); example = new IncorrectExample(incorrectExample.toString(), corrections); } else { example = new IncorrectExample(incorrectExample.toString());
correctExamples.add(new CorrectExample(correctExample.toString())); } else if (inIncorrectExample) { incorrectExamples.add(new IncorrectExample(incorrectExample.toString()));
/** * Create an example text (usually just one sentence) with an error - the error must be marked with {@code <marker>...</marker>}. * @throws IllegalArgumentException if the {@code <marker>...</marker>} is missing * @since 2.5 */ public static IncorrectExample wrong(String example) { requireMarkup(example); return new IncorrectExample(example); }
private IncorrectExample setExample() { IncorrectExample example = null; if (inCorrectExample) { example = new IncorrectExample(correctExample.toString()); } else if (inIncorrectExample) { String[] corrections = exampleCorrection.toString().split("\\|"); if (corrections.length > 0 && corrections[0].length() > 0) { example = new IncorrectExample(incorrectExample.toString(), Arrays.asList(corrections)); } else { example = new IncorrectExample(incorrectExample.toString()); } } else if (inErrorTriggerExample) { throw new RuntimeException("'triggers_error' is not supported for bitext XML"); } correctExample = new StringBuilder(); incorrectExample = new StringBuilder(); exampleCorrection = new StringBuilder(); return example; }
/** * Convenience method to add a pair of sentences: an incorrect sentence and the same sentence * with the error corrected. * @since 2.5 */ protected void addExamplePair(IncorrectExample incorrectSentence, CorrectExample correctSentence) { String correctExample = correctSentence.getExample(); int markerStart= correctExample.indexOf("<marker>"); int markerEnd = correctExample.indexOf("</marker>"); if (markerStart != -1 && markerEnd != -1) { List<String> correction = Collections.singletonList(correctExample.substring(markerStart + "<marker>".length(), markerEnd)); incorrectExamples.add(new IncorrectExample(incorrectSentence.getExample(), correction)); } else { incorrectExamples.add(incorrectSentence); } correctExamples.add(correctSentence); }
corrections.add(""); example = new IncorrectExample(incorrectExample.toString(), corrections); } else { example = new IncorrectExample(incorrectExample.toString());
correctExamples.add(new CorrectExample(correctExample.toString())); } else if (inIncorrectExample) { incorrectExamples.add(new IncorrectExample(incorrectExample.toString()));