Ejemplo n.º 1
0
def query_category( qWord ):

	res = DB.category(qWord)
	return_data = [] if res == None else res

	category_lst = return_data[1]

	level_lst = []
	level_dic = {}
	for cat, freq in category_lst:
		cat = cat.replace(":","")
		cat_lst = []



		# print cat, freq
		if not bnc_classcode.smp_bnc_classcode.has_key( cat ):
			cat_lst = cat.split(" ",1)
			cat_lst.append( freq )
			
			
		else:
			cat_lst += bnc_classcode.smp_bnc_classcode[cat]
			cat_lst.append( freq )
			
			level_lst.append( [ build_child( cat_lst ) ])

	target_dic = { "root": reduce( merge_tree , level_lst ) }

	return xmlize( target_dic  )
Ejemplo n.º 2
0
def word_genre(query):
	res = None if skip_mongo_request else DB.category(query)
	return_data = [] if res == None else res[0]
	return Response(json.dumps(return_data), mimetype='application/json')