<commit_before>/* LanguageTool, a natural language style checker
 * Copyright (C) 2013 <NAME> (http://www.danielnaber.de)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
package org.languagetool.dev.wikipedia.atom;

import org.junit.Test;
import org.languagetool.language.German;
import org.languagetool.tools.Tools;

import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

import static junit.framework.TestCase.assertTrue;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

public class AtomFeedCheckerTest {

  private static final String DB_URL = "jdbc:derby:atomFeedChecksDB;create=true";

  @Test
  public void testCheck() throws IOException {
    AtomFeedChecker atomFeedChecker = new AtomFeedChecker(new German());
    CheckResult checkResult = atomFeedChecker.checkChanges(getStream());
    List<ChangeAnalysis> changeAnalysis = checkResult.getCheckResults();
    assertThat(changeAnalysis.size(), is(3));

    assertThat(changeAnalysis.get(0).getAddedMatches().size(), is(1));<commit_msg>add an interactive test (set to @Ignore)<commit_after>/* LanguageTool, a natural language style checker
 * Copyright (C) 2013 <NAME> (http://www.danielnaber.de)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
package org.languagetool.dev.wikipedia.atom;

import org.junit.Ignore;
import org.junit.Test;
import org.languagetool.language.English;
import org.languagetool.language.German;
import org.languagetool.tools.Tools;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

import static junit.framework.TestCase.assertTrue;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

public class AtomFeedCheckerTest {

  private static final String DB_URL = "jdbc:derby:atomFeedChecksDB;create=true";

  @Ignore("Interactive use only - for testing the 'recent changes' XML we get from the API")
  @Test
  public void testCheckManually() throws IOException {
    AtomFeedChecker atomFeedChecker = new AtomFeedChecker(new English());
    CheckResult checkResult = atomFeedChecker.checkChanges(new FileInputStream("/home/dnaber/wiki.xml"));
    List<ChangeAnalysis> changeAnalysisList = checkResult.getCheckResults();
    for (ChangeAnalysis changeAnalysis : changeAnalysisList) {
      System.out.println(changeAnalysis.getTitle());
      for (WikipediaRuleMatch match : changeAnalysis.getRemovedMatches()) {
        System.out.println(" [-] " + match);
      }
      for (WikipediaRuleMatch match : changeAnalysis.getAddedMatches()) {
        System.out.println(" [+] " + match);
      }
      System.out.println("----------------------");
    }
  }

  @Test
  public void testCheck() throws IOException {
    AtomFeedChecker atomFeedChecker = new AtomFeedChecker(new German());
    CheckResult checkResult = atomFeedChecker.checkChanges(getStream());
    List<ChangeAnalysis> changeAnalysis = checkResult.getCheckResults();
    assertThat(changeAnalysis.size(), is(3));

    assertThat(changeAnalysis.get(0).getAddedMatches().size(), is(1));
{'fraction_non_alphanumeric': 0.09665112335735482, 'fraction_numerical': 0.00847816871555744, 'mean_word_length': 4.571428571428571, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4049978', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1293, 'n_words': 439}