Change e letters to i in words: Difference between revisions
Content added Content deleted
m (→AppleScript :: Functional: Adjusted display format, updated output) |
|||
Line 327: | Line 327: | ||
set longWords to filteredLines("5 < length", s) |
set longWords to filteredLines("5 < length", s) |
||
set eWords to longWords's ¬ |
set eWords to longWords's ¬ |
||
filteredArrayUsingPredicate:( |
filteredArrayUsingPredicate:(containsChar("e")) |
||
set lexicon to ca's NSSet's ¬ |
set lexicon to ca's NSSet's ¬ |
||
setWithArray:(longWords's ¬ |
setWithArray:(longWords's ¬ |
||
filteredArrayUsingPredicate:( |
filteredArrayUsingPredicate:(containsChar("i"))) |
||
set possibles to ( |
set possibles to ((eWords's ¬ |
||
componentsJoinedByString:(linefeed))'s ¬ |
|||
⚫ | |||
⚫ | |||
componentsSeparatedByString:(linefeed) |
componentsSeparatedByString:(linefeed) |
||
set possibleSet to ca's NSMutableSet's setWithArray:(possibles) |
set possibleSet to ca's NSMutableSet's setWithArray:(possibles) |
||
Line 341: | Line 343: | ||
-- Dictionary of possible words and their sources |
-- Dictionary of possible words and their sources |
||
set dict to |
set dict to ca's NSDictionary's ¬ |
||
⚫ | |||
-- Listing of candidate words which are found in the dictionary |
-- Listing of candidate words which are found in the dictionary |
||
Line 361: | Line 364: | ||
set {e, i} to ei |
set {e, i} to ei |
||
i & " <- " & e |
|||
end |λ| |
end |λ| |
||
end script |
end script |
||
Line 368: | Line 371: | ||
ieTwins(readFile("~/Desktop/unixdict.txt")))) |
ieTwins(readFile("~/Desktop/unixdict.txt")))) |
||
end run |
end run |
||
------------------------- GENERIC ------------------------ |
------------------------- GENERIC ------------------------ |
||
⚫ | |||
-- allRplaced :: String -> String -> NSString -> NSString |
|||
on containsChar(c) |
|||
on allReplaced(needle, replacement, haystack) |
|||
⚫ | |||
⚫ | |||
end allReplaced |
|||
⚫ | |||
on containsString(s) |
|||
tell current application |
tell current application |
||
its (NSPredicate's ¬ |
its (NSPredicate's ¬ |
||
predicateWithFormat:("self contains '" & |
predicateWithFormat:("self contains '" & c & "'")) |
||
end tell |
|||
end containsString |
|||
-- dictFromZip :: NSArray -> NSArray -> NSDictionary |
|||
on dictFromZip(ks, vs) |
|||
tell current application |
|||
its (NSDictionary's ¬ |
|||
⚫ | |||
end tell |
end tell |
||
end |
end containsChar |
||
-- filteredLines :: String -> |
-- filteredLines :: String -> NString -> [a] |
||
on filteredLines(predicateString, s) |
on filteredLines(predicateString, s) |
||
-- A list of lines filtered by an NSPredicate string |
-- A list of lines filtered by an NSPredicate string |
||
Line 404: | Line 392: | ||
predicateWithFormat:predicateString) |
predicateWithFormat:predicateString) |
||
set array to its (NSArray's ¬ |
set array to its (NSArray's ¬ |
||
arrayWithArray:(s's componentsSeparatedByString:( |
arrayWithArray:(s's componentsSeparatedByString:("\n"))) |
||
end tell |
end tell |
||
Line 467: | Line 455: | ||
end unlines</lang> |
end unlines</lang> |
||
{{Out}} |
{{Out}} |
||
<pre> |
<pre>analysis <- analyses |
||
atlantis <- atlantes |
|||
atlantes -> atlantis |
|||
billow <- bellow |
|||
bellow -> billow |
|||
briton <- breton |
|||
breton -> briton |
|||
clinch <- clench |
|||
clench -> clinch |
|||
convict <- convect |
|||
convect -> convict |
|||
crisis <- crises |
|||
crises -> crisis |
|||
diagnosis <- diagnoses |
|||
diagnoses -> diagnosis |
|||
francis <- frances |
|||
frances -> francis |
|||
galatia <- galatea |
|||
galatea -> galatia |
|||
hardin <- harden |
|||
harden -> hardin |
|||
hickman <- heckman |
|||
heckman -> hickman |
|||
infant <- enfant |
|||
enfant -> infant |
|||
inflict <- inflect |
|||
inflect -> inflict |
|||
iniquity <- inequity |
|||
inequity -> iniquity |
|||
inquiry <- enquiry |
|||
enquiry -> inquiry |
|||
jacobian <- jacobean |
|||
jacobean -> jacobian |
|||
martin <- marten |
|||
marten -> martin |
|||
moduli <- module |
|||
module -> moduli |
|||
pigging <- pegging |
|||
pegging -> pigging |
|||
psychosis <- psychoses |
|||
psychoses -> psychosis |
|||
rabbit <- rabbet |
|||
rabbet -> rabbit |
|||
stirling <- sterling |
|||
sterling -> stirling |
|||
synopsis <- synopses |
|||
synopses -> synopsis |
|||
victor <- vector |
|||
vector -> victor |
|||
willis <- welles</pre> |
|||
=={{header|AWK}}== |
=={{header|AWK}}== |