コード例 #1
0
ファイル: RedPen.java プロジェクト: so-c/redpen
 /**
  * parse given files.
  *
  * @param parser DocumentParser parser
  * @param files files to parse
  * @return parsed documents
  * @throws RedPenException when failed to parse input stream
  */
 public List<Document> parse(DocumentParser parser, File[] files) throws RedPenException {
   List<Document> documents = new ArrayList<>();
   for (File file : files) {
     documents.add(parser.parse(file, sentenceExtractor, configuration.getTokenizer()));
   }
   return documents;
 }
コード例 #2
0
  @Test
  public void testNotDetectPositiveType() throws Exception {
    String sampleText = "そういう話は理解できる。";
    Configuration config =
        Configuration.builder("ja")
            .addValidatorConfig(new ValidatorConfiguration("DoubleNegative"))
            .build();
    DocumentParser parser = DocumentParser.MARKDOWN;
    List<Document> documents = new ArrayList<>();
    Document document =
        parser.parse(
            sampleText, new SentenceExtractor(config.getSymbolTable()), config.getTokenizer());
    documents.add(document);

    RedPen redPen = new RedPen(config);
    Map<Document, List<ValidationError>> errors = redPen.validate(documents);

    assertEquals(0, errors.get(documents.get(0)).size());
  }
コード例 #3
0
  @Test
  public void testDetectEnDoubleNegativeWithDistance() throws Exception {
    String sampleText = "unless that is not true, I will go there.";
    Configuration config =
        Configuration.builder()
            .addValidatorConfig(new ValidatorConfiguration("DoubleNegative"))
            .build();

    DocumentParser parser = DocumentParser.MARKDOWN;
    List<Document> documents = new ArrayList<>();
    Document document =
        parser.parse(
            sampleText, new SentenceExtractor(config.getSymbolTable()), config.getTokenizer());
    documents.add(document);

    RedPen redPen = new RedPen(config);
    Map<Document, List<ValidationError>> errors = redPen.validate(documents);

    assertEquals(1, errors.get(documents.get(0)).size());
    assertEquals(1, errors.get(documents.get(0)).get(0).getLineNumber());
    assertEquals("DoubleNegative", errors.get(documents.get(0)).get(0).getValidatorName());
  }
コード例 #4
0
ファイル: RedPen.java プロジェクト: so-c/redpen
 /**
  * parse given input stream.
  *
  * @param parser DocumentParser parser
  * @param InputStream content to parse
  * @return parsed document
  * @throws RedPenException when failed to parse input stream
  */
 public Document parse(DocumentParser parser, InputStream InputStream) throws RedPenException {
   return parser.parse(InputStream, sentenceExtractor, configuration.getTokenizer());
 }
コード例 #5
0
ファイル: RedPen.java プロジェクト: so-c/redpen
 /**
  * parse given content.
  *
  * @param parser DocumentParser parser
  * @param content content to parse
  * @return parsed document
  * @throws RedPenException when failed to parse input stream
  */
 public Document parse(DocumentParser parser, String content) throws RedPenException {
   return parser.parse(content, sentenceExtractor, configuration.getTokenizer());
 }