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,75 +1,46 @@
$define RCINDEX "http://rosettacode.org/mw/api.php?format=xml&action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500"
$define RCTASK "http://rosettacode.org/mw/index.php?action=raw&title="
$define RCUA "User-Agent: Unicon Rosetta 0.1"
$define RCXUA "X-Unicon: http://unicon.org/"
$define TASKTOT "* Total Tasks *"
$define TOTTOT "* Total Headers*"
link strings
link hexcvt
$define RCPREFIX "https://rosettacode.org/w/api.php?action=query&list=categorymembers&format=xml&cmlimit=5000&cmtitle=Category:"
$define RCSUFFIX1 "Programming%20Tasks"
procedure main(A) # simple single threaded read all at once implementation
lang := \A[1] | "Unicon"
write("Unimplemented tasks for ",lang," as of ",&date)
every task := taskNames() do {
if lang == languages(task) then next
write(task)
}
all_tasks := set([: taskNames() :])
tasks_for_lang := set([: tasksForLang(lang) :])
every write(!sort(all_tasks -- tasks_for_lang))
end
# Generate task names
procedure taskNames()
continue := ""
while \(txt := ReadURL(RCINDEX||continue)) do {
while \(txt := ReadURL(RCPREFIX||RCSUFFIX1||continue)) do {
txt ? {
while tab(find("<cm ") & find(s :="title=\"")+*s) do
while tab((find("<cm "),find(s :="title=\""))+*s) do
suspend tab(find("\""))\1
if tab(find("cmcontinue=")) then {
continue := "&"||tab(upto(' \t'))
}
else break
continue := getContinue() | break
}
}
end
# Generate language headers in a task
procedure languages(task)
static WS
initial WS := ' \t'
page := ReadURL(RCTASK||CleanURI(task))
page ? while (tab(find("\n==")),tab(many(WS))|"",tab(find("{{"))) do {
header := tab(find("=="))
header ? {
while tab(find("{{header|")) do {
suspend 2(="{{header|",tab(find("}}")))\1
}
}
}
# Generate all tasks for a language
procedure tasksForLang(lang)
continue := ""
while \(txt := ReadURL(RCPREFIX||lang||continue)) do {
txt ? {
while tab(find(s :="title=\"")+*s) do
suspend tab(find("\""))\1
continue := getContinue() | break
}
}
end
procedure CleanURI(u) #: clean up a URI
static tr,dxml # xml & http translation
initial {
tr := table()
every c := !string(~(&digits++&letters++'-_.!~*()/\'`')) do
tr[c] := "%"||hexstring(ord(c),2)
every /tr[c := !string(&cset)] := c
tr[" "] := "_" # wiki convention
every push(dxml := [],"&#"||right(ord(c := !"&<>'\""),3,"0")||";",c)
}
dxml[1] := u # insert URI as 1st arg
u := replacem!dxml # de-xml it
every (c := "") ||:= tr[!u] # reencode everything
c := replace(c,"%3E","'") # Hack to put single quotes back in
c := replace(c,"%26quot%3B","\"") # Hack to put double quotes back in
return c
procedure getContinue()
gcm := "cmcontinue="
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)
page := open(url,"m-") | stop("Unable to open ",url," -> ",&errortext)
if page["Status-Code"] < 300 then text := reads(page,-1)
else write(&errout,image(url),": ",
page["Status-Code"]," ",page["Reason-Phrase"])
close(page)