From 4dc377db39af03beae8f24fd4f09313fd40795d2 Mon Sep 17 00:00:00 2001 From: a-t-0 <34750068+a-t-0@users.noreply.github.com> Date: Sun, 31 Oct 2021 23:25:07 +0100 Subject: [PATCH 1/3] Create retry.py --- retry.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 retry.py diff --git a/retry.py b/retry.py new file mode 100644 index 0000000..f5b7acc --- /dev/null +++ b/retry.py @@ -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")}') From d245046525f771e84c5059c4788edd9a210d5615 Mon Sep 17 00:00:00 2001 From: a-t-0 <34750068+a-t-0@users.noreply.github.com> Date: Sun, 31 Oct 2021 23:25:39 +0100 Subject: [PATCH 2/3] Create environment.yml --- environment.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 environment.yml diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..278278a --- /dev/null +++ b/environment.yml @@ -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 From 64216a2fb66276f54645858aa2c87a13b7be04b0 Mon Sep 17 00:00:00 2001 From: a-t-0 <34750068+a-t-0@users.noreply.github.com> Date: Sun, 31 Oct 2021 23:26:57 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index dcded32..18c70fe 100644 --- a/README.md +++ b/README.md @@ -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).