@@ -59,7 +59,8 @@ def set_timeout(self, timeout: int):
5959 def search_pubs (self ,
6060 query : str , patents : bool = True ,
6161 citations : bool = True , year_low : int = None ,
62- year_high : int = None , sortby_date : str = None )-> _SearchScholarIterator :
62+ year_high : int = None , sort_by : str = "relevance" ,
63+ include_last_year : str = "abstracts" )-> _SearchScholarIterator :
6364 """Searches by query and returns a generator of Publication objects
6465
6566 :param query: terms to be searched
@@ -72,8 +73,10 @@ def search_pubs(self,
7273 :type year_low: int, optional
7374 :param year_high: maximum year of publication, defaults to None
7475 :type year_high: int, optional
75- :param sortby_date: 'abstracts' for abstracts, 'everything' for all results
76- :type sortyby_date: string, optional
76+ :param sort_by: 'relevance' or 'date', defaults to 'relevance'
77+ :type sort_by: string, optional
78+ :param include_last_year: 'abstracts' or 'everything', defaults to 'abstracts' and only applies if 'sort_by' is 'date'
79+ :type include_last_year: string, optional
7780 :returns: Generator of Publication objects
7881 :rtype: Iterator[:class:`Publication`]
7982
@@ -124,10 +127,18 @@ def search_pubs(self,
124127 patents = '&as_sdt={0},33' .format (1 - int (patents ))
125128 sortby = ''
126129
127- if sortby_date == 'abstract' :
128- sortby = '&scisbd=1'
129- elif sortby_date == 'everything' :
130- sortby = '&scisbd=2'
130+ if sort_by == "date" :
131+ if include_last_year == "abstracts" :
132+ sortby = '&scisbd=1'
133+ elif include_last_year == "everything" :
134+ sortby = '&scisbd=2'
135+ else :
136+ print ("Invalid option for 'include_last_year', available options: 'everything', 'abstracts'" )
137+ return
138+ elif sort_by != "relevance" :
139+ print ("Invalid option for 'sort_by', available options: 'relevance', 'date'" )
140+ return
141+
131142 # improve str below
132143 url = url + yr_lo + yr_hi + citations + patents + sortby
133144 return self .__nav .search_publications (url )
0 commit comments