Data update

This commit is contained in:
Ingy döt Net 2024-07-13 15:19:22 -07:00
parent 29a5eea0d4
commit 5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions

View file

@ -1,19 +1,18 @@
with Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url;
with Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs;
with Input_Sources.Strings, Unicode, Unicode.Ces.Utf8;
with AWS.Client, AWS.Messages, AWS.Response, AWS.URL;
with DOM.Readers, DOM.Core, DOM.Core.Documents, DOM.Core.Nodes, DOM.Core.Attrs;
with Input_Sources.Strings, Unicode, Unicode.CES.Utf8;
with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line;
with Ada.Containers.Vectors;
use Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url;
use Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs;
use Aws, Ada.Strings.Unbounded, Input_Sources.Strings;
use AWS.Client, AWS.Messages, AWS.Response;
use DOM.Readers, DOM.Core, DOM.Core.Documents, DOM.Core.Nodes, DOM.Core.Attrs;
use AWS, Ada.Strings.Unbounded, Input_Sources.Strings;
use Ada.Text_IO, Ada.Command_Line;
procedure Not_Coded is
package Members_Vectors is new Ada.Containers.Vectors (
Index_Type => Positive,
Element_Type => Unbounded_String);
package Members_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive, Element_Type => Unbounded_String);
use Members_Vectors;
All_Tasks, Language_Members : Vector;
@ -24,36 +23,33 @@ procedure Not_Coded is
List : Node_List;
N : Node;
A : Attr;
Page : Aws.Response.Data;
Page : AWS.Response.Data;
S : Messages.Status_Code;
-- Query has cmlimit value of 100, so we need 5 calls to
-- retrieve the complete list of Programming_category
-- Query has cmlimit value of 500, so we need 2 calls to
-- retrieve the complete list of Programming_category
Uri_Xml : constant String :=
"http://rosettacode.org/mw/api.php?action=query&list=categorymembers"
&
"&format=xml&cmlimit=100&cmtitle=Category:";
"https://rosettacode.org/w/api.php?action=query&list=categorymembers" &
"&format=xml&cmlimit=500&cmtitle=Category:";
Cmcontinue : Unbounded_String := Null_Unbounded_String;
begin
loop
Page :=
Aws.Client.Get (Uri_Xml & Category & (To_String (Cmcontinue)));
S := Response.Status_Code (Page);
if S not in Messages.Success then
AWS.Client.Get (Uri_Xml & Category & (To_String (Cmcontinue)));
S := AWS.Response.Status_Code (Page);
if S not in Messages.Success then
Put_Line
("Unable to retrieve data => Status Code :" &
Image (S) &
" Reason :" &
Reason_Phrase (S));
("Unable to retrieve data => Status Code :" & Image (S) &
" Reason :" & Reason_Phrase (S));
raise Connection_Error;
end if;
declare
Xml : constant String := Message_Body (Page);
Source : String_Input;
begin
Open
(Xml'Unrestricted_Access,
Unicode.Ces.Utf8.Utf8_Encoding,
(Xml'Unrestricted_Access, Unicode.CES.Utf8.Utf8_Encoding,
Source);
Parse (Reader, Source);
Close (Source);
@ -64,22 +60,20 @@ procedure Not_Coded is
N := Item (List, Index - 1);
A := Get_Named_Item (Attributes (N), "title");
Members_Vectors.Append
(Mbr_Vector,
To_Unbounded_String (Value (A)));
(Mbr_Vector, To_Unbounded_String (Value (A)));
end loop;
Free (List);
List := Get_Elements_By_Tag_Name (Doc, "query-continue");
List := Get_Elements_By_Tag_Name (Doc, "continue");
if Length (List) = 0 then
-- we are done
-- we are done
Free (List);
Free (Reader);
exit;
end if;
N := First_Child (Item (List, 0));
N := Item (List, 0);
A := Get_Named_Item (Attributes (N), "cmcontinue");
Cmcontinue :=
To_Unbounded_String
("&cmcontinue=" & Aws.Url.Encode (Value (A)));
To_Unbounded_String ("&cmcontinue=" & AWS.URL.Encode (Value (A)));
Free (List);
Free (Reader);
end loop;
@ -88,14 +82,14 @@ procedure Not_Coded is
procedure Quick_Diff (From : in out Vector; Substract : in Vector) is
Beginning, Position : Extended_Index;
begin
-- take adavantage that both lists are already sorted
-- take adavantage that both lists are already sorted
Beginning := First_Index (From);
for I in First_Index (Substract) .. Last_Index (Substract) loop
Position :=
Find_Index
(Container => From,
Item => Members_Vectors.Element (Substract, I),
Index => Beginning);
Find_Index
(Container => From,
Item => Members_Vectors.Element (Substract, I),
Index => Beginning);
if not (Position = No_Index) then
Delete (From, Position);
Beginning := Position;
@ -108,6 +102,8 @@ begin
Put_Line ("Can't process : No language given!");
return;
else
Put ("Language given: ");
Put_Line (Argument (1));
Get_Vector (Argument (1), Language_Members);
end if;