Find the duplicate words from the paragraph in Appian
Input - A big buck bucket over the big bug bucket
Output- big bucket
Find the duplicate words from the paragraph in Appian Input - A big buck bucket over the big bug bucket Output- big bucket
Answer
You can find duplicate words in an Appian expression with split(), lower(), union(), and wherecontains(). Split the sentence into words, build a list of the unique ones, count how often each appears in the full list, and keep the words that appear more than once.
Code:
Output:
Step-by-Step Explanation
1. Split the sentence into words
trim() removes leading and trailing spaces, lower() converts the sentence to lowercase, and split() breaks it into words at each space. The example sentence "A big buck bucket over the big bug bucket" becomes:{"a", "big", "buck", "bucket", "over", "the", "big", "bug", "bucket"}
Lowercasing means "Appian" and "appian" count as the same word.
2. Get unique words using union()
Passing the same list as both arguments makes union() drop the repeated items, so each word appears once:
{"a", "big", "buck", "bucket", "over", "the", "bug"}
This way each distinct word is checked once instead of once per occurrence.
3. Find duplicate words using a!forEach() and wherecontains()
a!forEach() loops over the unique words, and fv!item is the current word. wherecontains() returns the positions where that word appears in the original list, length() counts them, and the if() keeps the word when the count is above one.
For "big", wherecontains("big", local!words) returns {2, 7}. The length is 2, so "big" is a duplicate. "bucket" appears at positions {4, 9}, so it is one too. Words that appear once return null.
4. Remove null values
reject() drops the nulls left by the words that appear only once, which leaves {"big", "bucket"}.
Limitations
Splitting on a single space doesn’t handle multiple consecutive spaces, tabs, or line breaks well. If the input can contain them, normalize the whitespace before splitting. Punctuation isn’t removed either, so "Appian" and "Appian," are treated as different words.
Try it yourself
Change the inputs or the expression and run it to see what it returns.
Independent evaluator: it approximates the Appian expression language and may differ from a real Appian environment. Verify anything that matters. Terms