@Test void testPunctuation() throws RedPenException { RedPen redPen = new RedPen(config); Document document = prepareSimpleDocument("That is true."); assertEquals(0, redPen.validate(singletonList(document)).get(document).size()); document = prepareSimpleDocument("That is true!"); assertEquals(0, redPen.validate(singletonList(document)).get(document).size()); document = prepareSimpleDocument("That is true?"); assertEquals(0, redPen.validate(singletonList(document)).get(document).size()); document = prepareSimpleDocument("That: true"); assertEquals(0, redPen.validate(singletonList(document)).get(document).size()); document = prepareSimpleDocument("That; and also this"); assertEquals(0, redPen.validate(singletonList(document)).get(document).size()); document = prepareSimpleDocument("That - is good"); assertEquals(0, redPen.validate(singletonList(document)).get(document).size()); document = prepareSimpleDocument("That / That"); assertEquals(0, redPen.validate(singletonList(document)).get(document).size()); document = prepareSimpleDocument("Number 1"); assertEquals(0, redPen.validate(singletonList(document)).get(document).size()); document = prepareSimpleDocument("The price is $123 or 100€ or ¥1000"); assertEquals(0, redPen.validate(singletonList(document)).get(document).size()); document = prepareSimpleDocument("100%"); assertEquals(0, redPen.validate(singletonList(document)).get(document).size()); }
@Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String surface = token.getSurface().toLowerCase(); if (surface.length() == 0 || surface.matches("\\P{L}+")) continue; if (dictionaryExists() && !inDictionary(surface)) { addLocalizedErrorFromToken(sentence, token); } } }
SpellingValidator extends SpellingDictionaryValidator { @Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String surface = token.getSurface().toLowerCase(); if (surface.length() == 0 || surface.matches("\\P{L}+")) continue; if (dictionaryExists() && !inDictionary(surface)) { addLocalizedErrorFromToken(sentence, token); } } } }
SpellingValidator extends SpellingDictionaryValidator { @Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String surface = token.getSurface().toLowerCase(); if (surface.length() == 0 || surface.matches("\\P{L}+")) continue; if (dictionaryExists() && !inDictionary(surface)) { addLocalizedErrorFromToken(sentence, token); } } }  }
SpellingValidator extends SpellingDictionaryValidator { @Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String surface = token.getSurface().toLowerCase(); if (surface.length() == 0 || surface.matches("\\P{L}+")) continue; if (dictionaryExists() && !inDictionary(surface)) { addLocalizedErrorFromToken(sentence, token); } } }  @Override void validate(Sentence sentence); }
SpellingValidator extends SpellingDictionaryValidator { @Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String surface = token.getSurface().toLowerCase(); if (surface.length() == 0 || surface.matches("\\P{L}+")) continue; if (dictionaryExists() && !inDictionary(surface)) { addLocalizedErrorFromToken(sentence, token); } } }  @Override void validate(Sentence sentence);  }