def test_search_keyword(self): """ When we search for the keyword "3d_shape" the author Steven A. Cholewiak should be among those listed """ authors = [a.name for a in scholarly.search_keyword('3d_shape')] self.assertIsNot(len(authors), 0) self.assertIn(u'Steven A. Cholewiak, PhD', authors)
def test_search_keyword_empty_keyword(self): """ As of 2020-04-30, there are 6 individuals that match the name 'label' """ # TODO this seems like undesirable functionality for # scholarly.search_keyword() with empty string. Surely, no authors # should be returned. Consider modifying the method itself. authors = [a for a in scholarly.search_keyword('')] self.assertGreaterEqual(len(authors), 6)
def scholarlyBookKeyword(): try: query = request.form['query'] search_query = scholarly.search_keyword(query) string = '' for i in range(5): try: author = next(search_query) string += author.blb['eprint'] except: print('') if (len(string) > 0): string = string[:-1] return json.loads(str(string)) except Exception as e: response = "Error occured please check your input" return response
def search_keyword(query: str) -> None: search_query = scholarly.search_keyword(query) paper = next(search_query) print(paper)
def get_author_generator_from_keyword(keyword): """ This method gets a generator of the authors with a keyword """ author_gen = scholarly.search_keyword(keyword) return author_gen
import os import sys import time import argparse sys.path.append('scholarly') from scholarly import scholarly os.makedirs('Results/', exist_ok=True) parser = argparse.ArgumentParser() parser.add_argument('--category', default='artificial_intelligence') args = parser.parse_args() query = scholarly.search_keyword(args.category) start_time = time.time() for i, author in enumerate(query): author.yearly_citations = scholarly.search_id(author.id) elapsed_seconds = time.time() - start_time str_time = '{:02d}:{:02d}:{:02d}'.format( int(elapsed_seconds // 3600), int((elapsed_seconds % 3600) / 60), int(elapsed_seconds % 60)) try: citedby = author.citedby except: citedby = 0