AppleScript名:英文のスペルチェックを行い、候補文を返す |
— Created 2015-12-18 by Takaaki Naganoya — 2015 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "AppKit" set aText to "This is a penz." set spRes to spellChecking(aText) of me –> {missed:"penz", suggestionList:{"This Is A Pens", "This Is A Pend", "This Is A Penh", "This Is A Penn", "This Is A Pent", "This is a pen"}} set aText to "AppleScript" set spRes to spellChecking(aText) of me –> missing value set aText to "Applele" set spRes to spellChecking(aText) of me –> {missed:"Applele", suggestionList:{"Apple", "Apples", "Appeal", "Appalled", "Appellate"}} on spellChecking(aText) set aStr to current application’s NSString’s stringWithString:aText set aChecker to current application’s NSSpellChecker’s sharedSpellChecker() set aMisspelledRange to aChecker’s checkSpellingOfString:aStr startingAt:0 if aMisspelledRange’s |length|() = 0 then return missing value –Get Misspelled String set aMisString to (aStr’s substringWithRange:aMisspelledRange) as text –Get Suggestion set aSugList to (aChecker’s guessesForWord:aStr) as list –> {"This Is A Pens", "This Is A Pend", "This Is A Penh", "This Is A Penn", "This Is A Pent", "This is a pen"} return {missed:aMisString, suggestionList:aSugList} end spellChecking |
More from my site
(Visited 31 times, 1 visits today)