@Test void testSentenceWithCommas() throws RedPenException { Document document = prepareSimpleDocument("There is no real path, so first follow the line of the foot of the rocks past Kawa, then cut straight up to the next level of slabs."); RedPen redPen = new RedPen(config); Map<Document, List<ValidationError>> errors = redPen.validate(singletonList(document)); assertEquals(0, errors.get(document).size()); }
@Override public void validate(Sentence sentence) { List<TokenElement> words = sentence.getTokens(); int wordNum = 0; for (TokenElement word : words) { if (!word.getSurface().equals(",") && !word.getSurface().equals(",") && !word.getSurface().equals("?") && !word.getSurface().equals("!") && !word.getSurface().equals(":") && !word.getSurface().equals(";") && !word.getSurface().equals("\"") && !word.getSurface().equals("'")) { wordNum++; } } int maxNum = getInt("max_num"); if (wordNum > maxNum) { addLocalizedError(sentence, wordNum, maxNum); } }
WordNumberValidator extends Validator { @Override public void validate(Sentence sentence) { List<TokenElement> words = sentence.getTokens(); int wordNum = 0; for (TokenElement word : words) { if (!word.getSurface().equals(",") && !word.getSurface().equals(",") && !word.getSurface().equals("?") && !word.getSurface().equals("!") && !word.getSurface().equals(":") && !word.getSurface().equals(";") && !word.getSurface().equals("\"") && !word.getSurface().equals("'")) { wordNum++; } } int maxNum = getInt("max_num"); if (wordNum > maxNum) { addLocalizedError(sentence, wordNum, maxNum); } } }
WordNumberValidator extends Validator { @Override public void validate(Sentence sentence) { List<TokenElement> words = sentence.getTokens(); int wordNum = 0; for (TokenElement word : words) { if (!word.getSurface().equals(",") && !word.getSurface().equals(",") && !word.getSurface().equals("?") && !word.getSurface().equals("!") && !word.getSurface().equals(":") && !word.getSurface().equals(";") && !word.getSurface().equals("\"") && !word.getSurface().equals("'")) { wordNum++; } } int maxNum = getInt("max_num"); if (wordNum > maxNum) { addLocalizedError(sentence, wordNum, maxNum); } } WordNumberValidator(); }
WordNumberValidator extends Validator { @Override public void validate(Sentence sentence) { List<TokenElement> words = sentence.getTokens(); int wordNum = 0; for (TokenElement word : words) { if (!word.getSurface().equals(",") && !word.getSurface().equals(",") && !word.getSurface().equals("?") && !word.getSurface().equals("!") && !word.getSurface().equals(":") && !word.getSurface().equals(";") && !word.getSurface().equals("\"") && !word.getSurface().equals("'")) { wordNum++; } } int maxNum = getInt("max_num"); if (wordNum > maxNum) { addLocalizedError(sentence, wordNum, maxNum); } } WordNumberValidator(); @Override void validate(Sentence sentence); }
WordNumberValidator extends Validator { @Override public void validate(Sentence sentence) { List<TokenElement> words = sentence.getTokens(); int wordNum = 0; for (TokenElement word : words) { if (!word.getSurface().equals(",") && !word.getSurface().equals(",") && !word.getSurface().equals("?") && !word.getSurface().equals("!") && !word.getSurface().equals(":") && !word.getSurface().equals(";") && !word.getSurface().equals("\"") && !word.getSurface().equals("'")) { wordNum++; } } int maxNum = getInt("max_num"); if (wordNum > maxNum) { addLocalizedError(sentence, wordNum, maxNum); } } WordNumberValidator(); @Override void validate(Sentence sentence);  }