Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,49 @@
|
|||
$define RCLANGS "http://rosettacode.org/mw/api.php?format=xml&action=query&generator=categorymembers&gcmtitle=Category:Programming%20Languages&gcmlimit=500&prop=categoryinfo"
|
||||
$define RCUA "User-Agent: Unicon Rosetta 0.1"
|
||||
$define RCXUA "X-Unicon: http://unicon.org/"
|
||||
|
||||
link strings
|
||||
link hexcvt
|
||||
|
||||
procedure main()
|
||||
cnt := create seq()
|
||||
last := -1
|
||||
every pair := !reverse(sort(langs := tallyPages(),2)) do {
|
||||
n := if last ~=:= pair[2] then @cnt else (@cnt,"")
|
||||
write(right(n,4),": ",left(pair[1],30,". "),right(pair[2],10,". "))
|
||||
}
|
||||
write(*langs, " languages")
|
||||
end
|
||||
|
||||
# Generate page counts for each language
|
||||
procedure tallyPages(url)
|
||||
/url := RCLANGS
|
||||
counts := table()
|
||||
continue := ""
|
||||
while \(txt := ReadURL(url||continue)) do {
|
||||
txt ? {
|
||||
if tab(find("gcmcontinue=")) then {
|
||||
continue := "&"||tab(upto('"'))
|
||||
move(1)
|
||||
continue ||:= tab(upto('"'))
|
||||
}
|
||||
else continue := ""
|
||||
while tab(find("<page ") & find(s := "title=\"Category:")+*s) do {
|
||||
lang := tab(upto('"'))
|
||||
tab(find(s := "pages=\"")+*s)
|
||||
counts[lang] := numeric(tab(upto('"')))
|
||||
}
|
||||
if continue == "" then return counts
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
procedure ReadURL(url) #: read URL into string
|
||||
page := open(url,"m",RCUA,RCXUA) | stop("Unable to open ",url)
|
||||
text := ""
|
||||
if page["Status-Code"] < 300 then while text ||:= reads(page,-1)
|
||||
else write(&errout,image(url),": ",
|
||||
page["Status-Code"]," ",page["Reason-Phrase"])
|
||||
close(page)
|
||||
return text
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue