-- Corpus - Read input words given as lines and make a corpus holding all five letter words therein. -- Copyright (C) 2024 Prince Trippy . -- This program is free software: you can redistribute it and/or modify it under the terms of the -- GNU Affero General Public License version 3 as published by the Free Software Foundation. -- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without -- even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- See the GNU Affero General Public License for more details. -- You should have received a copy of the GNU Affero General Public License along with this program. -- If not, see . -- This program requires Ada 2005 support due entirely to the function form of Ada.Text_IO.Get_Line. with Ada.Text_IO, Ada.Command_Line, Ada.Strings.Fixed, Ada.Strings.Maps.Constants; procedure Corpus is subtype Letter is Character range 'a' .. 'z'; Five : array (Letter, Letter, Letter, Letter, Letter) of Boolean := (others => (others => (others => (others => (others => False))))); File : Ada.Text_IO.File_Type; begin if Ada.Command_Line.Argument_Count /= 2 then Ada.Text_IO.Put_Line("Supply an input and an output file."); return; end if; Ada.Text_IO.Open(File, Mode => Ada.Text_IO.In_File, Name => Ada.Command_Line.Argument(1)); Ada.Text_IO.Set_Input(File); while not Ada.Text_IO.End_Of_File loop declare use Ada.Strings.Maps.Constants; Line : String := Ada.Strings.Fixed.Translate(Source => Ada.Text_IO.Get_Line, Mapping => Lower_Case_Map); begin if Line'Length = 5 and then (Line(1) in Letter and Line(2) in Letter and Line(3) in Letter and Line(4) in Letter and Line(5) in Letter) then Five(Line(1), Line(2), Line(3), Line(4), Line(5)) := True; end if; end; end loop; Ada.Text_IO.Close(File); Ada.Text_IO.Create(File, Mode => Ada.Text_IO.Out_File, Name => Ada.Command_Line.Argument(2)); Ada.Text_IO.Set_Output(File); for A in Letter'Range loop for B in Letter'Range loop for C in Letter'Range loop for D in Letter'Range loop for E in Letter'Range loop if Five(A, B, C, D, E) then Ada.Text_IO.Put(A & B & C & D & E); end if; end loop; end loop; end loop; end loop; end loop; Ada.Text_IO.Flush; Ada.Text_IO.Close(File); end Corpus; .