Skip to content

Commit

Permalink
Make addLocalizedErrorFromToken variadic function
Browse files Browse the repository at this point in the history
  • Loading branch information
takahi-i committed Oct 9, 2017
1 parent b0165b0 commit 98ccea6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ public void addLocalizedError(String messageKey, Sentence sentenceWithError, Obj
}

@Override
public void addLocalizedErrorFromToken(Sentence sentenceWithError, TokenElement token) {
super.addLocalizedErrorFromToken(sentenceWithError, token);
public void addLocalizedErrorFromToken(Sentence sentenceWithError, TokenElement token, Object... args) {
super.addLocalizedErrorFromToken(sentenceWithError, token, args);
}

@Override
Expand Down
8 changes: 5 additions & 3 deletions redpen-core/src/main/java/cc/redpen/validator/Validator.java
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,15 @@ protected void addLocalizedError(String messageKey, Sentence sentenceWithError,
* @param sentenceWithError sentence
* @param token the TokenElement that has the error
*/
protected void addLocalizedErrorFromToken(Sentence sentenceWithError, TokenElement token) {
protected void addLocalizedErrorFromToken(Sentence sentenceWithError, TokenElement token, Object... args) {
List<Object> argList = new ArrayList<>();
for(Object o : args) argList.add(o);
argList.add(0, token.getSurface());
addLocalizedErrorWithPosition(
sentenceWithError,
token.getOffset(),
token.getOffset() + token.getSurface().length(),
token.getSurface(),
getLevel()
argList.toArray()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void validate(Document document) {
List<TokenElement> tokens = this.words.get(reading);
for (TokenElement candidate : tokens) {
if (candidate != token && !token.getSurface().equals(candidate.getSurface())) {
addLocalizedErrorFromToken(sentence, token);
addLocalizedErrorFromToken(sentence, token, candidate.getSurface());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected JapaneseExpressionVariationValidatorTest() {
}

@Test
void japanese() throws RedPenException {
void detectSameReadings() throws RedPenException {
config = Configuration.builder("ja")
.addValidatorConfig(new ValidatorConfiguration(validatorName))
.build();
Expand Down

0 comments on commit 98ccea6

Please sign in to comment.