I before E except after C: Difference between revisions

no edit summary
No edit summary
Line 1,997:
ei is not plausible when preceeded by c, the ratio is 0.5416666666666666
So, the idea is not plausible.</pre>
 
=={{header|FutureBasic}}==
<lang futurebasic>include "NSLog.incl"
 
#plist NSAppTransportSecurity @{NSAllowsArbitraryLoads:YES}
 
local fn CheckWord( wrd as CFStringRef, txt as CFStringRef, c as ^long, x as ^long )
CFRange range = fn StringRangeOfString( wrd, txt )
while ( range.location != NSNotFound )
if ( range.location > 0 )
select ( fn StringCharacterAtIndex( wrd, range.location-1 ) )
case _"c"
*c += 1
case else
*x += 1
end select
else
*x += 1
end if
range.location++
range.length = len(wrd) - range.location
range = fn StringRangeOfStringWithOptionsInRange( wrd, txt, 0, range )
wend
end fn
 
void local fn Doit
CFURLRef url = fn URLWithString( @"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
CFStringRef wrd, result
for wrd in words
fn CheckWord( wrd, @"ei", @cei, @xei )
fn CheckWord( wrd, @"ie", @cie, @xie )
next
NSLog(@"cei: %ld",cei)
NSLog(@"cie: %ld",cie)
NSLog(@"xei: %ld",xei)
NSLog(@"xie: %ld",xie)
if 2 * xie <= cie then result = @"not plausible" else result = @"plausible"
NSLog( @"\nI before E when not preceded by C: %@.\n¬
There are %ld examples and %ld counter-examples for a ratio of %f.\n", ¬
result, xie, xei, ( ( (float)xie - (float)cie ) / ( (float)xei - (float)cei ) ) )
if 2 * cei <= xei then result = @"not plausible" else result = @"plausible"
NSLog( @"E before I when preceded by C: %@.\n¬
There are %ld examples and %ld counter-examples for a ratio of %f.\n", ¬
result, cei, cie, ( (float)cei / (float)cie ) )
end fn
 
fn DoIt
 
HandleEvents</lang>
 
{{output}}
<pre>cei: 13
cie: 24
xei: 217
xie: 466
 
I before E when not preceded by C: plausible.
There are 466 examples and 217 counter-examples for a ratio of 2.166667.
 
E before I when preceded by C: not plausible.
There are 13 examples and 24 counter-examples for a ratio of 0.541667.</pre>
 
 
=={{header|Go}}==
408

edits