Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Think this might be a start ? .. only tested on your data: ;))
#!/usr/bin/perl -w use strict; sub FindRoot; my %Word=map {chomp;split /,/} <>; for (keys %Word) { print "Word: $_, etc: $Word{$_}\n"; }; my $Root=FindRoot("Longest",keys %Word); my @Words=map {split} (values %Word); my $Word=FindRoot("Shortest",@Words); print "\n---\n$Root:$Word\n"; for (keys %Word) { print "-",substr($_,length$Root),":"; print "",substr($Word{$_},0,rindex($Word{$_},$Word)),"\n"; }; sub FindRoot { my $Order=shift; my %Container; my $Min="xxxxxxxxxxxxxxx"; print "Finding $Order\n"; if ($Order eq "Shortest") { $Min=""; $Min=((length $_)>(length $Min))?$_:$Min for (@_); } else { $Min=((length $_)<(length $Min))?$_:$Min for (@_); }; for my $Word (@_) { $Container{substr lc $Word,0,$_}++ for(2..length $Min); }; my $Root=""; $Min=0; my @List=sort keys %Container; @List=reverse@List if ($Order eq "Longest"); print "List: @List\n"; for (@List) { if ($Container{$_}>$Min) { $Root=$_; $Min=$Container{$_}; }; }; return $Root; };

It`s probably not the cleanest code, but it was fun to do, so
I thought I`d post it :)))
I figure you can use this as a start to really solve your
problem, it shouldn`t be too hard to once you got the Root,
take the substring out of the hash, and start looking for the next
one (using that FindRoot sub) which would give you `lar` ,
making the next root `BasLar` ...

Hmmmmm... actually I think I got that to work here...
Looking forward to more test-data :))

GreetZ!,
    ChOas

print "profeth still\n" if /bird|devil/;

In reply to Re: Perl and Morphology by ChOas
in thread Perl and Morphology by justinNEE

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (4)
    As of 2014-11-01 08:24 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (228 votes), past polls