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:(containsString("e")) |
||
set lexicon to ca's NSSet's ¬ |
set lexicon to ca's NSSet's ¬ |
||
setWithArray:(longWords's ¬ |
setWithArray:(longWords's ¬ |
||
filteredArrayUsingPredicate:( |
filteredArrayUsingPredicate:(containsString("i"))) |
||
set possibles to (( |
set possibles to (allReplaced("e", "i", ¬ |
||
componentsJoinedByString:(linefeed))'s ¬ |
(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 343: | Line 341: | ||
-- Dictionary of possible words and their sources |
-- Dictionary of possible words and their sources |
||
set dict to |
set dict to dictFromZip(possibles, eWords) |
||
⚫ | |||
-- Listing of candidate words which are found in the dictionary |
-- Listing of candidate words which are found in the dictionary |
||
Line 371: | Line 368: | ||
ieTwins(readFile("~/Desktop/unixdict.txt")))) |
ieTwins(readFile("~/Desktop/unixdict.txt")))) |
||
end run |
end run |
||
------------------------- GENERIC ------------------------ |
------------------------- GENERIC ------------------------ |
||
-- allRplaced :: String -> String -> NSString -> NSString |
|||
⚫ | |||
on allReplaced(needle, replacement, haystack) |
|||
on containsChar(c) |
|||
⚫ | |||
⚫ | |||
end allReplaced |
|||
⚫ | |||
on containsString(s) |
|||
tell current application |
tell current application |
||
its (NSPredicate's ¬ |
its (NSPredicate's ¬ |
||
predicateWithFormat:("self contains '" & |
predicateWithFormat:("self contains '" & s & "'")) |
||
end tell |
|||
end containsString |
|||
-- dictFromZip :: NSArray -> NSArray -> NSDictionary |
|||
on dictFromZip(ks, vs) |
|||
tell current application |
|||
its (NSDictionary's ¬ |
|||
⚫ | |||
end tell |
end tell |
||
end |
end dictFromZip |
||
-- filteredLines :: String -> |
-- filteredLines :: String -> NSString -> [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 392: | Line 404: | ||
predicateWithFormat:predicateString) |
predicateWithFormat:predicateString) |
||
set array to its (NSArray's ¬ |
set array to its (NSArray's ¬ |
||
arrayWithArray:(s's componentsSeparatedByString:( |
arrayWithArray:(s's componentsSeparatedByString:(linefeed))) |
||
end tell |
end tell |
||