def process_answer(self): _logger.info("Retrieving {} Wikipedia pages...".format( self.search_depth)) search_wikipedia(self.question_keywords, self.search_depth) # Anaphora Resolution wiki_pages = search_rank(self.query) _logger.info("Pages retrieved: {}".format(len(wiki_pages))) self.candidate_answers, keywords = get_candidate_answers( self.query, wiki_pages, self.nlp) _logger.info("Candidate answers ({}):\n{}".format( len(self.candidate_answers), '\n'.join(self.candidate_answers))) return " ".join(self.candidate_answers)
def process_answer(self): _logger.info("Retrieving {} Wikipedia pages...".format( self.search_depth)) search_wikipedia(self.question_keywords, self.search_depth) # wiki_pages = fetch_wiki(self.question_keywords, number_of_search=self.search_depth) # Anaphora Resolution # ranked_wiki_docs = rank_docs(self.question_keywords, wiki_pages) wiki_pages = search_rank(self.query) _logger.info("Pages retrieved: {}".format(len(wiki_pages))) # _logger.debug("Ranked pages: {}".format(ranked_wiki_docs)) self.candidate_answers, keywords = get_candidate_answers( self.query, wiki_pages, self.nlp) _logger.info("Candidate answers ({}):\n{}".format( len(self.candidate_answers), '\n'.join(self.candidate_answers))) return " ".join(self.candidate_answers)
for sent in simi_sorted: sent_id = sent[0] candidate_ans.append(str(sentences[sent_id])) return candidate_ans, keywords_query if __name__ == "__main__": import spacy from qas.constants import EN_MODEL_MD from qas.model.query_container import QueryContainer from qas.wiki.wiki_search import search_wikipedia from qas.doc_search_rank import search_rank logging.basicConfig(level=logging.DEBUG) lquestion_keywords = ['Albert Einstein', 'birth'] lquery_raw = list([[['Albert Einstein', 'birth'], [], [], []]]) lquery = [] for qr in lquery_raw: lquery.append(QueryContainer(qr)) search_wikipedia(lquestion_keywords, 3) lwiki_pages = search_rank(lquery_raw) len_nlp = spacy.load(EN_MODEL_MD) candidate_answers, keywords = get_candidate_answers( lquery, lwiki_pages, len_nlp) print(' '.join(candidate_answers))