Change e letters to i in words: Difference between revisions
m
→AppleScript :: Functional
m (→AppleScript :: Functional: Adjusted display format, updated output) |
|||
Line 327:
set longWords to filteredLines("5 < length", s)
set eWords to longWords's ¬
filteredArrayUsingPredicate:(
set lexicon to ca's NSSet's ¬
setWithArray:(longWords's ¬
filteredArrayUsingPredicate:(
set possibles to (allReplaced(
(eWords's componentsJoinedByString:(linefeed))))'s ¬
stringByReplacingOccurrencesOfString:("e") ¬▼
withString:("i"))'s ¬▼
componentsSeparatedByString:(linefeed)
set possibleSet to ca's NSMutableSet's setWithArray:(possibles)
Line 343 ⟶ 341:
-- Dictionary of possible words and their sources
set dict to
dictionaryWithObjects:eWords forKeys:possibles▼
-- Listing of candidate words which are found in the dictionary
Line 371 ⟶ 368:
ieTwins(readFile("~/Desktop/unixdict.txt"))))
end run
------------------------- GENERIC ------------------------
-- allRplaced :: String -> String -> NSString -> NSString
-- containsChar :: Char -> NSPredicate▼
on allReplaced(needle, replacement, haystack)
end allReplaced
on containsString(s)
tell current application
its (NSPredicate's ¬
predicateWithFormat:("self contains '" &
end tell
end containsString
-- dictFromZip :: NSArray -> NSArray -> NSDictionary
on dictFromZip(ks, vs)
tell current application
its (NSDictionary's ¬
end tell
end
-- filteredLines :: String ->
on filteredLines(predicateString, s)
-- A list of lines filtered by an NSPredicate string
Line 392 ⟶ 404:
predicateWithFormat:predicateString)
set array to its (NSArray's ¬
arrayWithArray:(s's componentsSeparatedByString:(
end tell
|