Generate Tags Effortlessly with This Apple Shortcut for Notes
Written on
Note-taking and automation
Have you ever found yourself wanting to tag a note after reading an article, drafting a message, or reviewing an email, but weren't sure which tags to use?
Imagine if you could simply choose significant words or phrases from a pre-generated list without the hassle of inserting # symbols manually. This Apple Shortcut accomplishes just that.
While I'll explain its functionality, you don't need to dive into the technical details to start using it. A link is provided for you to easily add it to your iPhone or iPad.
After installation, you can utilize it from any app that has a share option. Just highlight the desired text and share it to "SplitTextIntoTags." In a moment, a tag selection menu will appear, allowing you to pick your preferences.
Another window will pop up displaying a string of tags, complete with # symbols for easy copying and pasting into your notes. Simple, right?
What should the Shortcut do?
The Shortcut is designed to:
- Capture text from the share menu and break it into word combinations.
- Eliminate "stop words" (as detailed below).
- Present potential tags in alphabetical order for user selection.
- Generate a string of chosen tags for easy copying into your notes.
What are stop words?
Stop words are common filler words, such as conjunctions, that lack specific meaning. Natural language processing tools exclude these words from analysis, which is why they are termed "stop words."
Consider this example:
> Vegetarians do not eat meat.
In this sentence, "do" and "not" would be less useful as tags, while "vegetarians" and "meat" are more relevant.
You can find a comprehensive list of stop words [here](#).
How does it work?
You don’t need to read this section to use the Shortcut. Just follow the instructions in the next section, "How do I use it?" to get started.
Still with me? Great! Here’s a brief overview: it employs a pipeline approach.
- Capture the text sent to the Shortcut.
- Clean it up (e.g., remove punctuation).
- Create a list of potential tags from the source text.
- Eliminate duplicates.
- Discard stop words.
- Sort the list.
- Display the potential tags in a menu.
- Show a text string of the selected tags.
Capture the text sent to the shortcut.
The Shortcut appears in the Share Menu, allowing text from a source document to be passed to it. If no text is available, it prompts the user to provide some.
Clean it up (e.g., remove punctuation).
Only the words are needed, so punctuation and new line characters should be removed. A variable is created to hold the newline character, as Shortcuts does not provide a predefined one.
Regular expressions are used for text cleansing, and they must be activated in the Replace Text action.
Remove stop words
The simplest way to check if a word is in a list is to use a dictionary. I've formatted a downloaded list of stop words into a dictionary for easy lookup.
Now, I can check the input text against this dictionary using a regular expression. If a word isn’t found on the stop word list, it gets added to a potential tag list.
Create word combinations
Next, I generate combinations of words to use as potential tags—yes, more regular expressions! This list isn’t exhaustive, as combinations only need to reflect the order in which they appear in the original text.
Eliminate duplicates and sort the list
The search for combinations may have resulted in duplicates, so placing everything into a dictionary removes them. To sort the list, I utilize a trick where I treat my list as a list of file names.
Display the list
The hard work is complete! Now the sorted list is displayed for users to select their desired tags.
How do I use it?
For those who skipped the section on its inner workings, here's how to get started.
Before you can install this Shortcut, ensure that third-party shortcuts are allowed on your device. Follow these [instructions](#).
Once you’ve granted permission, tap on this link:
[Shortcuts](#)
If you agree, the Shortcut will be copied to your device.
Open Safari and check that "SplitTextIntoTags" appears on the Share Menu. If it’s not there, tap to edit and add it.
Highlight some text on a webpage, activate "SplitTextIntoTags," and wait for the Shortcut to generate the tags.
When the menu appears, select any tags you prefer. The Shortcut will create a text string of your selected tags for easy copying to your clipboard.
Future developments
Initially, this Shortcut was much simpler, focusing only on splitting text into words. However, I quickly realized the need for sorting and generating combinations of words. After several iterations, this is the final product.
This Shortcut could potentially loop through multiple Apple Notes or documents. I experimented with this, but iPadOS struggled with larger note collections. Additionally, tags must be selected for each note, which led to my decision to abandon that approach.
I also considered utilizing an API to classify words as nouns or verbs, but that would significantly slow down the Shortcut's performance.
I intend to explore better tag generation methods, but for now, I hope you find this useful. Do you have any suggestions for generating tag candidates?
Explore more of my articles on Apple Shortcuts:
[Apple Shortcuts](https://willjmurphy.medium.com)
Join Medium using my referral link - Will J Murphy:
[Read all stories from Will J Murphy (and many other writers on Medium). Your membership directly supports...](https://willjmurphy.page)