From eb8b1f56394808dc3f75a65c5ccb59d66cecfe99 Mon Sep 17 00:00:00 2001 From: Iddo Date: Tue, 8 Feb 2022 16:25:21 -0600 Subject: [PATCH 1/3] Added a general keyaord search function publ_search --- dblp/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dblp/__init__.py b/dblp/__init__.py index 17151b7..02573d3 100644 --- a/dblp/__init__.py +++ b/dblp/__init__.py @@ -4,6 +4,7 @@ DBLP_BASE_URL = 'http://dblp.uni-trier.de/' DBLP_AUTHOR_SEARCH_URL = DBLP_BASE_URL + 'search/author' +DBLP_PUB_SEARCH_URL = DBLP_BASE_URL + 'search/publ/api' DBLP_PERSON_URL = DBLP_BASE_URL + 'pers/xk/{urlpt}' DBLP_PUBLICATION_URL = DBLP_BASE_URL + 'rec/bibtex/{key}.xml' @@ -18,7 +19,7 @@ def __getattr__(self, key): if self.data is None: self.load_data() return self.data[key] - raise AttributeError, key + raise AttributeError(key) def load_data(self): pass @@ -140,6 +141,16 @@ def load_data(self): self.data = data +def publ_search(publ_str): + # Iddo Friedberg: search using keywords in publications. Return all publicaitons with these keywords + publications = [] + resp = requests.get(DBLP_PUB_SEARCH_URL, params={'q':publ_str}) + root = etree.fromstring(resp.content) + for des in root.iterdescendants(): + if des.tag == "key": + publications.append(Publication(des.text)) + return publications + def search(author_str): resp = requests.get(DBLP_AUTHOR_SEARCH_URL, params={'xauthor':author_str}) #TODO error handling From e2f8d888a7fa1ce4153c4001b4ab8ba16b4b1ac9 Mon Sep 17 00:00:00 2001 From: Iddo Date: Tue, 8 Feb 2022 16:35:51 -0600 Subject: [PATCH 2/3] Converted to Python3 and added documentation for the publ_search function --- README.rst | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index a30877e..92965b9 100644 --- a/README.rst +++ b/README.rst @@ -12,29 +12,48 @@ Let's search for `Michael Ley`_, DBLP maintainer. Try :: >>> #do a simple author search for michael ley >>> authors = dblp.search('michael ley') >>> michael = authors[0] - >>> print michael.name + >>> print(michael.name) Michael Ley - >>> print len(michael.publications) + >>> print(len(michael.publications)) 31 If you'd like to learn more about Michael's work, you can explore his publications. All publication results are lazy-loaded, so have at it :: - >>> print michael.publications[0].title + >>> print(michael.publications[0].title) DBLP - Some Lessons Learned. - >>> print michael.publications[0].journal + >>> print(michael.publications[0].journal) PVLDB - >>> print michael.publications[0].year + >>> print(michael.publications[0].year) 2009 More information about a publication can often be found at its `ee` URL - in this case, a link to the PDF :: - >>> print michael.publications[0].ee + >>> print(michael.publications[0].ee) http://www.vldb.org/pvldb/2/vldb09-98.pdf Other publication and author attributes are documented with their respective classes- just use `help()`. Enjoy! .. _Michael Ley: http://www.informatik.uni-trier.de/~ley/ + +If you'd like to learn more about Michael's work, you can explore his publications. All publication results are lazy-loaded, so have at it :: + + >>> print michael.publications[0].title + DBLP - Some Lessons Learned. + >>> print michael.publications[0].journal + PVLDB + +Keyword search :: + >>> import dblp + >>> papers = dblp.publ_search('Protein Function Prediction') + >>> papers[0].authors + ['Pingping Sun', 'Xian Tan', 'Sijia Guo', 'Jingbo Zhang', 'Bojian Sun', 'Ning Du', 'Han Wang', 'Hui Sun'] + >>> papers[0].title + 'Protein Function Prediction Using Function Associations in Protein-Protein Interaction Network.' + >>> papers[0].mdate + '2020-10-26' + + Contributing ============ From 7633484bdac7fd486a3a5afbc5dfeb0dda033156 Mon Sep 17 00:00:00 2001 From: Iddo Date: Tue, 8 Feb 2022 16:44:18 -0600 Subject: [PATCH 3/3] minor change --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 92965b9..122762a 100644 --- a/README.rst +++ b/README.rst @@ -43,7 +43,9 @@ If you'd like to learn more about Michael's work, you can explore his publicatio >>> print michael.publications[0].journal PVLDB + Keyword search :: + >>> import dblp >>> papers = dblp.publ_search('Protein Function Prediction') >>> papers[0].authors