예제 #1
0
 def searcher_translator(self, query):
     """ Translates the given universal query into parameters accepted by the searchers
         returns a translated dictionary
     """ 
     self.searcher_dictionary = self.searcher_to_dict(self.searcher_identity)
     keywords, params = break_query_string(query) 
     #need to check if params contains values such as '+/?/-creator'
     new_keywords,params = self._check_valid(params)
     keywords+=" "+new_keywords
     keywords.strip()
     query_string = keywords
     for key in params:
         value_list = params[key]
         if not isinstance(value_list,list):
             value_list = [value_list]
         for v in value_list:
             if len(query_string)>0:
                 query_string += ","
             query_string += key+"="+v
     translated_dictionary = self._translate_words(params)
     k = self._translate('keywords')
     if not keywords=="" :
         keywords = translated_dictionary[k]+keywords if 'keywords' in translated_dictionary else \
             keywords
         translated_dictionary[k] = keywords
     for mod in query_mods:
         query_string = query_string.replace((mod+"="),mod).replace((mod+"keywords="),mod)
     translated_dictionary["query_string"]=query_string
     
     return translated_dictionary 
예제 #2
0
 def searcher_translator(self, query):
     """ Translates the given universal query into parameters accepted by the searchers
         returns a translated dictionary
     """ 
     self.searcher_dictionary = self.searcher_to_dict(self.searcher_identity)
     keywords, params = break_query_string(query) 
     print "params after breaking"+str(params)
     #need to check if params contains values such as '+/?/-creator'
     keywords += self._check_valid(params)
     translated_dictionary = self._translate_words(params)
     k = self._translate('keywords')
     if not keywords=="" :
         keywords = translated_dictionary[k]+keywords if 'keywords' in translated_dictionary else keywords
         translated_dictionary[k] = str(keywords)
     return translated_dictionary 
예제 #3
0
 def searcher_translator(self, query):
     """ Translates the given universal query into parameters accepted by the searchers
         returns a translated dictionary
     """
     self.searcher_dictionary = self.searcher_to_dict(
         self.searcher_identity)
     keywords, params = break_query_string(query)
     print "params after breaking" + str(params)
     #need to check if params contains values such as '+/?/-creator'
     keywords += self._check_valid(params)
     translated_dictionary = self._translate_words(params)
     k = self._translate('keywords')
     if not keywords == "":
         keywords = translated_dictionary[
             k] + keywords if 'keywords' in translated_dictionary else keywords
         translated_dictionary[k] = str(keywords)
     return translated_dictionary