[Chicago-talk] Parsing APA-format citations

Mike Fragassi mikefrag at gmail.com
Mon May 7 07:23:24 PDT 2018


Well, if you can create targets for the in-text citations, and feed the
text body into the parser to look for these, you could then take the
hashrefs and use them to generate a skeleton of a bibliography that you can
fill out later. I.e. for a text reference of "see Foo and Bar (2001)"
you'll only have the author(s) and year for what's in the text, but you
could take that, feed it into a template system like Template::Toolkit, and
spit out a bibliography with 'TODO' or 'XXX' in the missing fields:
   Foo, XXX. & Bar XXX. (2001)  XXX_TITLE. XXX_JOURNAL, XXX_VOL, XXX_PAGES.
Then go back and fill in the missing fields.
And when done with writing both the text and the bibliography, you can
rescan both to check that there's no mismatches. Of course, that won't help
you if in one place you site Foo & Bar (2001) but you meant to site Foo &
Bar (2002), and you do also correctly site both of these elsewhere.

On Sun, May 6, 2018 at 11:21 PM, Alan Mead <amead at alanmead.org> wrote:

> Mike,
>
> Thanks! This is extremely interesting. I didn't know about this. But
> this is the second half of the issue (parsing the reference list). It
> would greatly enhance my hypothetical script to add this capability and
> check the in-text citations match one (and only one) of the references.
> And, I agree, using this mechanism, I could generate a list of "targets"
> that would make it easier to find those citations.
>
> But I was hoping to be able to parse text where the reference list
> hadn't been created to facilitate the creation of the reference list.
>
> -Alan
>
> On 5/6/2018 9:28 PM, Mike Fragassi wrote:
> > Biblio::Citation::Parser may help you.  First, seems like it should be
> > able to parse the references listed in an article's bibliography:
> >
> > use Biblio::Citation::Parser::Standard;
> > my $ref = 'Gleditsch, N. P., Pinker, S., Thayer, B. A., Levy, J. S., &
> > Thompson, W. R. (2013). The forum: The decline of war. International
> > Studies Review, 15(3), 396-419.';
> > # example from http://www.citationmachine.net/apa/cite-a-book
> > my $cit_parser = new Biblio::Citation::Parser::Standard;
> > my $metadata = $cit_parser->parse($ref);
> > print Dumper($metadata);
> >
> > The $metadata is a hashref of valid values parsed from the string,
> > including the rule that the parser used to identify the parts, that
> > looks like this:
> >
> >    'match' => '_AUTHORS_ (_YEAR_). _TITLE_. _PUBLICATION_,
> > _VOLUME_(_ISSUE_), _PAGES_',
> >
> > The 'match' seem to come from Biblio::Citation::Parser::Templates, and
> > you should be able to modify this to look for things like '(_AUTHORS_,
> > _YEAR_)' etc.  (Note: I've never used this module myself before now.)
> >
>
>
> --
>
> Alan D. Mead, Ph.D.
> President, Talent Algorithms Inc.
>
> science + technology = better workers
>
> http://www.alanmead.org
>
> I've... seen things you people wouldn't believe...
> functions on fire in a copy of Orion.
> I watched C-Sharp glitter in the dark near a programmable gate.
> All those moments will be lost in time, like Ruby... on... Rails... Time
> for Pi.
>
>           --"The Register" user Alister, applying the famous
>             "Blade Runner" speech to software development
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20180507/9fbd55bc/attachment.html>


More information about the Chicago-talk mailing list