2Pants Posted June 11, 2020 Posted June 11, 2020 (edited) I'd like to make a spell check helper. Basically a keyboard shortcut driven auto-correct spell checker. 1.) User selects text 2.) Issue a keyboard shortcut or some simple trigger 3.) Take the highlighted text and make an API call to some service (maybe this or something similar) and get the suggested correct spelling 4.) Parse the response of the API call 5.) Paste that new text overtop of the selected text It's like a spell check that will work anywhere on the computer. Has anyone done anything like this? It seems like it could be possible. The trick part I think would be making the API call and parsing the response. I've built many work flows in Alfred before, but I haven't tried this one yet. What's the best way to do this? I'm thinking to either trigger a script, apple script, or just a terminal command. I didn't see any built in API related features in Alfred. This makes me wonder. Is there a timeout for an action? I haven't ever used Alfred to trigger a script. What happens if the API call takes 30 seconds. I could assume it failed and change screens only to have the text paste somewhere else undesirable. Edited June 11, 2020 by 2Pants
deanishe Posted June 11, 2020 Posted June 11, 2020 (edited) 4 hours ago, 2Pants said: Is there a timeout for an action? No. I believe Alfred will only ever kill your workflow process if you've configured it to do so. 4 hours ago, 2Pants said: I didn't see any built in API related features in Alfred. There aren't any. Alfred allows you to write workflows in basically any programming language. Pick one with a good HTTP library. 4 hours ago, 2Pants said: What happens if the API call takes 30 seconds. I could assume it failed and change screens only to have the text paste somewhere else undesirable. That's up to you to figure out, tbh. You might, for example, check that the same application is still active before you paste content. Personally, I'd use a locally-installed spellchecker, not an API. Either something like hunspell (which you can install via Homebrew) or Apple's own spellcheck API. There's no point uploading stuff to the cloud when it isn't necessary, and local is almost always faster. And free. Edited June 11, 2020 by deanishe
2Pants Posted June 12, 2020 Author Posted June 12, 2020 7 hours ago, deanishe said: There aren't any. Alfred allows you to write workflows in basically any programming language. Pick one with a good HTTP library. Great idea! I prefer python. Quote Personally, I'd use a locally-installed spellchecker, not an API. Either something like hunspell (which you can install via Homebrew) or Apple's own spellcheck API. There's no point uploading stuff to the cloud when it isn't necessary, and local is almost always faster. And free. Great idea! Didn't think of that one. That would save a lot of delays.
vitor Posted June 12, 2020 Posted June 12, 2020 20 hours ago, 2Pants said: Has anyone done anything like this? Yes, you’ve described exactly how CheckSpelling works. Though the API hasn’t been working for a bit, despite the service looking like it’s still up. As a Workflow, it’s dirt simple: a few lines of bash with a curl command is most of what you need. 16 hours ago, deanishe said: Personally, I'd use a locally-installed spellchecker, not an API. I should do that instead for the next version. Who knows why I went the API route seven years ago. Though I remember I chose that one specifically because it did not require signing up for an API key. 16 hours ago, deanishe said: or Apple's own spellcheck API That requires diving into their frameworks (Appkit), does it not? I’m guessing they don’t provide a CLI tool for it.
deanishe Posted June 12, 2020 Posted June 12, 2020 1 hour ago, vitor said: That requires diving into their frameworks (Appkit), does it not? Yup. I've only glanced at the spelling API, but it looks like it might be for GUI apps only.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now