Created
January 18, 2016 13:09
-
-
Save MatteoRagni/e0b368ffbf4a0fb67024 to your computer and use it in GitHub Desktop.
Searcher for bibliography. Requires scholar.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'colorize' | |
# Comment a paper using % | |
$PAPERS = <<-ENDOFLIST | |
ENDOFLIST | |
$PAPERS = $PAPERS.chomp.split /\n/ | |
bibliography = "" | |
$PAPERS.each_with_index do |paper, i| | |
print "[#{i+1} of #{$PAPERS.size}] " | |
begin | |
puts "Commented... skipping" | |
next | |
end if paper =~ /%+\s.*/ | |
command = "scholar.py -c 1 --phrase \"#{paper}\" --no-patents --no-citations --citation bt" | |
puts command.red | |
result = `#{command}` | |
if result != "" | |
bibliography += result | |
puts "INFO: ".blue + paper.white + " saved in bibliography".green | |
puts result.light_blue | |
else | |
puts "WARNING! ".yellow + paper.white + " returned no result".yellow | |
end | |
end | |
puts "Writing to temporary bib file. Remember to check it!" | |
File.open("bib.bib", "a") do |f| | |
f.puts bibliography | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment