Skip to content

Commit

Permalink
Extract English spelling process into validate_en
Browse files Browse the repository at this point in the history
  • Loading branch information
takahi-i committed Sep 10, 2017
1 parent 868c0d8 commit d89d191
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
public final class SpellingValidator extends SpellingDictionaryValidator {
@Override
public void validate(Sentence sentence) {
if (getSymbolTable().getLang().equals("en")) {
validate_en(sentence);
}
}

private void validate_en(Sentence sentence) {
for (TokenElement token : sentence.getTokens()) {
String surface = token.getSurface().toLowerCase();
if (surface.length() == 0 || surface.matches("\\P{L}+")) continue;
Expand All @@ -32,4 +38,5 @@ public void validate(Sentence sentence) {
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void nonLatin() throws RedPenException {

RedPen redPen = new RedPen(config);
Map<Document, List<ValidationError>> errors = redPen.validate(singletonList(document));
assertEquals(1, errors.get(document).size());
assertEquals(0, errors.get(document).size());
}

@Test
Expand Down

0 comments on commit d89d191

Please sign in to comment.