} else if (inIncorrectExample) { StringPair examplePair = new StringPair(srcExample.getExample(), trgExample.getExample()); if (trgExample.getCorrections().isEmpty()) { incorrectExamples.add(new IncorrectBitextExample(examplePair)); } else { List<String> corrections = trgExample.getCorrections(); incorrectExamples.add(new IncorrectBitextExample(examplePair, corrections));
List<String> expectedCorrections = origBadExample.getCorrections(); int expectedMatchStart = origBadSentence.indexOf("<marker>"); int expectedMatchEnd = origBadSentence.indexOf("</marker>") - "<marker>".length();
boolean correctionExists = false; for (IncorrectExample incorrectExample : rule.getIncorrectExamples()) { if (incorrectExample.getCorrections().size() > 0) { correctionExists = true; break;
private static String getExampleSentences(Rule rule, ResourceBundle messages) { StringBuilder examples = new StringBuilder(200); List<IncorrectExample> incorrectExamples = rule.getIncorrectExamples(); if (incorrectExamples.size() > 0) { String incorrectExample = incorrectExamples.iterator().next().getExample(); String sentence = incorrectExample.replace("<marker>", "<span style='background-color:#ff8080'>").replace("</marker>", "</span>"); examples.append("<br/>").append(sentence).append(" <span style='color:red;font-style:italic;font-weight:bold'>x</span>"); } List<CorrectExample> correctExamples = rule.getCorrectExamples(); if (correctExamples.size() > 0) { String correctExample = correctExamples.iterator().next().getExample(); String sentence = correctExample.replace("<marker>", "<span style='background-color:#80ff80'>").replace("</marker>", "</span>"); examples.append("<br/>").append(sentence).append(" <span style='color:green'>✓</span>"); } else if (incorrectExamples.size() > 0) { IncorrectExample incorrectExample = incorrectExamples.iterator().next(); List<String> corrections = incorrectExample.getCorrections(); if (!corrections.isEmpty()) { String incorrectSentence = incorrectExamples.iterator().next().getExample(); String correctedSentence = incorrectSentence.replaceAll("<marker>.*?</marker>", "<span style='background-color:#80ff80'>" + corrections.get(0) + "</span>"); examples.append("<br/>").append(correctedSentence).append(" <span style='color:green'>✓</span>"); } } if (examples.length() > 0) { examples.insert(0, "<br/><br/>" + messages.getString("guiExamples")); } return examples.toString(); }
g.writeStringField("sentence", example.getExample()); g.writeArrayFieldStart("corrections"); for (String s : example.getCorrections()) { g.writeString(s);
} else if (inIncorrectExample) { StringPair examplePair = new StringPair(srcExample.getExample(), trgExample.getExample()); if (trgExample.getCorrections().isEmpty()) { incorrectExamples.add(new IncorrectBitextExample(examplePair)); } else { List<String> corrections = trgExample.getCorrections(); incorrectExamples.add(new IncorrectBitextExample(examplePair, corrections));