Todays task is seemingly simple, but has proven challenging for my woeful software skills. I will be processing arbitrary web pages, obtained by our crawler. I will be processing the textual content of these pages, if any. In no particular order, I need to remove any HTML tags as well as any garbage, separate any text into paragraphs, and for each of these paragraphs, separate into individual sentences which are processed individually.

By paragraph, I refer to the natural use of the word, and, since web pages are often poorly formed, it may be useful to employ some heuristics such as limiting to 20 sentences or something if no natural breaks are found near by.

Sentences are of course the groups of words separated by the usual punctuation, and maybe a similar heuristic can be employed, limiting the number of words to say, 100? I have tried writing some code to handle his, but it seems to perform poorly. I can use HTML::Strip to remove the tags, and Text::Sentence to find the sentences reasonably well, but have no clue how to grab paragraphs. I realize that I could probably use the html tags to aid this task, but I have been unsuccessful in doing so. I really appreciate any help!

In reply to Seperating HTML by paragraph, sentence by downer

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.