Beispiel #1
0
    def  __init__(self):
        print("Welcome to AutoFAQ. Initializing AutoFAQ for you ...")
        
        parser = argparse.ArgumentParser()
        parser.add_argument("-d","--debug",help="Run the program in debug mode", action="store_true")
        args = parser.parse_args()
        self._debug = args.debug

        #Initialized the list of stopwords
        self._stopwords=nltk.corpus.stopwords.words('english')

        #Parse the xml
        (self._quesList,self._ansList)=qna_parser.parse_xml(params.faqFile)
        #self._quesList=map(lambda ques:ques.lower(), self._quesList)
        #self._ansList=map(lambda ques:ques.lower(), self._ansList)
        self._quesListProcessed = map(lambda q:self.preprocess_query(q), self._quesList)
        self._matrix=type_similarity.get_matrix_english(params.similarity_matrix_file)

        #Parse the templates
        (self._templates,self._qtypes)=templateParser.parse_xml(params.templateFile)
        if self._debug:
            print self._templates
            print self._qtypes

        output=self.validate_input_file()
        if not output:
            print "Input file not Valid."
            sys.exit(-1)
        else:
            print "Input file validated."

        return
Beispiel #2
0
	def testToCheckIdenticalQueriesToFAQ(self):
		(self._quesList,self._ansList)=qna_parser.parse_xml(params.faqFile)
		'''use closest_question_index function to find the type of the given query'''
		autofaq=AutoFAQ.AutoFAQ()
		for ques in self._quesList:
			closest_ques=autofaq.closest_question_index(ques)
			self.assertEqual(ques,closest_ques)