Clustering/grouping word combinations based on similarity

Hi everyone!

I am trying to find the right way of building workflow for an app on Bubble.

The concept is simple:

  1. User inputs some words and combination of words into the input field
  2. Clicks ‘Cluster!’ button
  3. App clusters/groups words into groups based on common words and returns the result to user

Here is an example:

→ User inputs the following combination of words:

  1. I want to eat
  2. I want to sleep
  3. I want to study
  4. What to eat?
  5. Where to eat?
  6. How to study hard?

→ The app in this case should group these word combos in the following ways:

Group 1: Eat

  1. I want to eat
  2. What to eat?
  3. Where to eat?

Group 2: Study

  1. I want to study
  2. How to study hard?

Group 3: Sleep

  1. I want to sleep

→ The final output is a simple list of those words grouped together.

Any idea if this can be achieved in Bubble? If yes, how?

Many thanks in advance!