update
This commit is contained in:
parent
1f1ad49427
commit
6f050a029e
2496 changed files with 37609 additions and 3031 deletions
|
|
@ -9,3 +9,5 @@ Output:
|
|||
Abstract type: 10 examples.
|
||||
|
||||
Total: X examples.</pre>
|
||||
|
||||
You'll need to use the Media Wiki API, which you can find out about locally, [http://rosettacode.org/mw/api.php here], or in Media Wiki's API documentation at, [http://www.mediawiki.org/wiki/API_Query API:Query]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
#lang racket
|
||||
|
||||
(require net/url net/uri-codec json (only-in racket/dict [dict-ref ref]))
|
||||
|
||||
(define (RC-get verb params)
|
||||
((compose1 get-pure-port string->url format)
|
||||
"http://rosettacode.org/mw/~a.php?~a" verb (alist->form-urlencoded params)))
|
||||
|
||||
(define (get-category catname)
|
||||
(let loop ([c #f])
|
||||
(define t
|
||||
((compose1 read-json RC-get) 'api
|
||||
`([action . "query"] [format . "json"]
|
||||
[list . "categorymembers"] [cmtitle . ,(format "Category:~a" catname)]
|
||||
[cmcontinue . ,(and c (ref c 'cmcontinue))] [cmlimit . "500"])))
|
||||
(define (c-m key) (ref (ref t key '()) 'categorymembers #f))
|
||||
(append (for/list ([page (c-m 'query)]) (ref page 'title))
|
||||
(cond [(c-m 'query-continue) => loop] [else '()]))))
|
||||
|
||||
(printf "Total: ~a\n"
|
||||
(for/sum ([task (get-category 'Programming_Tasks)])
|
||||
(define s ((compose1 length regexp-match-positions*)
|
||||
#rx"=={{" (RC-get 'index `([action . "raw"] [title . ,task]))))
|
||||
(printf "~a: ~a\n" task s)
|
||||
s))
|
||||
Loading…
Add table
Add a link
Reference in a new issue