The new version of Script Debugger made me play with AppleScript. Of course, I had to add some python.
I played with Script Debugger and my Research Library, Papers. While Papers doesn't perform very well (anymore? I do have a fairly large library on an external USB3 hard drive), and is not the most stable software I use, its AppleScirpt Dictionary is wonderful. I am using continuously to get recent references that I collect in OmniFocus into Papers.
Now, here is what I did:
- I tried in Script Debugger to get the publication year of each of the publications that I have in my database. That worked nicely. Debugging applescripts is a so much improved experience compared to the default AppleScript script editor. This is what the AppleScript does:
- loop over every entry in my papers database
- figure out what the publication year is
- append the year to a list
- at the end, missing values are ignored, via
set myList to strings of pub_yrs
- the variable
myList
is returned to python in the call of the AppleScript.
- I figured out, how to call an AppleScript from within python, using py-applescript (installed via
pip install py-applescript
andpip install PyObjC
) and return a value (myList
). The list is converted to a numpy array, and a normed histogram is plotted
The figure below shows a normed histogram of the publication dates in my Papers database:
As you can see, not surprisingly, my reading (and knowledge) is biased towards recent research. However, I do have a few classics. My oldest reference is from 1870, and, of course, related to dependence ;-)
GROVE, W R. 1870. “Use of the Word ‘Correlation’.” Nature 1 (13): 335–35. doi:10.1038/001335b0.
Here is the full script: