TSE_index = Paths.TSE_INDEX, # Translations index path WSE_index = Paths.WSE_INDEX, # Quranic words index path Recitations_list_file = Paths.RECITATIONS_LIST_FILE, Translations_list_file = Paths.TRANSLATIONS_LIST_FILE , Hints_file = Paths.HINTS_FILE, Stats_file = Paths.STATS_FILE, Information_file = Paths.INFORMATION_FILE ) ## prepare a suggestion query suggest_flags = { "action":"suggest", "query": "ابراهيم" } results = RAWoutput.do( suggest_flags ) print "number of missed words", len(results["suggest"]) ## prepare a search query search_flags = { "action":"search", "query": "الحمد لله", "sortedby":"mushaf", "reverse_order": False, "page": 1, "word_info": True, "highlight": "css", "script": "standard", "sura_info": True,
"page": 1, "word_info": True, "highlight": "css", "script": "standard", "prev_aya": True, "next_aya": True, "sura_info": True, "aya_position_info": True, "aya_theme_info": True, "aya_stat_info": True, "aya_sajda_info": True, "translation": 1, "recitation": 1 } results = RAWoutput.do(search_flags) #print(results["search"]["ayas"][1]["sura"]["name"]) #print(results["search"]["ayas"][1]["sura"]["id"]) #print("verse" , results["search"]["ayas"][1]["aya"]["id"]) i = 1 #print(results["search"]["ayas"][i]) while i < len(results["search"]["ayas"]): print(results["search"]["ayas"][i]["sura"]["name"]) print(results["search"]["ayas"][i]["sura"]["id"]) print("verse", results["search"]["ayas"][i]["aya"]["id"]) i = i + 1 pass else: print "\n%s" % red(asr_req.response.error_message) except Exception as e:
''' a console interface for the API. TODO show RAW|JSON | BEST-presentation format TODO __file__ to use resources and indexes integrated with Alfanous Module ''' import sys import json from argparse import ArgumentParser from alfanous.Outputs import Raw RAWoutput = Raw() #use default paths INFORMATION = RAWoutput.do( {"action":"show", "query":"information" } )["show"]["information"] DOMAINS = RAWoutput.do( {"action":"show", "query":"domains" } )["show"]["domains"] HELPMESSAGES = RAWoutput.do( {"action":"show", "query":"help_messages" } )["show"]["help_messages"] arg_parser = ArgumentParser( description = INFORMATION["description"], prog = 'alfanous-console', version = '%(prog)s ' + INFORMATION["version"], usage = sys.argv[0] + " [flags]" ) # add arguments arg_parser.add_argument( "-a", "--action", dest = "action", type = str , choices = DOMAINS["action"], help = HELPMESSAGES["action"] ) arg_parser.add_argument( "-q", "--query", dest = "query", type = str , help = HELPMESSAGES["query"] ) arg_parser.add_argument( "-o", "--offset", dest = "offset", metavar = 'NUMBER', type = int, help = HELPMESSAGES["offset"] ) arg_parser.add_argument( "-r", "--range", dest = "range", type = int, metavar = 'NUMBER', help = HELPMESSAGES["range"] )
a console interface for the API. TODO show RAW|JSON | BEST-presentation format TODO __file__ to use resources and indexes integrated with Alfanous Module ''' import sys import json from argparse import ArgumentParser from alfanous.Outputs import Raw RAWoutput = Raw() #use default paths INFORMATION = RAWoutput.do({ "action": "show", "query": "information" })["show"]["information"] DOMAINS = RAWoutput.do({ "action": "show", "query": "domains" })["show"]["domains"] HELPMESSAGES = RAWoutput.do({ "action": "show", "query": "help_messages" })["show"]["help_messages"] arg_parser = ArgumentParser(description=INFORMATION["description"], prog='alfanous-console', version='%(prog)s ' + INFORMATION["version"], usage=sys.argv[0] + " [flags]")