in reply to Re^2: retain longest multi words units from hash
in thread retain longest multi words units from hash
I had the same idea, performance depends on the nature of your data. After sorting you'd have O(n²) i.e. (n**2 -n)/2 n *(n+1) * 1/2 == (n**2 + n)/2 comparisons from smaller in bigger keys.*
NB: you need to specify what words "are" and be careful not to delete "automation tech" because of "automation technology"
In my approach you'd calculate all subgroups of key (5 for "automation technology process") and delete them.
Performance depends then on the number of long groups you have.
As already mentioned, I don't know the nature of your data ²...
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
*) this can be improved by preparing a lookup table for single words, "automation technology" would listed for "automation" and "technology", so as soon you see "automation technology process" you only need to check the entries in the lookup table.
²) when looking for algorithms check the mathematics of Posets
I think we had the same question here already, better check the archives.
|
|---|