Exemplo n.º 1
0
def getResults(id,typ):
    #print typ
    k={"1":"general","2":"wiki","3":"news"}
    typ=k[typ]    
    dist={}    
    valuesDictionary = {"dictionary":["dictionary_db","dictionary_index","test","dictionary_table"],"news":["news_module","news_index","SRMSE","source2"],"wiki":["starkIndex","wiki","my_wiki","page"],"general":["starkIndex","calIndex","test","source_main1"]}
    get = valuesDictionary[typ]
    database = get[2]
    table = get[3]
    topIds = id
    topResults =[]
    #print topIds,database,table
    if typ !="wiki":
       topResults = FR.fetchResults(topIds,database,table)
    else :
       topResults = FR.fetchResultsWiki(topIds,database,table)
    dist["results"]=topResults
    return dist
Exemplo n.º 2
0
def getQuery(query,typ):
    k={"1":"general","2":"wiki","3":"news","4":"videos"}
    typ=k[typ]    
    dist={}

#    changed_query=SC.checking(query)
#    if query.lower() == changed_query.lower():
#	dist={"Did You Mean: ":""}
 #   else:
#	query=changed_query
#	dist = {"Did You Mean: ":query}
    query = query.lower()
    if typ == "videos":
        remove_videos = ["scene","scenes","videos","videos","clip","clips","videoclips","videoclip"]
        query = query.split()
        new_query = []
        for q in query:
            if q not in new_query:
                new_query.append(q)	
        query = " ".join(new_query)

    valuesDictionary = {"dictionary":["dictionary_db","dictionary_index","test","dictionary_table"],"news":["news","newNewsIndex","SRMSE","source21"],"wiki":["wiki","wiki3","my_wiki","page"],"general":["testIndex","test","test","source_main1"],"videos":["youtube","youtube_index","yt","main_links"]}
    if typ!="wiki":
    	query = MG.removeUnwanted(query.split(" "))
    else:
    	query=query.split()
    #print query
    get = valuesDictionary[typ]
    result = MR.getListQuery(query,get[0],get[1])
    #print get[0],get[1],result
    database = get[2]
    table = get[3]
    if (typ=="news"):
        result = sorted(result,reverse=True)
    if (typ=="general"):
	if len(result)>=10:
    	    topIds = result[:10]
        else:
            topIds = result
	topResults=[]
	if len(topIds)!=0:
                #print topIds
    		topResults = FR.fetchResults(topIds,database,table)
	dist["results"]=topResults
	dist["ids"]= result[10:100]
    elif (typ=="wiki"):
        topIds=result#by default you will get one result only
	topResults=[]
	if len(topIds)!=0:
        	topResults = FR.fetchResultsWiki(topIds,database,table," ".join(query))
        dist["results"]=topResults
        dist["ids"]= result[5:50]

    else:
	topIds=result[:5]
	topResults=[]
	if len(topIds)!=0:
		topResults = FR.fetchResults(topIds,database,table)
	dist["results"]=topResults
	dist["ids"]= result[5:50]            

    return dist