Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Comment on

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

Hi Perlmonks,

I am interested to find out the matching words between an original text and a new text and the percentage of matching words over the total words in new text. For example, I have an original text like $a="Poet Blake had a milky white cat. He used to call it Pussy."; and a new text like $b="Poet Blake had a white cat and used to call it Pussy."; The words that matched between these two texts are 11 i.e. Poet, Blake, had, a, white, cat, used, to, call, it, Pussy. Moreover, there are 12 words in new text $b. Thus, the percentage of matching words over the new text will be=(11/12)*100 i.e. 91.67%. Is it possible to get these results using a perl program? This question is in continuation of one of my earlier nodes. I tried with a script that made use of a module called but failed. I am at my wit's end to get the desired results. I got some suggestions in this regard from perlmonks earlier. But I failed to write a working script for the desired results. Is it possible to use a simple script in perl to find the matching words between two texts and the percentage of matching words?

In reply to Is it possible to find the matching words and the percentage of matching words between two texts? by supriyoch_2008

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, 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
  • 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.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (6)
    As of 2018-11-15 08:43 GMT
    Find Nodes?
      Voting Booth?
      My code is most likely broken because:

      Results (182 votes). Check out past polls.

      • (Sep 10, 2018 at 22:53 UTC) Welcome new users!