I am trying to figure out what the best method would be for me to use to parse word phrases passed to me and build different groupings based on those phrases.
Example XML:
<root>
<keyword value=""My First Phrase""/>
<keyword value=""My First Phrase Again""/>
<keyword value=""My First Phrase Again and Again""/>
</root>
So I would extract these out of the xml:
My First Phrase
My First Phrase Again
My First Phrase Again and Again
I would then like to build these new phrases from the original:
My First Phrase
My First
First Phrase
My
First
Phrase
My First Phrase Again
My First Phrase
First Phrase Again
My First
First Phrase
Phrase Again
My
First
Phrase
Again
This would let me break down the phrases and build a sort of ranking out of those words. I am have built some lists and iterated over them, but it isn’t work the way I would expect.
So for the ranking I mean this:
My First Phrase Again Rank: 1 (Exact Match)
My First Phrase Rank: 2
First Phrase Again Rank: 2
My First Rank: 3
First Phrase Rank: 3
Phrase Again Rank: 3
My Rank: 4
First Rank: 4
Phrase Rank: 4
Again Rank: 4
Not sure what the best approach would be to parse this data.
Thanks,
S
If i understand correctly your definition of ‘rank’, you can solve it with something like this:
Usage:
Output: