Skip to content

Instantly share code, notes, and snippets.

@copystar
Last active December 22, 2016 08:10
Show Gist options
  • Save copystar/082ee2161f9c7a54c47a to your computer and use it in GitHub Desktop.
Save copystar/082ee2161f9c7a54c47a to your computer and use it in GitHub Desktop.
How to use bibliograph.parsing?
I'm hoping to do some citation analysis.
I want to count from a set of Web of Science records:
How many come from a particular institution? How many from that set are from a particular publisher?
I know this is possible if I learn BibTex.
But that's sounds like a lot of work for really just counting items in a set.
I found a Python module called bibliograph.parsing that sounds promising.
It takes citations of various formats and returns them in a Python dictionary.
And I know that there are a lot of Python commands for counting items within dictionaries.
The module is here: https://github.com/collective/bibliograph.parsing
The trouble is that there is no documentation or even an example so I can figure out how to use this module.
This suggests that it's using some sort of protocol (piping, I guess)
that is obvious to experienced programmers and invisible to others.
So given that I have a file called citations.txt, citations.bib, or citations.enl,
what would I type in to return a dictionary of citations using bibliograph.parsing?
@copystar
Copy link
Author

Thanks SOOOO much! Unfortunately, for some reason, the line "source = parser.preprocess(bib)" results in an error message:

source = parser.preprocess(bib)
Traceback (most recent call last):
File "", line 1, in
NameError: name 'parser' is not defined

(Because I'm using Ubuntu on a non-mac, instead of "brew install bibutils" - I used apt-get install bibutils. Not sure if this is a difference that makes a difference)

@smoynes
Copy link

smoynes commented May 11, 2015

Oops! I missed copypasting this line:

>>> parser = BibtexParser()

I've added it to my comment above.

apt-get install bibutils should be totally fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment