def new_articles(NAVSTACK, STATE): categories = [('arxiv', 'new_cs'), ('arxiv', 'new_physics'), ('arxiv', 'new_q_bio'), ('arxiv', 'new_math'), ('arxiv', 'new_non_linear_math')] action, STATE = navigable_menus.create( categories + [('main_menu', 'back'), ('main_menu', 'back_to_main')], header='main >> arxiv >> new articles', STATE=STATE) return action, NAVSTACK, STATE
def recommended(NAVSTACK, STATE): categories = [('arxiv', 'recommended_cs'), ('arxiv', 'recommended_physics'), ('arxiv', 'recommended_q_bio'), ('arxiv', 'recommended_math'), ('arxiv', 'recommended_non_linear_math')] action, STATE = navigable_menus.create( categories + [('main_menu', 'back'), ('main_menu', 'back_to_main')], header='main >> arxiv >> recommended', STATE=STATE) return action, NAVSTACK, STATE
def new_cs(NAVSTACK, STATE): try: feed_items, STATE = arxiv_api.get_feed(topic='cs', STATE=STATE) except: navigable_menus.error('request timed out. standby...') return ('main_menu', 'do_nothing'), NAVSTACK, STATE articles = navigable_menus.make_articles(feed_items, sys.modules[__name__]) articles = navigable_menus.paginate(articles, page_length=10, menu_options=[ ('main_menu', 'back'), ('main_menu', 'back_to_main'), ('CONTROL', 'previous_page'), ('CONTROL', 'next_page') ]) action, STATE = navigable_menus.create( articles, header='main >> arxiv >> new articles >> cs', STATE=STATE) return action, NAVSTACK, STATE
def search(NAVSTACK, STATE): navigable_menus.make_header('main >> search') search_results, STATE = arxiv_api.search(STATE) if search_results == []: navigable_menus.error('no results found or query empty') return ('main_menu', 'back'), NAVSTACK, STATE articles = navigable_menus.make_articles(search_results, sys.modules[__name__]) articles = navigable_menus.paginate(articles, page_length=10, menu_options=[ ('main_menu', 'back'), ('main_menu', 'back_to_main'), ('CONTROL', 'previous_page'), ('CONTROL', 'next_page') ]) action, STATE = navigable_menus.create(articles, header='main >> search', STATE=STATE) return action, NAVSTACK, STATE
def main(NAVSTACK, STATE): """ create a new menu by: 1. add to this menu e.g ('new', 'index') 2. create a file under menus/ with the same name e.g. 'new' 3. the file should contain 'index' as a function, implemented similarly to this index function. all other functions are implemented the same. 4. NOTE that the function names will match those selectable in the menus """ # refresh search results when back to main menu STATE.search_results = [] action, STATE = navigable_menus.create([ ('arxiv', 'arxiv'), ('search', 'search'), ('man', 'man'), ], header='main', STATE=STATE) return action, NAVSTACK, STATE
def recommended_math(NAVSTACK, STATE): try: feed_items, STATE = arxiv_api.get_feed(topic='math', STATE=STATE) print('-' * 80) print('generating recommendations. standby...') feed_items, STATE = main_ml.predict(feed_items, STATE=STATE) except: navigable_menus.error( 'request timed out or prediction algorithms have failed. standby...' ) articles = navigable_menus.make_articles(feed_items, sys.modules[__name__]) articles = navigable_menus.paginate(articles, page_length=10, menu_options=[ ('main_menu', 'back'), ('main_menu', 'back_to_main'), ('CONTROL', 'previous_page'), ('CONTROL', 'next_page') ]) action, STATE = navigable_menus.create( articles, header='main >> arxiv >> recommended >> math', STATE=STATE) return action, NAVSTACK, STATE