Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thank you for your work. I included support for Anaconda. #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ Print matched article from last to first, so that the best one would be bottom.
# Setting (doi2bib)
In doi2bib, modify the fmt to the format you want. Here are available options: bibtex apa harvard ris ieee mla vancouver chicago
bibtex is the default.

# Troubleshooting
If that does not work, you could give:
```
python retry.py
```
a shot. (The title is hardcoded in this file, so you can do a whole list at once).
14 changes: 14 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# run: conda env create --file environment.yml
# include new packages: conda env update --file environment.yml
name: title2doi
channels:
- conda
dependencies:
- anaconda
- pip
- pip:
- bs4
- lxml
- habanero
- conda:
- pytest=6.1.2
25 changes: 25 additions & 0 deletions retry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# pip install habanero
from habanero import Crossref
import re

def titletodoi(keyword):
cr = Crossref()
result = cr.works(query=keyword)
items = result['message']['items']
item_title = items[0]['title']
tmp = ''
for it in item_title:
tmp += it
title = keyword.replace(' ', '').lower()
title = re.sub(r'\W', '', title)
# print('title: ' + title)
tmp = tmp.replace(' ', '').lower()
tmp = re.sub(r'\W', '', tmp)
# print('tmp: ' + tmp)
if (title == tmp):
doi=items[0]['DOI']
return doi
else:
return None

print(f'doi={titletodoi("Increased Mars rover autonomy using AI planning, scheduling and execution")}')