Changeset 28987 in osm


Ignore:
Timestamp:
2012-11-25T20:57:21+01:00 (11 years ago)
Author:
simon04
Message:

JOSM/wikipedia: migrate to Lightweight Category Scanner

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaApp.java

    r28983 r28987  
    6767    static List<WikipediaEntry> getEntriesFromCategory(String wikipediaLang, String category, int depth) {
    6868        try {
    69             final String url = "http://toolserver.org/~magnus/catscan_rewrite.php"
    70                     + "?project=wikipedia"
    71                     + "&ext_image_data="
    72                     + "&file_usage_data="
    73                     + "&show_redirects=no"
    74                     + "&format=tsv"
    75                     + "&doit=doit"
     69            final String url = "http://toolserver.org/~simon04/cats.php"
     70                    + "?lang=" + wikipediaLang
    7671                    + "&depth=" + depth
    77                     + "&language=" + wikipediaLang
    78                     + "&categories=" + encodeURL(category);
     72                    + "&cat=" + encodeURL(category);
    7973            System.out.println("Wikipedia: GET " + url);
    8074            final Scanner scanner = new Scanner(new URL(url).openStream(), "UTF-8").useDelimiter("\n");
    8175            final List<WikipediaEntry> entries = new ArrayList<WikipediaEntry>();
    82             {
    83                 // skip first two rows
    84                 final String header = scanner.next(); // |subset
    85                 if (!"|subset".equals(header.trim())) {
    86                     throw new RuntimeException("Wikipedia: Invalid header: " + header);
    87                 }
    88                 final String colspec = scanner.next(); //title  id      namespace       len     touched seen    nstext
    89                 if (!colspec.startsWith("title")) {
    90                     throw new RuntimeException("Wikipedia: Invalid colspec: " + colspec);
    91                 }
    92             }
    9376            while (scanner.hasNext()) {
    94                 final String article = scanner.next().split("\t")[0].trim().replace("_", " ");
     77                final String article = scanner.next().trim().replace("_", " ");
    9578                entries.add(new WikipediaEntry(article, wikipediaLang, article));
    9679            }
Note: See TracChangeset for help on using the changeset viewer.