I've been thrown a curveball in a community project I signed myself up for.. a linguist contacted me with the intent of rolling through all of Project Gutenberg, importing every ebook found, and doing some analysis of the contents of the texts, for his paper.

He found me, because I suggested a project to convert all of Project Gutenberg to Plucker format, in a professional, scalable, automated fashion.

The combined talents of a "Professional Screen Scraper" and a Linguist, would be ideal here, which is how the two of us managed to hook up on this project.

But we ran into a snag.. there is ZERO consistency in the Project Gutenberg etexts, after editing them by hundreds of volunteers, each with their own ideas. Project Gutenberg's Distributed Proofreaders is a good first step, but it isn't quite there yet.

How does this relate to Perl? Well, that would be our engine, to roll through each book, unzip it, catalog it, store it in MySQL, and output it into a format we can grok with other tools.

Our first step is to take the Gutenberg Master Index, and parse it for the title, filename, document number, and so on, to populate the initial tables in the database. From there, we'll query the db and fetch each ebook in succession to perform our tests, analysis, import, and conversion of the documents.

But we're stuck on the index. The only thing that seems to remain constant in there, is the document number, a 5-digit number in the right-most column. It is always at the end of the very first line of text describing a new book entry.

What is the best way to approach parsing this? I don't even know where to begin to scan this file for the right textual members in a way that doesn't overlap another previous or following entry, during our import.

I've seen the Glossarymaker and this entry from SpritusMaximus, but neither of them seem to do what we need.

Pseudo-examples or real examples we can use as a starting point would be great. Thanks again, everyone.


In reply to Parsing Gutenberg Catalog Index by hacker

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.