Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,32 +0,0 @@
|
|||
with Ada.Text_IO, Ada.Command_Line, String_Helper;
|
||||
|
||||
procedure Madlib is
|
||||
|
||||
use String_Helper;
|
||||
|
||||
Text: Vector := Get_Vector(Ada.Command_Line.Argument(1));
|
||||
M, N: Natural;
|
||||
|
||||
begin
|
||||
-- search for templates and modify the text accordingly
|
||||
for I in Text.First_Index .. Text.Last_Index loop
|
||||
loop
|
||||
Search_Brackets(Text.Element(I), "<", ">", M, N);
|
||||
exit when M=0; -- "M=0" means "not found"
|
||||
Ada.Text_IO.Put_Line("Replacement for " & Text.Element(I)(M .. N) & "?");
|
||||
declare
|
||||
Old: String := Text.Element(I)(M .. N);
|
||||
New_Word: String := Ada.Text_IO.Get_Line;
|
||||
begin
|
||||
for J in I .. Text.Last_Index loop
|
||||
Text.Replace_Element(J, Replace(Text.Element(J), Old, New_Word));
|
||||
end loop;
|
||||
end;
|
||||
end loop;
|
||||
end loop;
|
||||
|
||||
-- write the text
|
||||
for I in Text.First_Index .. Text.Last_Index loop
|
||||
Ada.Text_IO.Put_Line(Text.Element(I));
|
||||
end loop;
|
||||
end Madlib;
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
with Ada.Containers.Indefinite_Vectors;
|
||||
|
||||
package String_Helper is
|
||||
|
||||
function Index(Source: String; Pattern: String) return Natural;
|
||||
|
||||
procedure Search_Brackets(Source: String;
|
||||
Left_Bracket: String;
|
||||
Right_Bracket: String;
|
||||
First, Last: out Natural);
|
||||
-- returns indices of first pair of brackets in source
|
||||
-- indices are zero if no such brackets are found
|
||||
|
||||
function Replace(Source: String; Old_Word: String; New_Word: String)
|
||||
return String;
|
||||
|
||||
package String_Vec is new Ada.Containers.Indefinite_Vectors
|
||||
(Index_Type => Positive,
|
||||
Element_Type => String);
|
||||
|
||||
type Vector is new String_Vec.Vector with null record;
|
||||
|
||||
function Get_Vector(Filename: String) return Vector;
|
||||
|
||||
end String_Helper;
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
with Ada.Strings.Fixed, Ada.Text_IO;
|
||||
|
||||
package body String_Helper is
|
||||
|
||||
function Index(Source: String; Pattern: String) return Natural is
|
||||
begin
|
||||
return Ada.Strings.Fixed.Index(Source => Source, Pattern => Pattern);
|
||||
end Index;
|
||||
|
||||
procedure Search_Brackets(Source: String;
|
||||
Left_Bracket: String;
|
||||
Right_Bracket: String;
|
||||
First, Last: out Natural) is
|
||||
begin
|
||||
First := Index(Source, Left_Bracket);
|
||||
if First = 0 then
|
||||
Last := 0; -- not found
|
||||
else
|
||||
Last := Index(Source(First+1 .. Source'Last), Right_Bracket);
|
||||
if Last = 0 then
|
||||
First := 0; -- not found;
|
||||
end if;
|
||||
end if;
|
||||
end Search_Brackets;
|
||||
|
||||
function Replace(Source: String; Old_Word: String; New_Word: String)
|
||||
return String is
|
||||
L: Positive := Old_Word'Length;
|
||||
I: Natural := Index(Source, Old_Word);
|
||||
begin
|
||||
if I = 0 then
|
||||
return Source;
|
||||
else
|
||||
return Source(Source'First .. I-1) & New_Word
|
||||
& Replace(Source(I+L .. Source'Last), Old_Word, New_Word);
|
||||
end if;
|
||||
end Replace;
|
||||
|
||||
function Get_Vector(Filename: String) return Vector is
|
||||
F: Ada.Text_IO.File_Type;
|
||||
T: Vector;
|
||||
begin
|
||||
Ada.Text_IO.Open(F, Ada.Text_IO.In_File, Filename);
|
||||
while not Ada.Text_IO.End_Of_File(F) loop
|
||||
T.Append(Ada.Text_IO.Get_Line(F));
|
||||
end loop;
|
||||
Ada.Text_IO.Close(F);
|
||||
return T;
|
||||
end Get_Vector;
|
||||
|
||||
end String_Helper;
|
||||
|
|
@ -2,7 +2,7 @@ story: strip input "Enter a story: "
|
|||
vars: unique map match story {/\|([^\|]+)\|/} 'v -> replace v "|" ""
|
||||
|
||||
i: 0
|
||||
while [i < size vars].import [
|
||||
while [i < size vars] [
|
||||
let vars\[i] input ~"Enter value for <|vars\[i]|>: "
|
||||
i: i + 1
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
function New-MadLibs
|
||||
{
|
||||
[CmdletBinding(DefaultParameterSetName='None')]
|
||||
[OutputType([string])]
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[AllowEmptyString()]
|
||||
[string]
|
||||
$Name = "",
|
||||
|
||||
[Parameter(Mandatory=$false, ParameterSetName='Male')]
|
||||
[switch]
|
||||
$Male,
|
||||
|
||||
[Parameter(Mandatory=$false, ParameterSetName='Female')]
|
||||
[switch]
|
||||
$Female,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[AllowEmptyString()]
|
||||
[string]
|
||||
$Item = ""
|
||||
)
|
||||
|
||||
if (-not $Name)
|
||||
{
|
||||
$Name = (Get-Culture).TextInfo.ToTitleCase((Read-Host -Prompt "`nEnter a name").ToLower())
|
||||
}
|
||||
else
|
||||
{
|
||||
$Name = (Get-Culture).TextInfo.ToTitleCase(($Name).ToLower())
|
||||
}
|
||||
|
||||
if ($Male)
|
||||
{
|
||||
$pronoun = "He"
|
||||
}
|
||||
elseif ($Female)
|
||||
{
|
||||
$pronoun = "She"
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = "Gender"
|
||||
$message = "Select $Name's Gender"
|
||||
$_male = New-Object System.Management.Automation.Host.ChoiceDescription "&Male", "Selects male gender."
|
||||
$_female = New-Object System.Management.Automation.Host.ChoiceDescription "&Female", "Selects female gender."
|
||||
$options = [System.Management.Automation.Host.ChoiceDescription[]]($_male, $_female)
|
||||
$result = $host.UI.PromptForChoice($title, $message, $options, 0)
|
||||
|
||||
switch ($result)
|
||||
{
|
||||
0 {$pronoun = "He"}
|
||||
1 {$pronoun = "She"}
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $Item)
|
||||
{
|
||||
$Item = Read-Host -Prompt "`nEnter an item"
|
||||
}
|
||||
|
||||
"`n{0} went for a walk in the park. {1} found a {2}. {0} decided to take it home.`n" -f $Name, $pronoun, $Item
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
New-MadLibs -Name hank -Male -Item shank
|
||||
|
|
@ -1 +0,0 @@
|
|||
New-MadLibs
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
$paramLists = @(@{Name='mary'; Female=$true; Item="little lamb"},
|
||||
@{Name='hank'; Male=$true; Item="shank"},
|
||||
@{Name='foo'; Male=$true; Item="bar"})
|
||||
|
||||
foreach ($paramList in $paramLists)
|
||||
{
|
||||
New-MadLibs @paramList
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
t: {<name> went for a walk in the park. <he or she> found a <noun>. <name> decided to take it home.}
|
||||
view layout [a: area wrap t btn "Done" [x: a/text unview]]
|
||||
parse x [any [to "<" copy b thru ">" (append w: [] b)] to end]
|
||||
foreach i unique w [replace/all x i ask join i ": "] alert x
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
Function mad_libs(s)
|
||||
Do
|
||||
If InStr(1,s,"<") <> 0 Then
|
||||
start_position = InStr(1,s,"<") + 1
|
||||
end_position = InStr(1,s,">")
|
||||
parse_string = Mid(s,start_position,end_position-start_position)
|
||||
WScript.StdOut.Write parse_string & "? "
|
||||
input_string = WScript.StdIn.ReadLine
|
||||
s = Replace(s,"<" & parse_string & ">",input_string)
|
||||
Else
|
||||
Exit Do
|
||||
End If
|
||||
Loop
|
||||
mad_libs = s
|
||||
End Function
|
||||
|
||||
WScript.StdOut.Write mad_libs("<name> went for a walk in the park. <he or she> found a <noun>. <name> decided to take it home.")
|
||||
WScript.StdOut.WriteLine
|
||||
Loading…
Add table
Add a link
Reference in a new issue