Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,49 +1,46 @@
$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/"
$define RCLANGS "https://rosettacode.org/w/api.php?action=query&generator=categorymembers&gcmtitle=Category:Programming%20Languages&gcmlimit=500&prop=categoryinfo&format=xml"
link strings
link hexcvt
procedure main()
procedure main(A)
limit := \A[1] # Limit the output?
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,". "))
if 0 >= (\limit -:= 1) then break
}
write(*langs, " languages")
end
# Generate page counts for each language
procedure tallyPages(url)
/url := RCLANGS
procedure tallyPages()
counts := table()
continue := ""
while \(txt := ReadURL(url||continue)) do {
while \(txt := ReadURL(RCLANGS||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
continue := getContinue() | break
}
}
return counts
end
procedure getContinue()
gcm := "gcmcontinue="
return (tab(1),"&"||2(tab(find(gcm)),=gcm,="\"")||tab(upto('"')))
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"])
page := open(url,"m-") | stop("Unable to open ",url,"\n",&errno,"->",&errortext)
if page["Status-Code"] < 300 then text := reads(page,-1)
else write(&errout,"ERROR: ",&errout," -> ",&errortext)
close(page)
return text
end