Can you help me devise an algorithm to identify all possible combinations of word groupings in a sentence without changing the order of the words?
For example, for the sentence "the test case phrase," the various combinations would include:
['the test case phrase']
['the', 'test case phrase']
['the test', 'case phrase']
['the test case', 'phrase']
['the', 'test', 'case phrase']
['the test', 'case', 'phrase']
['the', 'test case', 'phrase']
['the', 'test', 'case', 'phrase']
I initially considered permutations, but it seems like that would be for rearranging the words in any possible order.
I have a feeling there's a mathematical concept at play here, but I'm struggling to pinpoint it...
Just so you know, I was working on my test cases and intend to implement the solution in JavaScript.