I have a sentence, for example
John Doe moved to New York last year.
Now I split the sentence into the single words and I get:
array((John(, (Doe(, (moved(, (to(, (New(, (York(, (last(, (year()
That(s quite easy. But then I want to combine the single words to get all the composed terms. It doesn(t if the composed terms make sense, I want to get all of them, though. The result of that operation should look like this:
John, Doe, John Doe, moved, Doe moved, John Doe moved, to, moved to, Doe moved to ...
The words should be composed to terms to a limit of k parts. In the example above, the limit is 3. So a term can contain 3 words at most.
The problem: How could I code the composition in PHP? It would be great if I had a function which gets a sentence as the input and gives an array with all terms as the output.
I hope you can help me. Thanks in advance!
posted date: 2009-04-12 16:15:00