> This approach should work, but I am not sure if it make sense in terms of performances with big hashes

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

UPDATE

I think we had the same question here already, better check the archives.


In reply to Re^3: retain longest multi words units from hash by LanX
in thread retain longest multi words units from hash by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.