Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,98 +0,0 @@
|
|||
with Ada.Characters.Handling;
|
||||
with Ada.Containers.Indefinite_Vectors;
|
||||
with Ada.Strings.Fixed;
|
||||
with Ada.Strings.Maps.Constants;
|
||||
with Ada.Text_IO;
|
||||
|
||||
procedure Abbreviations_Easy is
|
||||
|
||||
package Command_Vectors
|
||||
is new Ada.Containers.Indefinite_Vectors (Index_Type => Positive,
|
||||
Element_Type => String);
|
||||
use Command_Vectors;
|
||||
|
||||
Commands : Vector;
|
||||
|
||||
procedure Append (Word_List : String) is
|
||||
use Ada.Strings;
|
||||
First : Positive := Word_List'First;
|
||||
Last : Natural;
|
||||
begin
|
||||
loop
|
||||
Fixed.Find_Token (Word_List,
|
||||
Set => Maps.Constants.Letter_Set,
|
||||
From => First,
|
||||
Test => Inside,
|
||||
First => First,
|
||||
Last => Last);
|
||||
exit when Last = 0;
|
||||
Commands.Append (Word_List (First .. Last));
|
||||
exit when Last = Word_List'Last;
|
||||
First := Last + 1;
|
||||
end loop;
|
||||
end Append;
|
||||
|
||||
function Match (Word : String) return String is
|
||||
use Ada.Strings;
|
||||
use Ada.Characters.Handling;
|
||||
Upper_Word : constant String := To_Upper (Word);
|
||||
Prefix_First : Positive;
|
||||
Prefix_Last : Natural;
|
||||
begin
|
||||
if Word = "" then
|
||||
return "";
|
||||
end if;
|
||||
|
||||
for Command of Commands loop
|
||||
Fixed.Find_Token (Command, Maps.Constants.Upper_Set, Inside,
|
||||
Prefix_First, Prefix_Last);
|
||||
declare
|
||||
Upper_Prefix : constant String := Command (Prefix_First .. Prefix_Last);
|
||||
Upper_Command : constant String := To_Upper (Command);
|
||||
Valid_Length : constant Boolean := Word'Length >= Upper_Prefix'Length;
|
||||
Match_Length : constant Natural := Natural'Min (Word'Length,
|
||||
Command'Length);
|
||||
Valid_Match : constant Boolean
|
||||
:= Fixed.Head (Upper_Word, Upper_Word'Length)
|
||||
= Fixed.Head (Upper_Command, Upper_Word'Length);
|
||||
begin
|
||||
if Valid_Length and Valid_Match then
|
||||
return Upper_Command;
|
||||
end if;
|
||||
end;
|
||||
end loop;
|
||||
return "*error*";
|
||||
end Match;
|
||||
|
||||
procedure Put_Match (To : String) is
|
||||
use Ada.Text_IO;
|
||||
M : constant String := Match (To);
|
||||
begin
|
||||
Put ("Match to '"); Put (To);
|
||||
Put ("' is '"); Put (M);
|
||||
Put_Line ("'");
|
||||
end Put_Match;
|
||||
|
||||
procedure A (Item : String) renames Append;
|
||||
begin
|
||||
A ("Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy");
|
||||
A ("COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find");
|
||||
A ("NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput");
|
||||
A ("Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase LPrefix MACRO");
|
||||
A ("MErge MODify MOve MSG Next Overlay PARSE PREServe PURge PUT PUTD Query QUIT");
|
||||
A ("READ RECover REFRESH RENum REPeat Replace CReplace RESet RESTore RGTLEFT");
|
||||
A ("RIght LEft SAVE SET SHift SI SORT SOS STAck STATus TOP TRAnsfer Type Up");
|
||||
|
||||
Put_Match ("riG");
|
||||
Put_Match ("rePEAT");
|
||||
Put_Match ("copies");
|
||||
Put_Match ("put");
|
||||
Put_Match ("mo");
|
||||
Put_Match ("rest");
|
||||
Put_Match ("types");
|
||||
Put_Match ("fup.");
|
||||
Put_Match ("6");
|
||||
Put_Match ("poweRin");
|
||||
Put_Match ("");
|
||||
Put_Match ("o");
|
||||
end Abbreviations_Easy;
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
include std/text.e -- for upper conversion
|
||||
include std/console.e -- for display
|
||||
include std/sequence.e
|
||||
|
||||
sequence ct = """
|
||||
Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy
|
||||
COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find
|
||||
NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput
|
||||
Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase LPrefix MACRO
|
||||
MErge MODify MOve MSG Next Overlay PARSE PREServe PURge PUT PUTD Query QUIT
|
||||
READ RECover REFRESH RENum REPeat Replace CReplace RESet RESTore RGTLEFT
|
||||
RIght LEft SAVE SET SHift SI SORT SOS STAck STATus TOP TRAnsfer Type Up
|
||||
"""
|
||||
ct = upper(split(join(split(ct,"\n")," ")," "))
|
||||
|
||||
object input = remove_all("\n",upper(remove_all("",split(gets(0)))))
|
||||
display(validate(input))
|
||||
|
||||
-------------------------------
|
||||
function validate(object words)
|
||||
-------------------------------
|
||||
object results = repeat("*error*",length(words)) -- build an output list;
|
||||
integer x
|
||||
for i = 1 to length(words) do
|
||||
words[i] = remove_all('\n',words[i]) -- final word in input line (may) have \n, get rid of it;
|
||||
for j = 1 to length(ct) do
|
||||
x = match(words[i],ct[j])
|
||||
if x = 1 then
|
||||
results[i] = ct[j] -- replace this slot in the output list with the "found" word;
|
||||
exit -- and don't look further into the list;
|
||||
end if
|
||||
end for
|
||||
end for
|
||||
return flatten(join(results," ")) -- convert sequence of strings into one string, words separated by a single space;
|
||||
end function
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
<# Start with a string of the commands #>
|
||||
$cmdTableStr =
|
||||
"Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy
|
||||
COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find
|
||||
NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput
|
||||
Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase LPrefix MACRO
|
||||
MErge MODify MOve MSG Next Overlay PARSE PREServe PURge PUT PUTD Query QUIT
|
||||
READ RECover REFRESH RENum REPeat Replace CReplace RESet RESTore RGTLEFT
|
||||
RIght LEft SAVE SET SHift SI SORT SOS STAck STATus TOP TRAnsfer Type Up"
|
||||
<# String of inputs #>
|
||||
$userWordStr = "riG rePEAT copies put mo rest types fup. 6 poweRin"
|
||||
|
||||
$outputStr = $null # Set this string to null only so all variables are intialized
|
||||
|
||||
$cmdTabArray = @() # Arrays for the commands and the inputs
|
||||
$userWordArray = @()
|
||||
|
||||
<# Split the strings into arrays using a space as the delimiter.
|
||||
This also removes "blank" entries, which fits the requirement
|
||||
"A blank input (or a null input) should return a null string." #>
|
||||
$cmdTabArray = $cmdTableStr.Split(" ", [System.StringSplitOptions]::RemoveEmptyEntries)
|
||||
$userWordArray = $userWordStr.Split(" ", [System.StringSplitOptions]::RemoveEmptyEntries)
|
||||
|
||||
<# Begins a loop to iterate through the inputs #>
|
||||
foreach($word in $userWordArray)
|
||||
{
|
||||
$match = $false # Variable set to false so that if a match is never found, the "*error*" string can be appended
|
||||
foreach($cmd in $cmdTabArray)
|
||||
{
|
||||
<# This test: 1) ensures inputs match the leading characters of the command
|
||||
2) are abbreviations of the command
|
||||
3) the abbreviations is at least the number of capital characters in the command #>
|
||||
if($cmd -like "$word*" -and ($word.Length -ge ($cmd -creplace '[a-z]').Length))
|
||||
{
|
||||
$outputStr += $cmd.ToUpper() + " " # Adds the command in all caps to the output string
|
||||
$match = $true # Sets the variable so that "*error*" is not appended
|
||||
break # Break keep the loop from continuing and wasting time once a match was found
|
||||
}
|
||||
}
|
||||
if($match -eq $false){ $outputStr += "*error* " } # Appends error if no match was found
|
||||
}
|
||||
# Below lines display the input and output
|
||||
"User text: " + $userWordStr
|
||||
"Full text: " + $outputStr
|
||||
Loading…
Add table
Add a link
Reference in a new issue