Skip to content

Commit

Permalink
*CCIAnalyser: count articles too.
Browse files Browse the repository at this point in the history
  • Loading branch information
MER-C committed Dec 23, 2023
1 parent 8342364 commit 1d16282
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/org/wikipedia/tools/CCIAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ public String createOutput(CCIPage page)
if (footer != null)
out.append(footer);
out.append("\n");
System.err.printf("%d of %d diffs and %d articles removed.%n", page.baseremoveddiffs + page.minoredits.size(),
page.diffcount, page.baseremovedarticles + removedarticles);
System.err.printf("%d of %d diffs and %d of %d articles removed.%n", page.baseremoveddiffs + page.minoredits.size(),
page.diffcount, page.baseremovedarticles + removedarticles, page.pagecount);
return out.toString();
}

Expand Down Expand Up @@ -798,6 +798,7 @@ public class CCIPage
private String title;
private String cci;
private int diffcount;
private int pagecount;
private int baseremoveddiffs;
private int baseremovedarticles;
private List<String> diffshort, diffs, minoredits;
Expand All @@ -811,9 +812,18 @@ private CCIPage(String title, String cci)
diffs = new ArrayList<>(1000);
minoredits = new ArrayList<>(500);

// count diffs
for (int i = cci.indexOf("[[Special:Diff/"); i >= 0; i = cci.indexOf("[[Special:Diff/", ++i))
diffcount++;
// count articles and diffs
String[] x = cci.split("\n");
Pattern p = Pattern.compile("\\*.+\\(\\d+ edits?.*\\).+Special:Diff.+");
for (String line : x)
{
if (p.matcher(line).matches())
{
for (int i = line.indexOf("[[Special:Diff/"); i >= 0; i = line.indexOf("[[Special:Diff/", ++i))
diffcount++;
pagecount++;
}
}
}

/**
Expand Down

0 comments on commit 1d16282

Please # to comment.