Jump to content
gandalfsaxe

Autocompletion references from .bib file

Recommended Posts

Hi,

 

I'm looking to build quite a simple workflow in Alfred that simply can suggest / autocomplete "citekeys" when I start typing, using a .bib file as it's basis.

 

A .bib file is a BibTeX reference list, which is a plain text file containing a list of references formatted by the following scheme:

 

@article{Salimans2017,
abstract = {We explore the use of Evolution Strategies (ES), a class of black box optimization algorithms, as an alternative to popular MDP-based RL techniques such as Q-learning and Policy Gradients. Experiments on MuJoCo and Atari show that ES is a viable solution strategy that scales extremely well with the number of CPUs available: By using a novel communication strategy based on common random numbers, our ES implementation only needs to communicate scalars, making it possible to scale to over a thousand parallel workers. This allows us to solve 3D humanoid walking in 10 minutes and obtain competitive results on most Atari games after one hour of training. In addition, we highlight several advantages of ES as a black box optimization technique: it is invariant to action frequency and delayed rewards, tolerant of extremely long horizons, and does not need temporal discounting or value function approximation.},
archivePrefix = {arXiv},
arxivId = {1703.03864},
author = {Salimans, Tim and Ho, Jonathan and Chen, Xi and Sidor, Szymon and Sutskever, Ilya},
doi = {10.1.1.51.6328},
eprint = {1703.03864},
file = {:Users/gandalf/Library/Mobile Documents/com{\~{}}apple{\~{}}CloudDocs/-Sync/Mendeley/Salimans et al/Salimans et al. - 2017 - Evolution Strategies as a Scalable Alternative to Reinforcement Learning.pdf:pdf},
isbn = {3-540-63746-X},
issn = {1744-4292},
pages = {1--13},
pmid = {27474269},
title = {{Evolution Strategies as a Scalable Alternative to Reinforcement Learning}},
url = {http://arxiv.org/abs/1703.03864},
year = {2017}
}

This example above is just one entry, there are typically many such entries in a file. The important part is the very first value near the top which is the citekey, here "Salimans2017".

 

What I want is that I start typing "Sali" in Alfred, and that it suggests "Salimans2017" and paste it to the current text cursor in format "[@Salimans2017]".

As a bonus feature I'd be nice to be able to search for a title, then getting the citekey for the selected match.

 

Does anyone have any good idea of how to construct this workflow?

It basically boils down to making suggestions / autocompletion for a list of keywords stored in a plaintext file, and then pasting these keywords in a slightly reformatted way. I've put an example of a .bib file with two references here: https://gist.github.com/GandalfSaxe/4ca72ed004b832f4721e5274e2f1bb48

Share this post


Link to post

if you use BibDesk this is your best bet 

which works much better than the later one by smargh , which has more features but is unusably slow with my master .bib with 6500 entries or so.

 

otherwise you’ll need to include a library and parse the bibtex yourself in your language of choice 

Share this post


Link to post
On 2/7/2018 at 5:24 PM, dfay said:

if you use BibDesk this is your best bet 

which works much better than the later one by smargh , which has more features but is unusably slow with my master .bib with 6500 entries or so.

 

otherwise you’ll need to include a library and parse the bibtex yourself in your language of choice 

 

I don't use BibDesk, but I'm willing to try that workflow, either as a basis to modify or just use Bibdesk in addition to Mendeley (that is my reference manager of choice) just for the purposes of this workflow, if that could somehow work.

 

However I'm getting a broken link when I try to download that workflow. Do you know where it moved to?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×