bibtex-cleaner 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bibtex-cleaner.gemspec +30 -0
- data/bin/bibtex-cleaner +88 -0
- data/lib/bibtex_cleaner.rb +119 -0
- data/lib/bibtex_cleaner/acm.rb +19 -0
- data/lib/bibtex_cleaner/dblp.rb +19 -0
- data/lib/bibtex_cleaner/doi.rb +14 -0
- data/lib/bibtex_cleaner/google.rb +19 -0
- data/lib/bibtex_cleaner/ieee.rb +22 -0
- data/lib/bibtex_cleaner/springer.rb +18 -0
- metadata +171 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: f45e5cbb472cb8b143af18667b38ba94917e8bac
|
|
4
|
+
data.tar.gz: de896821da019dc7b3008a835b58d127b22cc1fd
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: de3edb96472a17fd7d04cf1cb1c422ab2f6c78492dbb9a4d1bd437194ad3d508f9ccfcca0e06052d67ca77b82b1b45668a13ce209f9264dcb9cd8df8b3c98717
|
|
7
|
+
data.tar.gz: b62855b6ab7bc5954ea4fe464242f555ce747dce07bba96482b831455dbf16b71136aeb05f76b3d444c96b3ec03c45054b40d1bc486be6f148e19a187dc8ce33
|
data/.gitignore
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.yardoc
|
|
6
|
+
Gemfile.lock
|
|
7
|
+
InstalledFiles
|
|
8
|
+
_yardoc
|
|
9
|
+
coverage
|
|
10
|
+
doc/
|
|
11
|
+
lib/bundler/man
|
|
12
|
+
pkg
|
|
13
|
+
rdoc
|
|
14
|
+
spec/reports
|
|
15
|
+
test/tmp
|
|
16
|
+
test/version_tmp
|
|
17
|
+
tmp
|
|
18
|
+
*.bundle
|
|
19
|
+
*.so
|
|
20
|
+
*.o
|
|
21
|
+
*.a
|
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
gem "cites", git: "https://github.com/sckott/cites.git"
|
|
4
|
+
gem "google-scholar", git: "https://github.com/tpendragon/ruby-google-scholar.git"
|
|
5
|
+
gem "gscholar", git: "https://github.com/5kg/gscholar.git"
|
|
6
|
+
gem "dblp", git: "https://github.com/grundprinzip/dblp.git"
|
|
7
|
+
gem "levenshtein"
|
|
8
|
+
|
|
9
|
+
group :dev do
|
|
10
|
+
gem "pry"
|
|
11
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2016 Tim Felgentreff
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Bibtex::Cleaner
|
|
2
|
+
|
|
3
|
+
TODO: Write a gem description
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'bibtex-cleaner'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install bibtex-cleaner
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
TODO: Write usage instructions here
|
|
22
|
+
|
|
23
|
+
## Contributing
|
|
24
|
+
|
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/bibtex-cleaner/fork )
|
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'bibtex_cleaner'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "bibtex-cleaner"
|
|
8
|
+
spec.version = BibtexCleaner::VERSION
|
|
9
|
+
spec.authors = ["Tim Felgentreff"]
|
|
10
|
+
spec.email = ["timfelgentreff@gmail.com"]
|
|
11
|
+
spec.summary = %q{Cleanup your bib file interactively}
|
|
12
|
+
spec.description = %q{}
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
spec.add_development_dependency "pry"
|
|
24
|
+
|
|
25
|
+
spec.add_dependency "cites"
|
|
26
|
+
spec.add_dependency "google-scholar"
|
|
27
|
+
spec.add_dependency "gscholar"
|
|
28
|
+
spec.add_dependency "dblp"
|
|
29
|
+
spec.add_dependency "levenshtein"
|
|
30
|
+
end
|
data/bin/bibtex-cleaner
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
|
|
4
|
+
require "bibtex_cleaner"
|
|
5
|
+
require "bibtex_cleaner/acm"
|
|
6
|
+
require "bibtex_cleaner/dblp"
|
|
7
|
+
require "bibtex_cleaner/doi"
|
|
8
|
+
require "bibtex_cleaner/google"
|
|
9
|
+
require "bibtex_cleaner/ieee"
|
|
10
|
+
require "bibtex_cleaner/springer"
|
|
11
|
+
|
|
12
|
+
if ARGV.size < 3 || ARGV.include?("-h") || ARGV.include?("--help")
|
|
13
|
+
puts "Usage:\n\t#{File.basename(__FILE__)} -unify -clean input.bib output.bib"
|
|
14
|
+
exit
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
unify = ARGV.delete("-unify")
|
|
18
|
+
clean = ARGV.delete("-clean")
|
|
19
|
+
|
|
20
|
+
b = BibTeX.open(ARGV[0])
|
|
21
|
+
|
|
22
|
+
if unify
|
|
23
|
+
b.unify :publisher, /springer/i, "Springer"
|
|
24
|
+
b.unify :publisher, /acm/i, "{ACM}"
|
|
25
|
+
b.unify :publisher, /ieee/i, "{IEEE}"
|
|
26
|
+
b.unify :publisher, /easychair/i, "{EasyChair}"
|
|
27
|
+
b.unify :publisher, /mit/i, "{MIT} Press"
|
|
28
|
+
b.unify :institution, /vpri|viewpoints/i, "Viewpoints Research Institute"
|
|
29
|
+
b.unify :institution, /hpi|hasso.plattner.institut/i, "Hasso Plattner Institute"
|
|
30
|
+
b.unify(:doi, /./) { |e| e.doi = e.doi.downcase }
|
|
31
|
+
b.unify(:issn, /./) { |e| e.issn = e.issn.downcase }
|
|
32
|
+
b.unify(:isbn, /./) { |e| e.isbn = e.isbn.downcase }
|
|
33
|
+
b.unify(:pages, /\-/) { |e| e.pages = e.pages.gsub(/\-+/, "--") }
|
|
34
|
+
|
|
35
|
+
b.unify(:journal, /\(?[A-Z][A-Z]+\)?/) do |e|
|
|
36
|
+
unless e.journal =~ /{/
|
|
37
|
+
e.journal = e.journal.gsub(/(\(?[A-Z][A-Z]+\)?)/, "{\\1}")
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
b.unify(:booktitle, /\(?[A-Za-z]+\)/) do |e|
|
|
41
|
+
unless e.booktitle =~ /{/
|
|
42
|
+
e.booktitle = e.booktitle.gsub(/(\(?[A-Z][A-Z]+\)?)/, "{\\1}")
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
b.unify_interactively(:journal) { b.save_to(ARGV[0]) }
|
|
47
|
+
b.unify_interactively(:booktitle) { b.save_to(ARGV[0]) }
|
|
48
|
+
b.unify_interactively(:publisher) { b.save_to(ARGV[0]) }
|
|
49
|
+
b.unify_interactively(:organization) { b.save_to(ARGV[0]) }
|
|
50
|
+
b.unify_interactively(:institution) { b.save_to(ARGV[0]) }
|
|
51
|
+
|
|
52
|
+
b.save_to(ARGV[1])
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
if clean
|
|
56
|
+
out = BibTeX::Bibliography.new
|
|
57
|
+
inputthread = Thread.new {}
|
|
58
|
+
|
|
59
|
+
b.entries.values.each do |e|
|
|
60
|
+
querystr = "#{e.title} #{e.author} #{e.year} #{e.journal} #{e.booktitle}"
|
|
61
|
+
nbibtexen = BibtexCleaner.constants.map { |c| BibtexCleaner.const_get(c) }.map do |m|
|
|
62
|
+
begin
|
|
63
|
+
m.bibtex_for(querystr) if m.respond_to? :bibtex_for
|
|
64
|
+
rescue Exception; end
|
|
65
|
+
end.flatten.compact
|
|
66
|
+
|
|
67
|
+
inputthread.join
|
|
68
|
+
bibtexen = nbibtexen
|
|
69
|
+
inputthread = Thread.new do
|
|
70
|
+
puts "\nCleaning #{e} ..."
|
|
71
|
+
out << e.merge_interactively(
|
|
72
|
+
bibtexen,
|
|
73
|
+
inproceedings: [:author, :booktitle, :year, :month, :pages, :publisher, :doi],
|
|
74
|
+
incollection: [:author, :booktitle, :year, :month, :pages, :publisher, :doi],
|
|
75
|
+
phdthesis: [:author, :year, :month, :school],
|
|
76
|
+
article: [:author, :journal, :number, :volume, :year, :month, :pages, :publisher, :doi],
|
|
77
|
+
book: [:author, :year, :month, :isbn, :issn, :publisher, :doi, :edition],
|
|
78
|
+
techreport: [:author, :year, :month, :number, :institution, :issn, :doi, :isbn],
|
|
79
|
+
manual: [:author, :organization, :edition, :year, :month, :note],
|
|
80
|
+
online: [:author, :day, :month, :year, :url, :note],
|
|
81
|
+
misc: [:author, :month, :year, :howpublished, :note]
|
|
82
|
+
)
|
|
83
|
+
out.save_to(ARGV[1])
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
out.save_to(ARGV[1])
|
|
88
|
+
end
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
require "bundler/setup"
|
|
2
|
+
require "levenshtein"
|
|
3
|
+
require "bibtex"
|
|
4
|
+
require "readline"
|
|
5
|
+
|
|
6
|
+
module BibtexCleaner
|
|
7
|
+
VERSION = "0.1.0"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class BibTeX::Entry
|
|
11
|
+
def multiple_choice(f, bibtexen)
|
|
12
|
+
choices = bibtexen.map { |b| [(b.send(f) if b.respond_to?(f)), b.title, b.author] }
|
|
13
|
+
choices = choices.reject { |c| "#{c.first}".empty? }.uniq { |c| "#{c.first}" }
|
|
14
|
+
|
|
15
|
+
return choices.first.first if choices.size == 1
|
|
16
|
+
return "" if choices.size == 0
|
|
17
|
+
|
|
18
|
+
puts "Choose #{f}! (or enter your own, 0 is the original or suggested entry)"
|
|
19
|
+
choices.each_with_index do |choice, idx|
|
|
20
|
+
puts "[#{idx}] \"#{choice.first}\"\n\t\t\t\t(#{choice[1]}, #{choice[2]})"
|
|
21
|
+
end
|
|
22
|
+
answer = Readline.readline.strip
|
|
23
|
+
result = if answer =~ /\d+/
|
|
24
|
+
choices[answer.to_i].first
|
|
25
|
+
elsif answer.empty?
|
|
26
|
+
choices[0].first
|
|
27
|
+
else
|
|
28
|
+
answer
|
|
29
|
+
end
|
|
30
|
+
puts result
|
|
31
|
+
result
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def merge_interactively(other_entries, required_fields)
|
|
35
|
+
new_entry = {
|
|
36
|
+
bibtex_type: multiple_choice(:type, [self] + other_entries),
|
|
37
|
+
key: self.key
|
|
38
|
+
}
|
|
39
|
+
fields = required_fields[new_entry[:bibtex_type]]
|
|
40
|
+
if fields.nil?
|
|
41
|
+
self.key = "XXX_NOT_CLEANED_#{self.key}"
|
|
42
|
+
fields = []
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
unless fields.empty?
|
|
46
|
+
other_entries = other_entries.select do |b|
|
|
47
|
+
b.type == new_entry[:bibtex_type]
|
|
48
|
+
end
|
|
49
|
+
new_entry[:title] = multiple_choice(:title, [self] + other_entries)
|
|
50
|
+
other_entries = other_entries.select do |b|
|
|
51
|
+
Levenshtein.normalized_distance(b.title.to_s, new_entry[:title].to_s) < 0.5
|
|
52
|
+
end
|
|
53
|
+
fields.each do |f|
|
|
54
|
+
new_entry[f] = multiple_choice(f, [self] + other_entries)
|
|
55
|
+
end
|
|
56
|
+
BibTeX::Entry.new(new_entry)
|
|
57
|
+
else
|
|
58
|
+
self
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
class BibTeX::Bibliography
|
|
64
|
+
def unify_interactively(field)
|
|
65
|
+
elements = entries.values
|
|
66
|
+
todo = elements.clone
|
|
67
|
+
|
|
68
|
+
elements.each do |prime|
|
|
69
|
+
next unless todo.include?(prime)
|
|
70
|
+
if prime.respond_to?(field) && prime.send(field)
|
|
71
|
+
primevalue = prime.send(field).to_s
|
|
72
|
+
todo.delete(prime)
|
|
73
|
+
|
|
74
|
+
es = todo.select do |e|
|
|
75
|
+
e.respond_to?(field) && Levenshtein.normalized_distance(
|
|
76
|
+
e.send(field).to_s.downcase.gsub(/[^A-Za-z]/, "").split.sort.join(" "),
|
|
77
|
+
primevalue.downcase.gsub(/[^A-Za-z]/, "").split.sort.join(" ")) < 0.4
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
if (es + [prime]).uniq { |e| e.send(field).to_s }.size > 1
|
|
81
|
+
puts "#{field}: #{primevalue}"
|
|
82
|
+
puts "These seem similar -- write (comma separated) which entries do belong in this list (or press return to skip all)"
|
|
83
|
+
es.each_with_index do |e, i|
|
|
84
|
+
puts "[#{i}] #{e.send(field)}"
|
|
85
|
+
end
|
|
86
|
+
answer = Readline.readline.strip
|
|
87
|
+
unless answer.empty?
|
|
88
|
+
rejects = answer.strip.split(",").map(&:strip).map(&:to_i)
|
|
89
|
+
es = es.each_with_index.select do |(e, idx)|
|
|
90
|
+
rejects.include? idx
|
|
91
|
+
end.map(&:first)
|
|
92
|
+
else
|
|
93
|
+
es = []
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
puts "Now, enter the desired common writing for this, press return to keep all values as they are, enter '.' to apply the prime writing"
|
|
98
|
+
puts "#{primevalue}"
|
|
99
|
+
es.each_with_index do |e, i|
|
|
100
|
+
puts "#{e.send(field)}"
|
|
101
|
+
end
|
|
102
|
+
answer = Readline.readline("", true).strip
|
|
103
|
+
unless answer.empty?
|
|
104
|
+
if answer == "."
|
|
105
|
+
answer = primevalue
|
|
106
|
+
else
|
|
107
|
+
prime.send("#{field}=", answer)
|
|
108
|
+
end
|
|
109
|
+
es.each do |e|
|
|
110
|
+
e.send("#{field}=", answer)
|
|
111
|
+
todo.delete(e)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
puts "\n\n"
|
|
115
|
+
yield if block_given?
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require "mechanize"
|
|
2
|
+
|
|
3
|
+
module BibtexCleaner
|
|
4
|
+
module ACM
|
|
5
|
+
def self.bibtex_for(querystr, limit = 4)
|
|
6
|
+
agent = Mechanize.new
|
|
7
|
+
page = agent.get("http://dl.acm.org/results.cfm", query: querystr, srt: "_score")
|
|
8
|
+
|
|
9
|
+
page.links.
|
|
10
|
+
select { |l| l.href =~ /citation.cfm\?id/ }[0...limit].
|
|
11
|
+
map do |l|
|
|
12
|
+
BibTeX.parse(
|
|
13
|
+
agent.get(l.href.sub("citation.cfm", "exportformats.cfm") + "&expformat=bibtex").
|
|
14
|
+
links.detect { |l| l.to_s =~ /download/i }.click.content
|
|
15
|
+
).entries.values
|
|
16
|
+
end.flatten
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require "mechanize"
|
|
2
|
+
require "dblp"
|
|
3
|
+
|
|
4
|
+
module BibtexCleaner
|
|
5
|
+
module DBLP
|
|
6
|
+
def self.bibtex_for(querystr, limit = 4)
|
|
7
|
+
agent = Mechanize.new
|
|
8
|
+
page = agent.get("http://dblp.uni-trier.de/search", q: querystr)
|
|
9
|
+
|
|
10
|
+
page.links.
|
|
11
|
+
select { |l| l.href =~ /rec\/bibtex\/(.+)/; $1 }.compact[0...limit].
|
|
12
|
+
map do |dblpkey|
|
|
13
|
+
BibTeX.parse(
|
|
14
|
+
agent.get("http://dblp.uni-trier.de/rec/bib2/#{dblpkey}.bib").content
|
|
15
|
+
).entries.values
|
|
16
|
+
end.flatten
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require "cites"
|
|
2
|
+
|
|
3
|
+
module BibtexCleaner
|
|
4
|
+
module DOI
|
|
5
|
+
def self.bibtex_for(querystr, limit = 4)
|
|
6
|
+
results = ::Cites.search(querystr)
|
|
7
|
+
results["items"].select { |i| i["normalizedScore"] > 90 }.map do |i|
|
|
8
|
+
BibTeX.
|
|
9
|
+
parse(::Cites.doi2cit(i["doi"].sub(/^.+dx.doi.org\//, ""), "bibtex").first).
|
|
10
|
+
entries.values
|
|
11
|
+
end.flatten[0...limit]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require "gscholar"
|
|
2
|
+
require "mechanize"
|
|
3
|
+
|
|
4
|
+
module BibtexCleaner
|
|
5
|
+
module Google
|
|
6
|
+
def self.bibtex_for(querystr, limit = 4)
|
|
7
|
+
agent = Mechanize.new
|
|
8
|
+
page = agent.get("https://scholar.google.de/scholar", q: querystr)
|
|
9
|
+
|
|
10
|
+
page.links.
|
|
11
|
+
map { |l| l.href =~ /\?cites=(\d+)/; $1 }.compact[0..limit].
|
|
12
|
+
map do |id|
|
|
13
|
+
bibtex = GScholar::Paper.new(id).bibtex
|
|
14
|
+
bibtex = bibtex.encode('ASCII', :invalid => :replace, :undef => :replace)
|
|
15
|
+
BibTeX.parse(bibtex).entries.values
|
|
16
|
+
end.flatten
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "mechanize"
|
|
2
|
+
|
|
3
|
+
module BibtexCleaner
|
|
4
|
+
module IEEE
|
|
5
|
+
def self.bibtex_for(querystr, limit = 4)
|
|
6
|
+
agent = Mechanize.new
|
|
7
|
+
page = agent.get("http://ieeexplore.ieee.org/search/searchresult.jsp", queryText: querystr)
|
|
8
|
+
|
|
9
|
+
page.links.
|
|
10
|
+
map { |l| l.href =~ /arnumber=(\d+)/; $1 }.compact[0...limit].
|
|
11
|
+
map do |id|
|
|
12
|
+
bibtex = agent.post("http://ieeexplore.ieee.org/xpl/downloadCitations",
|
|
13
|
+
:recordIds => id,
|
|
14
|
+
"citations-format" => "citation-only",
|
|
15
|
+
"download-format" => "download-bibtex",
|
|
16
|
+
"x" => "74",
|
|
17
|
+
"y" => "7").content
|
|
18
|
+
BibTeX.parse(bibtex).entries.values
|
|
19
|
+
end.flatten
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "mechanize"
|
|
2
|
+
|
|
3
|
+
module BibtexCleaner
|
|
4
|
+
module Springer
|
|
5
|
+
def self.bibtex_for(querystr, limit = 4)
|
|
6
|
+
agent = Mechanize.new
|
|
7
|
+
page = agent.get("http://link.springer.com/search", query: querystr)
|
|
8
|
+
|
|
9
|
+
page.links.
|
|
10
|
+
select { |l| l.href =~ /link.springer.com\/(chapter|article)\/.+\/.+/ }[0...limit].
|
|
11
|
+
map do |l|
|
|
12
|
+
BibTeX.parse(
|
|
13
|
+
agent.get(l.href.sub("link.springer.com/", "link.springer.com/export-citation") + ".bib").content
|
|
14
|
+
).entries.values
|
|
15
|
+
end.flatten
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bibtex-cleaner
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Tim Felgentreff
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-01-04 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.6'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.6'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: pry
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: cites
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: google-scholar
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: gscholar
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: dblp
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: levenshtein
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
description: ''
|
|
126
|
+
email:
|
|
127
|
+
- timfelgentreff@gmail.com
|
|
128
|
+
executables:
|
|
129
|
+
- bibtex-cleaner
|
|
130
|
+
extensions: []
|
|
131
|
+
extra_rdoc_files: []
|
|
132
|
+
files:
|
|
133
|
+
- ".gitignore"
|
|
134
|
+
- Gemfile
|
|
135
|
+
- LICENSE.txt
|
|
136
|
+
- README.md
|
|
137
|
+
- Rakefile
|
|
138
|
+
- bibtex-cleaner.gemspec
|
|
139
|
+
- bin/bibtex-cleaner
|
|
140
|
+
- lib/bibtex_cleaner.rb
|
|
141
|
+
- lib/bibtex_cleaner/acm.rb
|
|
142
|
+
- lib/bibtex_cleaner/dblp.rb
|
|
143
|
+
- lib/bibtex_cleaner/doi.rb
|
|
144
|
+
- lib/bibtex_cleaner/google.rb
|
|
145
|
+
- lib/bibtex_cleaner/ieee.rb
|
|
146
|
+
- lib/bibtex_cleaner/springer.rb
|
|
147
|
+
homepage: ''
|
|
148
|
+
licenses:
|
|
149
|
+
- MIT
|
|
150
|
+
metadata: {}
|
|
151
|
+
post_install_message:
|
|
152
|
+
rdoc_options: []
|
|
153
|
+
require_paths:
|
|
154
|
+
- lib
|
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - ">="
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: '0'
|
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
|
+
requirements:
|
|
162
|
+
- - ">="
|
|
163
|
+
- !ruby/object:Gem::Version
|
|
164
|
+
version: '0'
|
|
165
|
+
requirements: []
|
|
166
|
+
rubyforge_project:
|
|
167
|
+
rubygems_version: 2.2.2
|
|
168
|
+
signing_key:
|
|
169
|
+
specification_version: 4
|
|
170
|
+
summary: Cleanup your bib file interactively
|
|
171
|
+
test_files: []
|