Transform string to a list of ngrams
Function: Transform string to a list of ngrams
This action helps you break down a piece of text into all its possible smaller parts, called 'ngrams'. You decide the minimum length of these parts. This is useful for analyzing text, finding patterns, or preparing data for search functions.
Input,
- String: The text you want to break down into smaller parts.
- Type: Text
- Required: Yes
- N: The smallest number of characters each part (ngram) should have. For example, if you set N to 2, the action will find all 2-character, 3-character, and longer parts within your text.
- Type: Number
- Required: Yes
Output,
- Result: A list of all the generated text parts (ngrams). This list will be stored in a variable you name, which you can then use in other parts of your application.
- Type: List of Text
Execution Flow,
Real-Life Examples,
-
Analyzing product names for search suggestions
- Inputs:
- String: "Smartphone"
- N: 3
- Result: The action generates a list like:
["Sma", "mar", "art", "rtp", "tph", "pho", "hon", "one", "Smar", "mart", "artp", "rtph", "tpho", "phon", "hone", "Smart", "martp", "artph", "rtpho", "tphon", "phone", "Smartp", "martph", "artpho", "rtphon", "tphone", "Smartph", "martpho", "artphon", "rtphone", "Smartpho", "martphon", "artphone", "Smartphon", "martphone", "Smartphone"]. This list can be used to match partial user inputs in a search bar.
- Inputs:
-
Generating tags or keywords from a single word
- Inputs:
- String: "Marketing"
- N: 4
- Result: The action generates a list like:
["Mark", "arke", "rket", "keti", "etin", "ting", "Marke", "arket", "rketi", "ketin", "eting", "Market", "arketi", "rketin", "keting", "Marketi", "arketin", "rketing", "Marketin", "arketing", "Marketing"]. This list can be used to automatically suggest relevant tags for content.
- Inputs:
-
Creating partial matches for an autocomplete feature
- Inputs:
- String: "Apple"
- N: 1
- Result: The action generates a list like:
["A", "p", "p", "l", "e", "Ap", "pp", "pl", "le", "App", "ppl", "ple", "Appl", "pple", "Apple"]. This comprehensive list of substrings can power an autocomplete dropdown, suggesting "Apple" even if the user types "App" or "ple".
- Inputs: