@Test void detectSuccessiveWordWithDifferentCase() throws RedPenException { Document document = prepareSimpleDocument("Welcome welcome to Estonia."); RedPen redPen = new RedPen(config); Map<Document, List<ValidationError>> errors = redPen.validate(singletonList(document)); assertEquals(1, errors.get(document).size()); assertEquals("Found word \"welcome\" repeated twice in succession.", errors.get(document).get(0).getMessage()); }
@Override public void validate(Sentence sentence) { String prevSurface = ""; for (TokenElement token : sentence.getTokens()) { String currentSurface = token.getSurface(); if (prevSurface.equalsIgnoreCase(currentSurface) && currentSurface.length() > 0 && !isPartOfNumber(sentence, token)) { addLocalizedErrorFromToken(sentence, token); } prevSurface = currentSurface; } }
SuccessiveWordValidator extends Validator { @Override public void validate(Sentence sentence) { String prevSurface = ""; for (TokenElement token : sentence.getTokens()) { String currentSurface = token.getSurface(); if (prevSurface.equalsIgnoreCase(currentSurface) && currentSurface.length() > 0 && !isPartOfNumber(sentence, token)) { addLocalizedErrorFromToken(sentence, token); } prevSurface = currentSurface; } } }
SuccessiveWordValidator extends Validator { @Override public void validate(Sentence sentence) { String prevSurface = ""; for (TokenElement token : sentence.getTokens()) { String currentSurface = token.getSurface(); if (prevSurface.equalsIgnoreCase(currentSurface) && currentSurface.length() > 0 && !isPartOfNumber(sentence, token)) { addLocalizedErrorFromToken(sentence, token); } prevSurface = currentSurface; } }  }
SuccessiveWordValidator extends Validator { @Override public void validate(Sentence sentence) { String prevSurface = ""; for (TokenElement token : sentence.getTokens()) { String currentSurface = token.getSurface(); if (prevSurface.equalsIgnoreCase(currentSurface) && currentSurface.length() > 0 && !isPartOfNumber(sentence, token)) { addLocalizedErrorFromToken(sentence, token); } prevSurface = currentSurface; } }  @Override void validate(Sentence sentence); }
SuccessiveWordValidator extends Validator { @Override public void validate(Sentence sentence) { String prevSurface = ""; for (TokenElement token : sentence.getTokens()) { String currentSurface = token.getSurface(); if (prevSurface.equalsIgnoreCase(currentSurface) && currentSurface.length() > 0 && !isPartOfNumber(sentence, token)) { addLocalizedErrorFromToken(sentence, token); } prevSurface = currentSurface; } }  @Override void validate(Sentence sentence);  }