Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -3,7 +3,7 @@ widely known mnemonic which is supposed to help when spelling English words.
|
|||
|
||||
|
||||
;Task:
|
||||
Using the word list from [http://wiki.puzzlers.org/pub/wordlists/unixdict.txt http://wiki.puzzlers.org/pub/wordlists/unixdict.txt],
|
||||
Using the word list from [https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt],
|
||||
<br>check if the two sub-clauses of the phrase are plausible individually:
|
||||
:::# ''"I before E when not preceded by C"''
|
||||
:::# ''"E before I when preceded by C"''
|
||||
|
|
|
|||
|
|
@ -1,207 +1,207 @@
|
|||
;;; I before E, except after C
|
||||
fcb1: equ 5Ch ; FCB 1 (populated by file on command line)
|
||||
dma: equ 80h ; Standard DMA location
|
||||
bdos: equ 5 ; CP/M entry point
|
||||
puts: equ 9 ; CP/M call to write a string to the console
|
||||
fopen: equ 0Fh ; CP/M call to open a file
|
||||
fread: equ 14h ; CP/M call to read from a file
|
||||
CR: equ 13
|
||||
LF: equ 10
|
||||
EOF: equ 26
|
||||
org 100h
|
||||
;;; Open the file given on the command line
|
||||
lxi d,fcb1
|
||||
mvi c,fopen
|
||||
call bdos
|
||||
inr a ; FF = error
|
||||
jz die
|
||||
;;; We can only read one 128-byte block at a time, and the file
|
||||
;;; will not fit in memory (max 64 k). So there are two things
|
||||
;;; going on here: we copy from the block into a word buffer
|
||||
;;; until we see the end of a line, at which point we process
|
||||
;;; the word. In the meantime, if while copying we reach the end
|
||||
;;; of the block, we read the next block.
|
||||
lxi b,curwrd ; Word pointer
|
||||
block: push b ; Keep word pointer while reading
|
||||
lxi d,fcb1 ; Read a block from the file
|
||||
mvi c,fread
|
||||
call bdos
|
||||
pop b ; Restore word pointer
|
||||
dcr a ; 1 = EOF
|
||||
jz done
|
||||
inr a ; otherwise, <>0 = error
|
||||
jnz die
|
||||
lxi h,dma ; Start reading at DMA
|
||||
char: mov a,m ; Get character
|
||||
cpi EOF ; If it's an EOF character, we're done
|
||||
jz done
|
||||
stax b ; Store character in current word
|
||||
inx b
|
||||
cpi LF ; If it's LF, then we've got a full word
|
||||
cz word ; Process the word
|
||||
inr l ; Go to next character
|
||||
jz block ; If we're done with this block, get next one
|
||||
jmp char
|
||||
;;; When done, report the statistics
|
||||
done: lxi d,scie ; CIE
|
||||
call sout
|
||||
lhld cie
|
||||
call puthl
|
||||
lxi d,sxie ; xIE
|
||||
call sout
|
||||
lhld xie
|
||||
call puthl
|
||||
lxi d,scei ; CEI
|
||||
call sout
|
||||
lhld cei
|
||||
call puthl
|
||||
lxi d,sxei ; xEI
|
||||
call sout
|
||||
lhld xei
|
||||
call puthl
|
||||
;;; Then say what is and isn't plausible
|
||||
lxi d,s_ienc ; I before E when not preceded by C
|
||||
call sout ; plausible if 2*xIE>CIE
|
||||
lhld cie
|
||||
xchg
|
||||
lhld xie
|
||||
call pplaus
|
||||
lxi d,s_eic ; E before I when preceded by C
|
||||
call sout ; plausible if 2*CEI>xEI
|
||||
lhld xei
|
||||
xchg
|
||||
lhld cei
|
||||
;;; If HL = amount of words with feature, and
|
||||
;;; DE = amount of words with opposit feature, then print
|
||||
;;; '(not) plausible', as appropriate.
|
||||
pplaus: dad h ; 2 * feature
|
||||
mov a,d ; Compare high byte
|
||||
cmp h
|
||||
jc plaus ; If 2*H>D then plausible
|
||||
mov a,e ; Otherwise, compare low byte
|
||||
cmp l
|
||||
jc plaus ; If 2*L>E then plausible
|
||||
lxi d,snop ; Otherwise, not plausible
|
||||
jmp sout
|
||||
plaus: lxi d,splau
|
||||
jmp sout
|
||||
;;; Process a word
|
||||
word: push h ; Save file read address
|
||||
xra a ; Zero out end of word
|
||||
stax b
|
||||
dcx b
|
||||
lxi h,curwrd ; Scan word
|
||||
start: mov a,m ; Get current character
|
||||
inx h ; Move pointer ahead
|
||||
ana a ; If zero,
|
||||
jz w_end ; we're done
|
||||
cpi 'c' ; Did we find a 'c'?
|
||||
jz findc
|
||||
cpi 'e' ; Otherwise, did we find 'e'?
|
||||
jz finde
|
||||
cpi 'i' ; Otherwise, did we find 'i'?
|
||||
jz findi
|
||||
jmp start ; Otherwise, keep going
|
||||
;;; We found an 'e'
|
||||
finde: mov a,m ; Get following character
|
||||
cpi 'i' ; Is it 'i'?
|
||||
jnz start ; If not, keep going
|
||||
inx h ; Otherwise, move past it,
|
||||
xchg ; keep pointer in DE,
|
||||
lhld xie ; We found ie without c
|
||||
inx h
|
||||
shld xie
|
||||
xchg
|
||||
jmp start
|
||||
;;; We found an 'i'
|
||||
findi: mov a,m ; Get following character
|
||||
cpi 'e' ; Is it 'e'?
|
||||
jnz start ; If not, keep going
|
||||
inx h ; Otherwise, move past it,
|
||||
xchg ; keep pointer in DE,
|
||||
lhld xei ; We found ei without c
|
||||
inx h
|
||||
shld xei
|
||||
xchg
|
||||
jmp start
|
||||
;;; We found a 'c'
|
||||
findc: mov a,m ; Get following character
|
||||
cpi 'e' ; Is it 'e'?
|
||||
jz findce ; Then we have 'ce'
|
||||
cpi 'i' ; Is it 'i'?
|
||||
jz findci ; Then we have 'ci'
|
||||
jmp start ; Otherwise, just keep going
|
||||
findce: mov d,h ; set DE = start of 'e?'
|
||||
mov e,l
|
||||
inx d ; Get next character
|
||||
ldax d
|
||||
cpi 'i' ; Is it 'i'?
|
||||
jnz start ; If not, do nothing
|
||||
lhld cei ; But if so, we found 'cei'
|
||||
inx h ; Increment the counter
|
||||
shld cei
|
||||
xchg ; Keep scanning _after_ the 'cei'
|
||||
inx h
|
||||
jmp start
|
||||
findci: mov d,h ; set DE = start of 'i?'
|
||||
mov e,l
|
||||
inx d ; Get next character
|
||||
ldax d
|
||||
cpi 'e' ; Is it 'e'?
|
||||
jnz start ; If not, do nothing
|
||||
lhld cie ; But if so, we found 'cie'
|
||||
inx h ; Increment the counter
|
||||
shld cie
|
||||
xchg ; Keep scanning _after_ the 'cie'
|
||||
inx h
|
||||
jmp start
|
||||
w_end: lxi b,curwrd ; Set word pointer to beginning
|
||||
pop h ; Restore file read address
|
||||
ret
|
||||
;;; Print error message and stop the program
|
||||
die: lxi d,errmsg
|
||||
mvi c,puts
|
||||
call bdos
|
||||
rst 0
|
||||
;;; Print string
|
||||
sout: mvi c,puts
|
||||
jmp bdos
|
||||
;;; Print HL to the console as a decimal number
|
||||
puthl: push h
|
||||
lxi h,num
|
||||
xthl
|
||||
lxi b,-10
|
||||
dgt: lxi d,-1
|
||||
clcdgt: inx d
|
||||
dad b
|
||||
jc clcdgt
|
||||
mov a,l
|
||||
adi 10+'0'
|
||||
xthl
|
||||
dcx h
|
||||
mov m,a
|
||||
xthl
|
||||
xchg
|
||||
mov a,h
|
||||
ora l
|
||||
jnz dgt
|
||||
pop d
|
||||
mvi c,puts
|
||||
jmp bdos
|
||||
errmsg: db 'Error$' ; Good enough
|
||||
s_ienc: db 'I before E when not preceded by C:$'
|
||||
s_eic: db 'E before I when preceded by C:$'
|
||||
snop: db ' not'
|
||||
splau: db ' plausible',CR,LF,'$'
|
||||
scie: db 'CIE: $' ; Report strings
|
||||
sxie: db 'xIE: $'
|
||||
scei: db 'CEI: $'
|
||||
sxei: db 'xEI: $'
|
||||
db '00000'
|
||||
num: db CR,LF,'$' ; Space for number
|
||||
;;; Counters
|
||||
xie: dw 0 ; I before E when not preceded by C
|
||||
cie: dw 0 ; I before E when preceded by C
|
||||
cei: dw 0 ; E before I when preceded by C
|
||||
xei: dw 0 ; E before I when not preceded by C
|
||||
curwrd: equ $ ; Current word stored here
|
||||
;;; I before E, except after C
|
||||
fcb1: equ 5Ch ; FCB 1 (populated by file on command line)
|
||||
dma: equ 80h ; Standard DMA location
|
||||
bdos: equ 5 ; CP/M entry point
|
||||
puts: equ 9 ; CP/M call to write a string to the console
|
||||
fopen: equ 0Fh ; CP/M call to open a file
|
||||
fread: equ 14h ; CP/M call to read from a file
|
||||
CR: equ 13
|
||||
LF: equ 10
|
||||
EOF: equ 26
|
||||
org 100h
|
||||
;;; Open the file given on the command line
|
||||
lxi d,fcb1
|
||||
mvi c,fopen
|
||||
call bdos
|
||||
inr a ; FF = error
|
||||
jz die
|
||||
;;; We can only read one 128-byte block at a time, and the file
|
||||
;;; will not fit in memory (max 64 k). So there are two things
|
||||
;;; going on here: we copy from the block into a word buffer
|
||||
;;; until we see the end of a line, at which point we process
|
||||
;;; the word. In the meantime, if while copying we reach the end
|
||||
;;; of the block, we read the next block.
|
||||
lxi b,curwrd ; Word pointer
|
||||
block: push b ; Keep word pointer while reading
|
||||
lxi d,fcb1 ; Read a block from the file
|
||||
mvi c,fread
|
||||
call bdos
|
||||
pop b ; Restore word pointer
|
||||
dcr a ; 1 = EOF
|
||||
jz done
|
||||
inr a ; otherwise, <>0 = error
|
||||
jnz die
|
||||
lxi h,dma ; Start reading at DMA
|
||||
char: mov a,m ; Get character
|
||||
cpi EOF ; If it's an EOF character, we're done
|
||||
jz done
|
||||
stax b ; Store character in current word
|
||||
inx b
|
||||
cpi LF ; If it's LF, then we've got a full word
|
||||
cz word ; Process the word
|
||||
inr l ; Go to next character
|
||||
jz block ; If we're done with this block, get next one
|
||||
jmp char
|
||||
;;; When done, report the statistics
|
||||
done: lxi d,scie ; CIE
|
||||
call sout
|
||||
lhld cie
|
||||
call puthl
|
||||
lxi d,sxie ; xIE
|
||||
call sout
|
||||
lhld xie
|
||||
call puthl
|
||||
lxi d,scei ; CEI
|
||||
call sout
|
||||
lhld cei
|
||||
call puthl
|
||||
lxi d,sxei ; xEI
|
||||
call sout
|
||||
lhld xei
|
||||
call puthl
|
||||
;;; Then say what is and isn't plausible
|
||||
lxi d,s_ienc ; I before E when not preceded by C
|
||||
call sout ; plausible if 2*xIE>CIE
|
||||
lhld cie
|
||||
xchg
|
||||
lhld xie
|
||||
call pplaus
|
||||
lxi d,s_eic ; E before I when preceded by C
|
||||
call sout ; plausible if 2*CEI>xEI
|
||||
lhld xei
|
||||
xchg
|
||||
lhld cei
|
||||
;;; If HL = amount of words with feature, and
|
||||
;;; DE = amount of words with opposit feature, then print
|
||||
;;; '(not) plausible', as appropriate.
|
||||
pplaus: dad h ; 2 * feature
|
||||
mov a,d ; Compare high byte
|
||||
cmp h
|
||||
jc plaus ; If 2*H>D then plausible
|
||||
mov a,e ; Otherwise, compare low byte
|
||||
cmp l
|
||||
jc plaus ; If 2*L>E then plausible
|
||||
lxi d,snop ; Otherwise, not plausible
|
||||
jmp sout
|
||||
plaus: lxi d,splau
|
||||
jmp sout
|
||||
;;; Process a word
|
||||
word: push h ; Save file read address
|
||||
xra a ; Zero out end of word
|
||||
stax b
|
||||
dcx b
|
||||
lxi h,curwrd ; Scan word
|
||||
start: mov a,m ; Get current character
|
||||
inx h ; Move pointer ahead
|
||||
ana a ; If zero,
|
||||
jz w_end ; we're done
|
||||
cpi 'c' ; Did we find a 'c'?
|
||||
jz findc
|
||||
cpi 'e' ; Otherwise, did we find 'e'?
|
||||
jz finde
|
||||
cpi 'i' ; Otherwise, did we find 'i'?
|
||||
jz findi
|
||||
jmp start ; Otherwise, keep going
|
||||
;;; We found an 'e'
|
||||
finde: mov a,m ; Get following character
|
||||
cpi 'i' ; Is it 'i'?
|
||||
jnz start ; If not, keep going
|
||||
inx h ; Otherwise, move past it,
|
||||
xchg ; keep pointer in DE,
|
||||
lhld xie ; We found ie without c
|
||||
inx h
|
||||
shld xie
|
||||
xchg
|
||||
jmp start
|
||||
;;; We found an 'i'
|
||||
findi: mov a,m ; Get following character
|
||||
cpi 'e' ; Is it 'e'?
|
||||
jnz start ; If not, keep going
|
||||
inx h ; Otherwise, move past it,
|
||||
xchg ; keep pointer in DE,
|
||||
lhld xei ; We found ei without c
|
||||
inx h
|
||||
shld xei
|
||||
xchg
|
||||
jmp start
|
||||
;;; We found a 'c'
|
||||
findc: mov a,m ; Get following character
|
||||
cpi 'e' ; Is it 'e'?
|
||||
jz findce ; Then we have 'ce'
|
||||
cpi 'i' ; Is it 'i'?
|
||||
jz findci ; Then we have 'ci'
|
||||
jmp start ; Otherwise, just keep going
|
||||
findce: mov d,h ; set DE = start of 'e?'
|
||||
mov e,l
|
||||
inx d ; Get next character
|
||||
ldax d
|
||||
cpi 'i' ; Is it 'i'?
|
||||
jnz start ; If not, do nothing
|
||||
lhld cei ; But if so, we found 'cei'
|
||||
inx h ; Increment the counter
|
||||
shld cei
|
||||
xchg ; Keep scanning _after_ the 'cei'
|
||||
inx h
|
||||
jmp start
|
||||
findci: mov d,h ; set DE = start of 'i?'
|
||||
mov e,l
|
||||
inx d ; Get next character
|
||||
ldax d
|
||||
cpi 'e' ; Is it 'e'?
|
||||
jnz start ; If not, do nothing
|
||||
lhld cie ; But if so, we found 'cie'
|
||||
inx h ; Increment the counter
|
||||
shld cie
|
||||
xchg ; Keep scanning _after_ the 'cie'
|
||||
inx h
|
||||
jmp start
|
||||
w_end: lxi b,curwrd ; Set word pointer to beginning
|
||||
pop h ; Restore file read address
|
||||
ret
|
||||
;;; Print error message and stop the program
|
||||
die: lxi d,errmsg
|
||||
mvi c,puts
|
||||
call bdos
|
||||
rst 0
|
||||
;;; Print string
|
||||
sout: mvi c,puts
|
||||
jmp bdos
|
||||
;;; Print HL to the console as a decimal number
|
||||
puthl: push h
|
||||
lxi h,num
|
||||
xthl
|
||||
lxi b,-10
|
||||
dgt: lxi d,-1
|
||||
clcdgt: inx d
|
||||
dad b
|
||||
jc clcdgt
|
||||
mov a,l
|
||||
adi 10+'0'
|
||||
xthl
|
||||
dcx h
|
||||
mov m,a
|
||||
xthl
|
||||
xchg
|
||||
mov a,h
|
||||
ora l
|
||||
jnz dgt
|
||||
pop d
|
||||
mvi c,puts
|
||||
jmp bdos
|
||||
errmsg: db 'Error$' ; Good enough
|
||||
s_ienc: db 'I before E when not preceded by C:$'
|
||||
s_eic: db 'E before I when preceded by C:$'
|
||||
snop: db ' not'
|
||||
splau: db ' plausible',CR,LF,'$'
|
||||
scie: db 'CIE: $' ; Report strings
|
||||
sxie: db 'xIE: $'
|
||||
scei: db 'CEI: $'
|
||||
sxei: db 'xEI: $'
|
||||
db '00000'
|
||||
num: db CR,LF,'$' ; Space for number
|
||||
;;; Counters
|
||||
xie: dw 0 ; I before E when not preceded by C
|
||||
cie: dw 0 ; I before E when preceded by C
|
||||
cei: dw 0 ; E before I when preceded by C
|
||||
xei: dw 0 ; E before I when not preceded by C
|
||||
curwrd: equ $ ; Current word stored here
|
||||
|
|
|
|||
|
|
@ -7,20 +7,20 @@
|
|||
/cie/ {cie+=cnt($3)}
|
||||
|
||||
function cnt(c) {
|
||||
if (c<1) return 1;
|
||||
return c;
|
||||
if (c<1) return 1;
|
||||
return c;
|
||||
}
|
||||
|
||||
END {
|
||||
printf("cie: %i\nnie: %i\ncei: %i\nnei: %i\n",cie,nie-cie,cei,nei-cei);
|
||||
v = v2 = "";
|
||||
if (nie < 3 * cie) {
|
||||
v =" not";
|
||||
}
|
||||
print "I before E when not preceded by C: is"v" plausible";
|
||||
if (nei > 3 * cei) {
|
||||
v = v2 =" not";
|
||||
}
|
||||
print "E before I when preceded by C: is"v2" plausible";
|
||||
printf("cie: %i\nnie: %i\ncei: %i\nnei: %i\n",cie,nie-cie,cei,nei-cei);
|
||||
v = v2 = "";
|
||||
if (nie < 3 * cie) {
|
||||
v =" not";
|
||||
}
|
||||
print "I before E when not preceded by C: is"v" plausible";
|
||||
if (nei > 3 * cei) {
|
||||
v = v2 =" not";
|
||||
}
|
||||
print "E before I when preceded by C: is"v2" plausible";
|
||||
print "Overall rule is"v" plausible";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
WordList := URL_ToVar("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")
|
||||
WordList := URL_ToVar("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")
|
||||
WordList := RegExReplace(WordList, "i)cie", "", cieN)
|
||||
WordList := RegExReplace(WordList, "i)cei", "", ceiN)
|
||||
RegExReplace(WordList, "i)ie", "", ieN)
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ CI = 0 : XI = 0 : CE = 0 : XE = 0
|
|||
open 1, "unixdict.txt"
|
||||
|
||||
do
|
||||
pal$ = readline (1)
|
||||
if instr(pal$, "ie") then
|
||||
if instr(pal$, "cie") then CI += 1 else XI += 1
|
||||
endif
|
||||
if instr(pal$, "ei") then
|
||||
if instr(pal$, "cei") then CE += 1 else XE += 1
|
||||
endif
|
||||
pal$ = readline (1)
|
||||
if instr(pal$, "ie") then
|
||||
if instr(pal$, "cie") then CI += 1 else XI += 1
|
||||
endif
|
||||
if instr(pal$, "ei") then
|
||||
if instr(pal$, "cei") then CE += 1 else XE += 1
|
||||
endif
|
||||
until eof(1)
|
||||
close 1
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
::Initialization
|
||||
::Initialization
|
||||
set ie=0
|
||||
set ei=0
|
||||
set cie=0
|
||||
|
|
@ -13,13 +13,13 @@ set propos1=FALSE
|
|||
set propos2=FALSE
|
||||
set propos3=FALSE
|
||||
|
||||
::Do the matching
|
||||
::Do the matching
|
||||
for /f %%X in (unixdict.txt) do (
|
||||
set word=%%X
|
||||
if not "!word:ie=!"=="!word!" if "!word:cie=!"=="!word!" (set /a ie+=1)
|
||||
if not "!word:ei=!"=="!word!" if "!word:cei=!"=="!word!" (set /a ei+=1)
|
||||
if not "!word:cei=!"=="!word!" (set /a cei+=1)
|
||||
if not "!word:cie=!"=="!word!" (set /a cie+=1)
|
||||
set word=%%X
|
||||
if not "!word:ie=!"=="!word!" if "!word:cie=!"=="!word!" (set /a ie+=1)
|
||||
if not "!word:ei=!"=="!word!" if "!word:cei=!"=="!word!" (set /a ei+=1)
|
||||
if not "!word:cei=!"=="!word!" (set /a cei+=1)
|
||||
if not "!word:cie=!"=="!word!" (set /a cie+=1)
|
||||
)
|
||||
|
||||
set /a "counter1=!ei!*2,counter2=!cie!*2"
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
format-line)))
|
||||
|
||||
(defn -main []
|
||||
(with-open [rdr (clojure.java.io/reader "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")]
|
||||
(with-open [rdr (clojure.java.io/reader "https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")]
|
||||
(i-before-e-except-after-c-plausible? "Check unixdist list" (apply-freq-1 (line-seq rdr))))
|
||||
(with-open [rdr (clojure.java.io/reader "http://ucrel.lancs.ac.uk/bncfreq/lists/1_2_all_freq.txt")]
|
||||
(i-before-e-except-after-c-plausible? "Word frequencies (stretch goal)" (map format-freq-line (drop 1 (line-seq rdr))))))
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ void local fn CheckWord( wrd as CFStringRef, txt as CFStringRef, c as ^long, x a
|
|||
end fn
|
||||
|
||||
void local fn Doit
|
||||
CFURLRef url = fn URLWithString( @"http://wiki.puzzlers.org/pub/wordlists/unixdict.txt" )
|
||||
CFURLRef url = fn URLWithString( @"https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt" )
|
||||
CFStringRef string = fn StringWithContentsOfURL( url, NSUTF8StringEncoding, NULL )
|
||||
CFArrayRef words = fn StringComponentsSeparatedByCharactersInSet( string, fn CharacterSetNewlineSet )
|
||||
long cei = 0, cie = 0, xei = 0, xie = 0
|
||||
|
|
|
|||
|
|
@ -1,68 +1,68 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
f, err := os.Open("unixdict.txt")
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
defer f.Close()
|
||||
f, err := os.Open("unixdict.txt")
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
s := bufio.NewScanner(f)
|
||||
rie := regexp.MustCompile("^ie|[^c]ie")
|
||||
rei := regexp.MustCompile("^ei|[^c]ei")
|
||||
var cie, ie int
|
||||
var cei, ei int
|
||||
for s.Scan() {
|
||||
line := s.Text()
|
||||
if strings.Contains(line, "cie") {
|
||||
cie++
|
||||
}
|
||||
if strings.Contains(line, "cei") {
|
||||
cei++
|
||||
}
|
||||
if rie.MatchString(line) {
|
||||
ie++
|
||||
}
|
||||
if rei.MatchString(line) {
|
||||
ei++
|
||||
}
|
||||
}
|
||||
err = s.Err()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
s := bufio.NewScanner(f)
|
||||
rie := regexp.MustCompile("^ie|[^c]ie")
|
||||
rei := regexp.MustCompile("^ei|[^c]ei")
|
||||
var cie, ie int
|
||||
var cei, ei int
|
||||
for s.Scan() {
|
||||
line := s.Text()
|
||||
if strings.Contains(line, "cie") {
|
||||
cie++
|
||||
}
|
||||
if strings.Contains(line, "cei") {
|
||||
cei++
|
||||
}
|
||||
if rie.MatchString(line) {
|
||||
ie++
|
||||
}
|
||||
if rei.MatchString(line) {
|
||||
ei++
|
||||
}
|
||||
}
|
||||
err = s.Err()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
if check(ie, ei, "I before E when not preceded by C") &&
|
||||
check(cei, cie, "E before I when preceded by C") {
|
||||
fmt.Println("Both plausable.")
|
||||
fmt.Println(`"I before E, except after C" is plausable.`)
|
||||
} else {
|
||||
fmt.Println("One or both implausable.")
|
||||
fmt.Println(`"I before E, except after C" is implausable.`)
|
||||
}
|
||||
if check(ie, ei, "I before E when not preceded by C") &&
|
||||
check(cei, cie, "E before I when preceded by C") {
|
||||
fmt.Println("Both plausable.")
|
||||
fmt.Println(`"I before E, except after C" is plausable.`)
|
||||
} else {
|
||||
fmt.Println("One or both implausable.")
|
||||
fmt.Println(`"I before E, except after C" is implausable.`)
|
||||
}
|
||||
}
|
||||
|
||||
// check checks if a statement is plausible. Something is plausible if a is more
|
||||
// than two times b.
|
||||
func check(a, b int, s string) bool {
|
||||
switch {
|
||||
case a > b*2:
|
||||
fmt.Printf("%q is plausible (%d vs %d).\n", s, a, b)
|
||||
return true
|
||||
case a >= b:
|
||||
fmt.Printf("%q is implausible (%d vs %d).\n", s, a, b)
|
||||
default:
|
||||
fmt.Printf("%q is implausible and contra-indicated (%d vs %d).\n",
|
||||
s, a, b)
|
||||
}
|
||||
return false
|
||||
switch {
|
||||
case a > b*2:
|
||||
fmt.Printf("%q is plausible (%d vs %d).\n", s, a, b)
|
||||
return true
|
||||
case a >= b:
|
||||
fmt.Printf("%q is implausible (%d vs %d).\n", s, a, b)
|
||||
default:
|
||||
fmt.Printf("%q is implausible and contra-indicated (%d vs %d).\n",
|
||||
s, a, b)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ getWordList :: IO String
|
|||
getWordList = do
|
||||
response <- simpleHTTP.getRequest$ url
|
||||
getResponseBody response
|
||||
where url = "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"
|
||||
where url = "https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"
|
||||
|
||||
main = do
|
||||
words <- getWordList
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import Utils # To get the FindFirst class
|
||||
import Utils # To get the FindFirst class
|
||||
|
||||
procedure main(a)
|
||||
showCounts := "--showcounts" == !a
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import Utils # To get the FindFirst class
|
||||
import Utils # To get the FindFirst class
|
||||
|
||||
procedure main(a)
|
||||
WS := " \t"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ static int cei = 0;
|
|||
static int cie = 0;
|
||||
|
||||
static void count() throws URISyntaxException, IOException {
|
||||
URL url = new URI("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").toURL();
|
||||
URL url = new URI("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").toURL();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
|
|
|
|||
|
|
@ -3,56 +3,56 @@ import java.io.FileReader;
|
|||
|
||||
public class IbeforeE
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
IbeforeE now=new IbeforeE();
|
||||
String wordlist="unixdict.txt";
|
||||
if(now.isPlausibleRule(wordlist))
|
||||
System.out.println("Rule is plausible.");
|
||||
else
|
||||
System.out.println("Rule is not plausible.");
|
||||
}
|
||||
boolean isPlausibleRule(String filename)
|
||||
{
|
||||
int truecount=0,falsecount=0;
|
||||
try
|
||||
{
|
||||
BufferedReader br=new BufferedReader(new FileReader(filename));
|
||||
String word;
|
||||
while((word=br.readLine())!=null)
|
||||
{
|
||||
if(isPlausibleWord(word))
|
||||
truecount++;
|
||||
else if(isOppPlausibleWord(word))
|
||||
falsecount++;
|
||||
}
|
||||
br.close();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
System.out.println("Something went horribly wrong: "+e.getMessage());
|
||||
}
|
||||
|
||||
System.out.println("Plausible count: "+truecount);
|
||||
System.out.println("Implausible count: "+falsecount);
|
||||
if(truecount>2*falsecount)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
boolean isPlausibleWord(String word)
|
||||
{
|
||||
if(!word.contains("c")&&word.contains("ie"))
|
||||
return true;
|
||||
else if(word.contains("cei"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
boolean isOppPlausibleWord(String word)
|
||||
{
|
||||
if(!word.contains("c")&&word.contains("ei"))
|
||||
return true;
|
||||
else if(word.contains("cie"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public static void main(String[] args)
|
||||
{
|
||||
IbeforeE now=new IbeforeE();
|
||||
String wordlist="unixdict.txt";
|
||||
if(now.isPlausibleRule(wordlist))
|
||||
System.out.println("Rule is plausible.");
|
||||
else
|
||||
System.out.println("Rule is not plausible.");
|
||||
}
|
||||
boolean isPlausibleRule(String filename)
|
||||
{
|
||||
int truecount=0,falsecount=0;
|
||||
try
|
||||
{
|
||||
BufferedReader br=new BufferedReader(new FileReader(filename));
|
||||
String word;
|
||||
while((word=br.readLine())!=null)
|
||||
{
|
||||
if(isPlausibleWord(word))
|
||||
truecount++;
|
||||
else if(isOppPlausibleWord(word))
|
||||
falsecount++;
|
||||
}
|
||||
br.close();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
System.out.println("Something went horribly wrong: "+e.getMessage());
|
||||
}
|
||||
|
||||
System.out.println("Plausible count: "+truecount);
|
||||
System.out.println("Implausible count: "+falsecount);
|
||||
if(truecount>2*falsecount)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
boolean isPlausibleWord(String word)
|
||||
{
|
||||
if(!word.contains("c")&&word.contains("ie"))
|
||||
return true;
|
||||
else if(word.contains("cei"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
boolean isOppPlausibleWord(String word)
|
||||
{
|
||||
if(!word.contains("c")&&word.contains("ei"))
|
||||
return true;
|
||||
else if(word.contains("cie"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ fun printResults(source: String, counts: IntArray) {
|
|||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val url = URL("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")
|
||||
val url = URL("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")
|
||||
val isr = InputStreamReader(url.openStream())
|
||||
val reader = BufferedReader(isr)
|
||||
val regexes = arrayOf(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
val words = less(split(readfile("./data/unixdict.txt"), by="\n"), of=1)
|
||||
val words = less(split(readfile("./data/unixdict.txt"), delim="\n"), of=1)
|
||||
|
||||
val print = fn*(support, against) {
|
||||
val print = fn*(support number, against number) {
|
||||
val ratio = support / against
|
||||
writeln "{{support}} / {{against}} = {{ratio : r2}}:", (ratio < 2) * " NOT", " PLAUSIBLE"
|
||||
return if(ratio >= 2: 1; 0)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ local(cie,cei,ie,ei) = (:0,0,0,0)
|
|||
local(match_ie) = regExp(`[^c]ie`)
|
||||
local(match_ei) = regExp(`[^c]ei`)
|
||||
|
||||
with word in include_url(`http://wiki.puzzlers.org/pub/wordlists/unixdict.txt`)->asString->split("\n")
|
||||
with word in include_url(`https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt`)->asString->split("\n")
|
||||
where #word >> `ie` or #word >> `ei`
|
||||
do {
|
||||
#word >> `cie`
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ function plaus (case, opposite, words)
|
|||
end
|
||||
|
||||
-- Main procedure
|
||||
local page = http.request("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")
|
||||
local page = http.request("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")
|
||||
io.write("I before E when not preceded by C: ")
|
||||
local sub1 = plaus("[^c]ie", "cie", page)
|
||||
io.write("E before I when preceded by C: ")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
function iBeforeE()
|
||||
check('http://wiki.puzzlers.org/pub/wordlists/unixdict.txt');
|
||||
check('https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt');
|
||||
fprintf('\n');
|
||||
check('http://ucrel.lancs.ac.uk/bncfreq/lists/1_2_all_freq.txt');
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
words:= HTTP:-Get("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"):
|
||||
words:= HTTP:-Get("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"):
|
||||
lst := StringTools:-Split(words[2],"\n"):
|
||||
xie, cie, cei, xei := 0, 0, 0, 0:
|
||||
for item in lst do
|
||||
if searchtext("ie", item) <> 0 then
|
||||
if searchtext("cie", item) <> 0 then
|
||||
cie := cie + 1:
|
||||
else
|
||||
xie := xie + 1:
|
||||
fi:
|
||||
fi:
|
||||
if searchtext("ei", item) <> 0 then
|
||||
if searchtext("cei", item) <> 0 then
|
||||
cei := cei + 1:
|
||||
else
|
||||
xei := xei + 1:
|
||||
fi:
|
||||
fi:
|
||||
od:
|
||||
if searchtext("ie", item) <> 0 then
|
||||
if searchtext("cie", item) <> 0 then
|
||||
cie := cie + 1:
|
||||
else
|
||||
xie := xie + 1:
|
||||
fi:
|
||||
fi:
|
||||
if searchtext("ei", item) <> 0 then
|
||||
if searchtext("cei", item) <> 0 then
|
||||
cei := cei + 1:
|
||||
else
|
||||
xei := xei + 1:
|
||||
fi:
|
||||
fi:
|
||||
od:
|
||||
p1, p2 := evalb(xie > 2*xei),evalb(cei > 2*cie);
|
||||
printf("The first phrase is %s with supporting features %d, anti features %d\n", piecewise(p1, "plausible", "not plausible"), xie, xei);
|
||||
printf("The seond phrase is %s with supporting features %d, anti features %d\n", piecewise(p2, "plausible", "not plausible"), cei, cie);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
wordlist =
|
||||
Import["http://wiki.puzzlers.org/pub/wordlists/unixdict.txt",
|
||||
Import["https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt",
|
||||
"Words"];
|
||||
Print["The number of words in unixdict.txt = " <>
|
||||
ToString[Length[wordlist]]]
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ proc plausibility(rule: string; count1, count2: int): bool =
|
|||
let client = newHttpClient()
|
||||
|
||||
var nie, cie, nei, cei = 0
|
||||
for word in client.getContent("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").split():
|
||||
for word in client.getContent("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").split():
|
||||
if word.contains("ie"):
|
||||
if word.contains("cie"):
|
||||
inc cie
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use Collection;
|
|||
|
||||
class HttpTest {
|
||||
function : Main(args : String[]) ~ Nil {
|
||||
IsPlausibleRule("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt");
|
||||
IsPlausibleRule("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt");
|
||||
}
|
||||
|
||||
function : PlausibilityCheck(comment : String, x : Int, y : Int) ~ Bool {
|
||||
|
|
|
|||
|
|
@ -6,27 +6,27 @@ cei = 0;
|
|||
nie = 0;
|
||||
cie = 0;
|
||||
while ~feof(fid)
|
||||
c = strsplit(strtrim(fgetl(fid)),char([9,32]));
|
||||
if length(c) > 2,
|
||||
n = str2num(c{3});
|
||||
else
|
||||
n = 1;
|
||||
end;
|
||||
if strfind(c{1},'ei')>1, nei=nei+n; end;
|
||||
if strfind(c{1},'cei'), cei=cei+n; end;
|
||||
if strfind(c{1},'ie')>1, nie=nie+n; end;
|
||||
if strfind(c{1},'cie'), cie=cie+n; end;
|
||||
c = strsplit(strtrim(fgetl(fid)),char([9,32]));
|
||||
if length(c) > 2,
|
||||
n = str2num(c{3});
|
||||
else
|
||||
n = 1;
|
||||
end;
|
||||
if strfind(c{1},'ei')>1, nei=nei+n; end;
|
||||
if strfind(c{1},'cei'), cei=cei+n; end;
|
||||
if strfind(c{1},'ie')>1, nie=nie+n; end;
|
||||
if strfind(c{1},'cie'), cie=cie+n; end;
|
||||
end;
|
||||
fclose(fid);
|
||||
|
||||
printf('cie: %i\nnie: %i\ncei: %i\nnei: %i\n',cie,nie-cie,cei,nei-cei);
|
||||
v = '';
|
||||
if (nie < 3 * cie)
|
||||
v=' not';
|
||||
v=' not';
|
||||
end
|
||||
printf('I before E when not preceded by C: is%s plausible\n',v);
|
||||
v = '';
|
||||
if (nei > 3 * cei)
|
||||
v=' not';
|
||||
v=' not';
|
||||
end
|
||||
printf('E before I when preceded by C: is%s plausible\n',v);
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
$Web = New-Object -TypeName Net.Webclient
|
||||
$Words = $web.DownloadString('http://wiki.puzzlers.org/pub/wordlists/unixdict.txt')
|
||||
|
||||
$IE = $EI = $CIE = $CEI = @()
|
||||
|
||||
$Clause1 = $Clause2 = $MainClause = $false
|
||||
|
||||
foreach ($Word in $Words.split())
|
||||
{
|
||||
switch ($Word)
|
||||
{
|
||||
{($_ -like '*ie*') -and ($_ -notlike '*cie*')} {$IE += $Word}
|
||||
{($_ -like '*ei*') -and ($_ -notlike '*cei*')} {$EI += $Word}
|
||||
{$_ -like '*cei*'} {$CEI += $Word}
|
||||
{$_ -like '*cie*'} {$CIE += $Word}
|
||||
}
|
||||
}
|
||||
|
||||
if ($IE.count -gt $EI.count * 2)
|
||||
{$Clause1 = $true}
|
||||
"The plausibility of 'I before E when not preceded by C' is $Clause1"
|
||||
|
||||
if ($CEI.count -gt $CIE.count * 2)
|
||||
{$Clause2 = $true}
|
||||
"The plausibility of 'E before I when preceded by C' is $Clause2"
|
||||
|
||||
if ($Clause1 -and $Clause2)
|
||||
{$MainClause = $True}
|
||||
"The plausibility of the phrase 'I before E except after C' is $MainClause"
|
||||
|
|
@ -17,7 +17,7 @@ def plausibility_check(comment, x, y):
|
|||
% (x, y, x / y))
|
||||
return x > PLAUSIBILITY_RATIO * y
|
||||
|
||||
def simple_stats(url='http://wiki.puzzlers.org/pub/wordlists/unixdict.txt'):
|
||||
def simple_stats(url='https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt'):
|
||||
words = urllib.request.urlopen(url).read().decode().lower().split()
|
||||
cie = len({word for word in words if 'cie' in word})
|
||||
cei = len({word for word in words if 'cei' in word})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
words = tolower(readLines("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"))
|
||||
words = tolower(readLines("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"))
|
||||
ie.npc = sum(grepl("(?<!c)ie", words, perl = T))
|
||||
ei.npc = sum(grepl("(?<!c)ei", words, perl = T))
|
||||
ie.pc = sum(grepl("cie", words, fixed = T))
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
/*REXX program shows plausibility of "I before E" when not preceded by C, and */
|
||||
/*───────────────────────────────────── "E before I" when preceded by C. */
|
||||
parse arg iFID . /*obtain optional argument from the CL.*/
|
||||
if iFID=='' | iFID=="," then iFID='UNIXDICT.TXT' /*Not specified? Then use the default.*/
|
||||
#.=0 /*zero out the various word counters. */
|
||||
do r=0 while lines(iFID)\==0 /*keep reading the dictionary 'til done*/
|
||||
u=space( lineIn(iFID), 0); upper u /*elide superfluous blanks and tabs. */
|
||||
if u=='' then iterate /*Is it a blank line? Then ignore it.*/
|
||||
#.words=#.words + 1 /*keep running count of number of words*/
|
||||
if pos('EI', u)\==0 & pos('IE', u)\==0 then #.both=#.both + 1 /*the word has both*/
|
||||
call find 'ie' /*look for ie */
|
||||
call find 'ei' /* " " ei */
|
||||
end /*r*/ /*at exit of DO loop, R = # of lines.*/
|
||||
|
||||
L=length(#.words) /*use this to align the output numbers.*/
|
||||
say 'lines in the ' iFID " dictionary: " r
|
||||
say 'words in the ' iFID " dictionary: " #.words
|
||||
say
|
||||
say 'words with "IE" and "EI" (in same word): ' right(#.both, L)
|
||||
say 'words with "IE" and preceded by "C": ' right(#.ie.c ,L)
|
||||
say 'words with "IE" and not preceded by "C": ' right(#.ie.z ,L)
|
||||
say 'words with "EI" and preceded by "C": ' right(#.ei.c ,L)
|
||||
say 'words with "EI" and not preceded by "C": ' right(#.ei.z ,L)
|
||||
say; mantra= 'The spelling mantra '
|
||||
p1=#.ie.z / max(1, #.ei.z); phrase= '"I before E when not preceded by C"'
|
||||
say mantra phrase ' is ' word("im", 1 + (p1>2) )'plausible.'
|
||||
p2=#.ie.c / max(1, #.ei.c); phrase= '"E before I when preceded by C"'
|
||||
say mantra phrase ' is ' word("im", 1 + (p2>2) )'plausible.'
|
||||
po=(p1>2 & p2>2); say 'Overall, it is' word("im", 1 + po)'plausible.'
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
find: arg x; s=1; do forever; _=pos(x, u, s); if _==0 then return
|
||||
if substr(u, _ - 1 + (_==1)*999, 1)=='C' then #.x.c=#.x.c + 1
|
||||
else #.x.z=#.x.z + 1
|
||||
s=_ + 1 /*handle the cases of multiple finds. */
|
||||
end /*forever*/
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
/*REXX program shows plausibility of "I before E" when not preceded by C, and */
|
||||
/*───────────────────────────────────── "E before I" when preceded by C, using a */
|
||||
/*───────────────────────────────────── weighted frequency for each word. */
|
||||
parse arg iFID wFID . /*obtain optional arguments from the CL*/
|
||||
if iFID=='' | iFID=="," then iFID='UNIXDICT.TXT' /*Not specified? Then use the default.*/
|
||||
if wFID=='' | wFID=="," then wFID='WORDFREQ.TXT' /* " " " " " " */
|
||||
cntl=xrange(, ' ') /*get all manner of tabs, control chars*/
|
||||
#.=0 /*zero out the various word counters. */
|
||||
f.=1 /*default word frequency multiplier. */
|
||||
do recs=0 while lines(wFID)\==0 /*read a record from the file 'til done*/
|
||||
u=translate( linein(wFID), , cntl); upper u /*translate various tabs and cntl chars*/
|
||||
u=translate(u, '*', "~") /*translate tildes (~) to an asterisk.*/
|
||||
if u=='' then iterate /*Is this a blank line? Then ignore it.*/
|
||||
freq=word(u, words(u) ) /*obtain the last token on the line. */
|
||||
if \datatype(freq, 'W') then iterate /*FREQ not an integer? Then ignore it.*/
|
||||
parse var u w.1 '/' w.2 . /*handle case of: ααα/ßßß ··· */
|
||||
|
||||
do j=1 for 2; w.j=word(w.j, 1) /*strip leading and/or trailing blanks.*/
|
||||
_=w.j; if _=='' then iterate /*if not present, then ignore it. */
|
||||
if j==2 then if w.2==w.1 then iterate /*second word ≡ first word? Then skip.*/
|
||||
#.freqs=#.freqs + 1 /*bump word counter in the FREQ list.*/
|
||||
f._=f._ + freq /*add to a word's frequency count. */
|
||||
end /*ws*/
|
||||
end /*recs*/ /*at exit of DO loop, RECS = # of recs.*/
|
||||
|
||||
if recs\==0 then say 'lines in the ' wFID " list: " recs
|
||||
if #.freqs\==0 then say 'words in the ' wFID " list: " #.freqs
|
||||
if #.freqs ==0 then weighted=
|
||||
else weighted= ' (weighted)'
|
||||
say
|
||||
do r=0 while lines(iFID)\==0 /*keep reading the dictionary 'til done*/
|
||||
u=space( linein(iFID), 0); upper u /*elide superfluous blanks and tabs. */
|
||||
if u=='' then iterate /*Is it a blank line? Then ignore it.*/
|
||||
#.words=#.words + 1 /*keep running count of number of words*/
|
||||
one=f.u
|
||||
if pos('EI', u)\==0 & pos('IE', u)\==0 then #.both=#.both + one /*the word has both*/
|
||||
call find 'ie' /*look for ie */
|
||||
call find 'ei' /* " " ei */
|
||||
end /*r*/ /*at exit of DO loop, R = # of lines.*/
|
||||
|
||||
L=length(#.words) /*use this to align the output numbers.*/
|
||||
say 'lines in the ' iFID ' dictionary: ' r
|
||||
say 'words in the ' iFID ' dictionary: ' #.words
|
||||
say
|
||||
say 'words with "IE" and "EI" (in same word): ' right(#.both, L) weighted
|
||||
say 'words with "IE" and preceded by "C": ' right(#.ie.c ,L) weighted
|
||||
say 'words with "IE" and not preceded by "C": ' right(#.ie.z ,L) weighted
|
||||
say 'words with "EI" and preceded by "C": ' right(#.ei.c ,L) weighted
|
||||
say 'words with "EI" and not preceded by "C": ' right(#.ei.z ,L) weighted
|
||||
say; mantra= 'The spelling mantra '
|
||||
p1=#.ie.z / max(1, #.ei.z); phrase= '"I before E when not preceded by C"'
|
||||
say mantra phrase ' is ' word("im", 1 + (p1>2) )'plausible.'
|
||||
p2=#.ie.c / max(1, #.ei.c); phrase= '"E before I when preceded by C"'
|
||||
say mantra phrase ' is ' word("im", 1 + (p2>2) )'plausible.'
|
||||
po=(p1>2 & p2>2); say 'Overall, it is' word("im",1 + po)'plausible.'
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
find: arg x; s=1; do forever; _=pos(x, u, s); if _==0 then return
|
||||
if substr(u, _ - 1 + (_==1)*999, 1)=='C' then #.x.c=#.x.c + one
|
||||
else #.x.z=#.x.z + one
|
||||
s=_ + 1 /*handle the cases of multiple finds. */
|
||||
|
|
@ -1,33 +1,33 @@
|
|||
Red ["i before e except after c"]
|
||||
|
||||
testlist: function [wordlist /wfreq] [
|
||||
cie: cei: ie: ei: 0
|
||||
if not wfreq [forall wordlist [insert wordlist: next wordlist 1]]
|
||||
foreach [word freq] wordlist [
|
||||
parse word [ some [
|
||||
"cie" (cie: cie + freq) |
|
||||
"cei" (cei: cei + freq) |
|
||||
"ie" (ie: ie + freq) |
|
||||
"ei" (ei: ei + freq) |
|
||||
skip
|
||||
]]
|
||||
]
|
||||
print rejoin [
|
||||
"i is before e " ie " times, and also " cie " times following c.^/"
|
||||
"i is after e " ei " times, and also " cei " times following c.^/"
|
||||
"Hence ^"i before e^" is " either a: 2 * ei < ie [""] ["not "] "plausible,^/"
|
||||
"while ^"except after c^" is " either b: 2 * cie < cei [""] ["not "] "plausible.^/"
|
||||
"Overall the rule is " either a and b [""] ["not "] "plausible."]
|
||||
cie: cei: ie: ei: 0
|
||||
if not wfreq [forall wordlist [insert wordlist: next wordlist 1]]
|
||||
foreach [word freq] wordlist [
|
||||
parse word [ some [
|
||||
"cie" (cie: cie + freq) |
|
||||
"cei" (cei: cei + freq) |
|
||||
"ie" (ie: ie + freq) |
|
||||
"ei" (ei: ei + freq) |
|
||||
skip
|
||||
]]
|
||||
]
|
||||
print rejoin [
|
||||
"i is before e " ie " times, and also " cie " times following c.^/"
|
||||
"i is after e " ei " times, and also " cei " times following c.^/"
|
||||
"Hence ^"i before e^" is " either a: 2 * ei < ie [""] ["not "] "plausible,^/"
|
||||
"while ^"except after c^" is " either b: 2 * cie < cei [""] ["not "] "plausible.^/"
|
||||
"Overall the rule is " either a and b [""] ["not "] "plausible."]
|
||||
]
|
||||
|
||||
print "Results for unixdict.txt:"
|
||||
testlist read/lines http://wiki.puzzlers.org/pub/wordlists/unixdict.txt
|
||||
testlist read/lines https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt
|
||||
|
||||
print "^/Results for British National Corpus:"
|
||||
bnc: next read/lines %1_2_all_freq.txt
|
||||
spaces: charset "^- "
|
||||
bnclist: collect [ foreach w bnc [
|
||||
if 3 = length? seq: split trim w spaces [
|
||||
keep seq/1 keep to-integer seq/3
|
||||
bnclist: collect [ foreach w bnc [
|
||||
if 3 = length? seq: split trim w spaces [
|
||||
keep seq/1 keep to-integer seq/3
|
||||
]]]
|
||||
testlist/wfreq bnclist
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ require 'open-uri'
|
|||
|
||||
plausibility_ratio = 2
|
||||
counter = Hash.new(0)
|
||||
path = 'http://wiki.puzzlers.org/pub/wordlists/unixdict.txt'
|
||||
path = 'https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt'
|
||||
rules = [['I before E when not preceded by C:', 'ie', 'ei'],
|
||||
['E before I when preceded by C:', 'cei', 'cie']]
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ fn print_feature_plausibility(feature_plausibility: Option<bool>, feature_name:
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let mut res = get(" http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").unwrap();
|
||||
let mut res = get(" https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").unwrap();
|
||||
let texts = res.text().unwrap();
|
||||
|
||||
let mut feature_count: Feature<u64> = Default::default();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ object I_before_E_except_after_C extends App {
|
|||
val testCEI2 = "(^|[^c])ei".r // e before i when not preceded by c
|
||||
var countsCEI = (0,0)
|
||||
|
||||
scala.io.Source.fromURL("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").getLines.map(_.toLowerCase).foreach{word =>
|
||||
scala.io.Source.fromURL("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt").getLines.map(_.toLowerCase).foreach{word =>
|
||||
if (testIE1.findFirstIn(word).isDefined) countsIE = (countsIE._1 + 1, countsIE._2)
|
||||
if (testIE2.findFirstIn(word).isDefined) countsIE = (countsIE._1, countsIE._2 + 1)
|
||||
if (testCEI1.findFirstIn(word).isDefined) countsCEI = (countsCEI._1 + 1, countsCEI._2)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import Foundation
|
||||
|
||||
let request = NSURLRequest(URL: NSURL(string: "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")!)
|
||||
let request = NSURLRequest(URL: NSURL(string: "https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")!)
|
||||
|
||||
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue()) {res, data, err in
|
||||
if (data != nil) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
$$ MODE TUSCRIPT,{}
|
||||
words=REQUEST("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")
|
||||
words=REQUEST("https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")
|
||||
size=SIZE(words)
|
||||
ieei=cie=xie=cei=xei=0
|
||||
|
||||
|
|
|
|||
|
|
@ -5,24 +5,24 @@ proc plausible {description x y} {
|
|||
variable PLAUSIBILITY_RATIO
|
||||
puts " Checking plausibility of: $description"
|
||||
if {$x > $PLAUSIBILITY_RATIO * $y} {
|
||||
set conclusion "PLAUSIBLE"
|
||||
set fmt "As we have counts of %i vs %i words, a ratio of %.1f times"
|
||||
set result true
|
||||
set conclusion "PLAUSIBLE"
|
||||
set fmt "As we have counts of %i vs %i words, a ratio of %.1f times"
|
||||
set result true
|
||||
} elseif {$x > $y} {
|
||||
set conclusion "IMPLAUSIBLE"
|
||||
set fmt "As although we have counts of %i vs %i words,"
|
||||
append fmt " a ratio of %.1f times does not make it plausible"
|
||||
set result false
|
||||
set conclusion "IMPLAUSIBLE"
|
||||
set fmt "As although we have counts of %i vs %i words,"
|
||||
append fmt " a ratio of %.1f times does not make it plausible"
|
||||
set result false
|
||||
} else {
|
||||
set conclusion "IMPLAUSIBLE, probably contra-indicated"
|
||||
set fmt "As we have counts of %i vs %i words, a ratio of %.1f times"
|
||||
set result false
|
||||
set conclusion "IMPLAUSIBLE, probably contra-indicated"
|
||||
set fmt "As we have counts of %i vs %i words, a ratio of %.1f times"
|
||||
set result false
|
||||
}
|
||||
puts [format " %s.\n $fmt" $conclusion $x $y [expr {double($x)/$y}]]
|
||||
return $result
|
||||
}
|
||||
|
||||
set t [http::geturl http://wiki.puzzlers.org/pub/wordlists/unixdict.txt]
|
||||
set t [http::geturl https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt]
|
||||
set words [split [http::data $t] "\n"]
|
||||
http::cleanup $t
|
||||
foreach {name pattern} {ie (?:^|[^c])ie ei (?:^|[^c])ei cie cie cei cei} {
|
||||
|
|
@ -39,4 +39,4 @@ if {
|
|||
puts "\nOVERALL IT IS IMPLAUSIBLE!"
|
||||
}
|
||||
puts "\n(To be plausible, one word count must exceed another by\
|
||||
$PLAUSIBILITY_RATIO times)"
|
||||
$PLAUSIBILITY_RATIO times)"
|
||||
|
|
|
|||
|
|
@ -2,26 +2,26 @@ import os
|
|||
import strconv
|
||||
|
||||
fn main() {
|
||||
mut cei, mut cie, mut ie, mut ei := f32(0), f32(0), f32(0), f32(0)
|
||||
mut cei, mut cie, mut ie, mut ei := f32(0), f32(0), f32(0), f32(0)
|
||||
unixdict := os.read_file('./unixdict.txt') or {println('Error: file not found') exit(1)}
|
||||
words := unixdict.split_into_lines()
|
||||
println("The number of words in unixdict: ${words.len}")
|
||||
for word in words {
|
||||
cei += word.count('cei')
|
||||
cie += word.count('cie')
|
||||
ei += word.count('ei')
|
||||
ie += word.count('ie')
|
||||
}
|
||||
print("Rule: 'e' before 'i' when preceded by 'c' at the ratio of ")
|
||||
print("${strconv.f64_to_str_lnd1((cei / cie), 2)} is ")
|
||||
if cei > cie {println("plausible.")} else {println("implausible.")}
|
||||
println("$cei cases for and $cie cases against.")
|
||||
words := unixdict.split_into_lines()
|
||||
println("The number of words in unixdict: ${words.len}")
|
||||
for word in words {
|
||||
cei += word.count('cei')
|
||||
cie += word.count('cie')
|
||||
ei += word.count('ei')
|
||||
ie += word.count('ie')
|
||||
}
|
||||
print("Rule: 'e' before 'i' when preceded by 'c' at the ratio of ")
|
||||
print("${strconv.f64_to_str_lnd1((cei / cie), 2)} is ")
|
||||
if cei > cie {println("plausible.")} else {println("implausible.")}
|
||||
println("$cei cases for and $cie cases against.")
|
||||
|
||||
print("Rule: 'i' before 'e' except after 'c' at the ratio of ")
|
||||
print("${strconv.f64_to_str_lnd1(((ie - cie) / (ei - cei)), 2)} is ")
|
||||
if ie > ei {println("plausible.")} else {println("implausible.")}
|
||||
println("${(ie - cie)} cases for and ${(ei - cei)} cases against.")
|
||||
print("Rule: 'i' before 'e' except after 'c' at the ratio of ")
|
||||
print("${strconv.f64_to_str_lnd1(((ie - cie) / (ei - cei)), 2)} is ")
|
||||
if ie > ei {println("plausible.")} else {println("implausible.")}
|
||||
println("${(ie - cie)} cases for and ${(ei - cei)} cases against.")
|
||||
|
||||
print("Overall the rules are ")
|
||||
if cei > cie && ie > ei {println("plausible.")} else {println("implausible.")}
|
||||
print("Overall the rules are ")
|
||||
if cei > cie && ie > ei {println("plausible.")} else {println("implausible.")}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
Set objFSO = CreateObject("Scripting.FileSystemObject")
|
||||
Set srcFile = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_
|
||||
"\unixdict.txt",1,False,0)
|
||||
|
||||
cei = 0 : cie = 0 : ei = 0 : ie = 0
|
||||
|
||||
Do Until srcFile.AtEndOfStream
|
||||
word = srcFile.ReadLine
|
||||
If InStr(word,"cei") Then
|
||||
cei = cei + 1
|
||||
ElseIf InStr(word,"cie") Then
|
||||
cie = cie + 1
|
||||
ElseIf InStr(word,"ei") Then
|
||||
ei = ei + 1
|
||||
ElseIf InStr(word,"ie") Then
|
||||
ie = ie + 1
|
||||
End If
|
||||
Loop
|
||||
|
||||
FirstClause = False
|
||||
SecondClause = False
|
||||
Overall = False
|
||||
|
||||
'testing the first clause
|
||||
If ie > ei*2 Then
|
||||
WScript.StdOut.WriteLine "I before E when not preceded by C is plausible."
|
||||
FirstClause = True
|
||||
Else
|
||||
WScript.StdOut.WriteLine "I before E when not preceded by C is NOT plausible."
|
||||
End If
|
||||
|
||||
'testing the second clause
|
||||
If cei > cie*2 Then
|
||||
WScript.StdOut.WriteLine "E before I when not preceded by C is plausible."
|
||||
SecondClause = True
|
||||
Else
|
||||
WScript.StdOut.WriteLine "E before I when not preceded by C is NOT plausible."
|
||||
End If
|
||||
|
||||
'overall clause
|
||||
If FirstClause And SecondClause Then
|
||||
WScript.StdOut.WriteLine "Overall it is plausible."
|
||||
Else
|
||||
WScript.StdOut.WriteLine "Overall it is NOT plausible."
|
||||
End If
|
||||
|
||||
srcFile.Close
|
||||
Set objFSO = Nothing
|
||||
|
|
@ -9,7 +9,7 @@ Imports System.Text.RegularExpressions
|
|||
|
||||
Module Program
|
||||
' Supports both local and remote files
|
||||
Const WORDLIST_URI = "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"
|
||||
Const WORDLIST_URI = "https://web.archive.org/web/20240920144647if_/http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"
|
||||
|
||||
|
||||
' The support factor of a word for EI or IE is the number of occurrences that support the rule minus the number that oppose it.
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ open "unixdict.txt" for reading as #1
|
|||
repeat
|
||||
line input #1 pal$
|
||||
if instr(pal$, "ie") then
|
||||
if instr(pal$, "cie") then CI = CI + 1 else XI = XI + 1 : fi
|
||||
endif
|
||||
if instr(pal$, "cie") then CI = CI + 1 else XI = XI + 1 : fi
|
||||
endif
|
||||
if instr(pal$, "ei") then
|
||||
if instr(pal$, "cei") then CE = CE + 1 else XE = XE + 1 : fi
|
||||
endif
|
||||
if instr(pal$, "cei") then CE = CE + 1 else XE = XE + 1 : fi
|
||||
endif
|
||||
until eof(1)
|
||||
close #1
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue