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,19 +0,0 @@
with Ada.Containers.Indefinite_Vectors, Ada.Text_IO;
package String_Vectors is
package String_Vec is new Ada.Containers.Indefinite_Vectors
(Index_Type => Positive, Element_Type => String);
type Vec is new String_Vec.Vector with null record;
function Read(Filename: String) return Vec;
-- uses Ada.Text_IO to read words from the given file into a Vec
-- requirement: each word is written in a single line
function Is_In(List: Vec;
Word: String;
Start: Positive; Stop: Natural) return Boolean;
-- checks if Word is in List(Start .. Stop);
-- requirement: the words in List are sorted alphabetically
end String_Vectors;

View file

@ -1,35 +0,0 @@
package body String_Vectors is
function Is_In(List: Vec;
Word: String;
Start: Positive; Stop: Natural) return Boolean is
Middle: Positive;
begin
if Start > Stop then
return False;
else
Middle := (Start+Stop) / 2;
if List.Element(Middle) = Word then
return True;
elsif List.Element(Middle) < Word then
return List.Is_In(Word, Middle+1, Stop);
else
return List.Is_In(Word, Start, Middle-1);
end if;
end if;
end Is_In;
function Read(Filename: String) return Vec is
package IO renames Ada.Text_IO;
Persistent_List: IO.File_Type;
List: Vec;
begin
IO.Open(File => Persistent_List, Name => Filename, Mode => IO.In_File);
while not IO.End_Of_File(Persistent_List) loop
List.Append(New_Item => IO.Get_Line(Persistent_List));
end loop;
IO.Close(Persistent_List);
return List;
end Read;
end String_Vectors;

View file

@ -1,30 +0,0 @@
with String_Vectors, Ada.Text_IO, Ada.Command_Line;
procedure Semordnilap is
function Backward(S: String) return String is
begin
if S'Length < 2 then
return S;
else
return (S(S'Last) & Backward(S(S'First+1 .. S'Last-1)) & S(S'First));
end if;
end Backward;
W: String_Vectors.Vec := String_Vectors.Read(Ada.Command_Line.Argument(1));
Semi_Counter: Natural := 0;
begin
for I in W.First_Index .. W.Last_Index loop
if W.Element(I) /= Backward(W.Element(I)) and then
W.Is_In(Backward(W.Element(I)), W.First_Index, I) then
Semi_Counter := Semi_Counter + 1;
if Semi_Counter <= 5 then
Ada.Text_IO.Put_Line(W.Element(I) & " - " & Backward(W.Element(I)));
end if;
end if;
end loop;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put("pairs found:" & Integer'Image(Semi_Counter));
end Semordnilap;

View file

@ -1,4 +1,4 @@
words: read.lines "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"
words: read.lines relative "unixdict.txt"
pairs: []
loop words 'wrd [
if and? contains? words reverse wrd

View file

@ -1,35 +0,0 @@
function Reverse-String ([string]$String)
{
[char[]]$output = $String.ToCharArray()
[Array]::Reverse($output)
$output -join ""
}
[string]$url = "http://www.puzzlers.org/pub/wordlists/unixdict.txt"
[string]$out = ".\unixdict.txt"
(New-Object System.Net.WebClient).DownloadFile($url, $out)
[string[]]$file = Get-Content -Path $out
[hashtable]$unixDict = @{}
[hashtable]$semordnilap = @{}
foreach ($line in $file)
{
if ($line.Length -gt 1)
{
$unixDict.Add($line,"")
}
[string]$reverseLine = Reverse-String $line
if ($reverseLine -notmatch $line -and $unixDict.ContainsKey($reverseLine))
{
$semordnilap.Add($line,$reverseLine)
}
}
$semordnilap
"`nSemordnilap count: {0}" -f ($semordnilap.GetEnumerator() | Measure-Object).Count

View file

@ -1,26 +0,0 @@
Rebol [
title: "Rosetta code: Semordnilap"
file: %Semordnilap.r
url: https://rosettacode.org/wiki/Semordnilap
needs: 2.7.0
]
words: read/lines http://wiki.puzzlers.org/pub/wordlists/unixdict.txt
seen: make hash! 200
count: 0
print ["Number of input words: " length? words LF]
foreach word words [
reversed: reverse copy word
either find seen reversed [
count: count + 1
if count <= 5 [
print [word "is reversed:" reversed]
]
][
append seen word
]
]
print [LF "Found total" count "pairs."]

View file

@ -1,25 +0,0 @@
Rebol [
title: "Rosetta code: Semordnilap"
file: %Semordnilap.r3
url: https://rosettacode.org/wiki/Semordnilap
needs: 3.14.0
]
words: read/lines http://wiki.puzzlers.org/pub/wordlists/unixdict.txt
seen: make map! 200
count: 0
print ["Number of input words: " length? words LF]
foreach word words [
reversed: reverse copy word
either find seen reversed [
if ++ count <= 5 [
print [word "is reversed:" reversed]
]
][
put seen word reversed
]
]
print [LF "Found total" count "pairs."]

View file

@ -1,3 +1,4 @@
A ← map:⊚⧻.⊜□≠@\n.&fras"unixdict.txt"
▽:⟜≡(↧⊃(<⇌.|has⇌))⊙◌°map⟜¤A
&p$"Found _ semordnilaps:"⊸⧻
A ← map:⊚⧻.⊜□≠@\n.&fras"unixdict.txt"
Earlier ← >0˜⨂0≡≤⇌. # Would this sort before its reverse?
˜▽⟜≡(↧⊃(Earlier|has⇌)°□)⊙◌°map⟜¤A
&p$"Found _ semordnilaps:\n_"⊸⧻⍆

View file

@ -1,36 +0,0 @@
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInFile = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_
"\unixdict.txt",1)
Set objUnixDict = CreateObject("Scripting.Dictionary")
Set objSemordnilap = CreateObject("Scripting.Dictionary")
Do Until objInFile.AtEndOfStream
line = objInFile.ReadLine
If Len(line) > 1 Then
objUnixDict.Add line,""
End If
reverse_line = StrReverse(line)
If reverse_line <> line And objUnixDict.Exists(reverse_line) Then
objSemordnilap.Add line, reverse_line
End If
Loop
'Display the first 5 keys.
k = 0
For Each Key In objSemordnilap.Keys
WScript.StdOut.Write Key & " - " & objSemordnilap.Item(Key)
WScript.StdOut.WriteLine
k = k + 1
If k = 5 Then
Exit For
End If
Next
WScript.StdOut.Write "Total Count: " & objSemordnilap.Count
WScript.StdOut.WriteLine
objInFile.Close
Set objFSO = Nothing
Set objUnixDict = Nothing
Set objSemordnilap = Nothing