예제 #1
0
 def reply(self, query):
     """
     基于检索的方式,返回query的answer
     :param query: 用户输入问句
     :return: 答案
     """
     answer = ""
     self.query = normalize_query(query)  # 问句预处理
     self.debug("[ start RetrievalBot reply ]")
     self.debug("query=%s", self.query)
     if self.query:
         answer = self.get_answer(self.query)
     else:
         self.warn("@@@@@@@@@@@@@@@@@@@ unexpected value, query is None")
     self.debug("answer=%s", answer)
     self.debug("[ end RetrievalBot reply ]")
     return answer
예제 #2
0
    def reply(self, query):
        """
        根据query返回答案
        :param query: 用户输入问句
        :return: 答案
        """
        answer = ""
        self.query = normalize_query(query)
        self.debug("[start TemplateBot reply]")
        self.debug('query=%s', self.query)

        if self.query:
            triple_docs = self.get_triple()  # 与问句可能相关的三元组
            answer = self.get_answer(triple_docs)
        else:
            self.warn("@@@@@@@@@@@@@@@@@@@ unexpected value, query is None")

        self.debug('answer=%s', answer)
        self.debug("[end TemplateBot reply]")
        return answer
def _get_shopping_url(query, page=0, per_page=10):
    return "http://www.google.com/search?hl=en&q={0}&tbm=shop&start={1}&num={2}".format(
        normalize_query(query), page * per_page, per_page)
def _get_shopping_url(query, page=0, per_page=10):
    return "http://www.google.com/search?hl=en&q={0}&tbm=shop&start={1}&num={2}".format(normalize_query(query), page * per_page, per_page)