I'm trying to write a small routine responsible for permuting all possible abbreviations for a string. This string is a full name, separated by spaces. Like this:
James Mitchell Rhodes
I want to output:
J. Mitchell Rhodes
James M. Rhodes
J. M. Rhodes
And so on... however, i also have to consider "stopwords":
James the Third Rhodes
I want to output:
J. the Third R.
James The Third R.
Is there a known algorithm for this? I've been trying to fix this problems for quite some time now.
UPDATE: Having each word in array is dead easy. Just explode(' ', $string) and then array_map, to exclude the stop words considering in_array($word, $stopWordsMap). This is NOT the problem, and NOT the focus of the question. The problem is how to discover the combination of possible Original words (O) and Abbreviated words (A):
O A A
O A O
O A A
A A A
O O O