Esempio n. 1
0
 def __init__(self):
     self.lemmatizer = Lemmatizer()
     self.stopwords = []
     self.limits = {
         'unreachable_questions_limit': conf.get("UNREACHABLE_QUESTIONS_LIMIT"),
         'questions_at_root_threshold': conf.get('NUMBER_OF_QUESTIONS_AT_ROOT_THRESHOLD'),
         'questions_at_root_limit': conf.get("QUESTIONS_AT_ROOT_LIMIT")
     }
Esempio n. 2
0
    def run_diagnostics(self, args):
        self.file_path = args['input_file_path']
        self.language = args['language']
        self.read_file()
        if not self.file_data:
            oa_logger.error("Ontology not present in input file")
            return
        self.threshold = conf.get("PATH_COVERAGE")
        self.stopwords = StopWords.get_stop_words(self.file_data, self.language)
        try:
            self.lemmatizer.set_language(self.language)
            oa_logger.info('Ontology analyzer started')
            root_node, parent_faq_map, parent_tags_map = self.fetch_ontology()

            return root_node, parent_faq_map, parent_tags_map 

            # print("root ",root_node)
            # print("parent_Faq ",parent_faq_map)
            # print("parent_tags_map ",parent_tags_map)
            quit()

            self.tree_traversal = [node for node in PreOrderIter(root_node)]
            response = dict()
            timestamp = datetime.datetime.utcnow().isoformat() + 'Z'

            response['timestamp'] = timestamp
            response['language'] = self.language

            suggestions = 0
            errors = 0
            warnings = 0

            result, present_or_not = self.check_unreachable_questions(root_node, parent_faq_map, parent_tags_map)
            response['unreachable_questions'] = {'result': result, 'type': 'error'}
            errors += int(present_or_not)
            oa_logger.debug('Ontology analyzer: Check 1 (unreachable_questions) done for bot:' + root_node.name[
                NODE_NAME] + ' and issue present: ' + str(present_or_not))

            result, present_or_not = self.check_questions_at_root(root_node, parent_faq_map, parent_tags_map)
            response['questions_at_root'] = {'result': result, 'type': 'suggestion'}
            suggestions += int(present_or_not)
            oa_logger.debug('Ontology analyzer: Check 2 (questions_at_root) done for bot:' + root_node.name[
                NODE_NAME] + ' and issue present: ' + str(present_or_not))

            response['no_of_suggestions'] = suggestions
            response['no_of_errors'] = errors
            response['no_of_warnings'] = warnings

            response['total_no_of_issues'] = suggestions + errors + warnings

            oa_logger.info('Ontology analyzer ran for bot:' + root_node.name[NODE_NAME])
            # oa_logger.debug('Ontology analyzer response for bot:' + root_node.name[NODE_NAME] + ' : ' + str(response))
            self.generate_csv_report(response, 'analyzer_report.csv')
            print('Report generated and saved in analyzer_report.csv file ...')
        except Exception as e:
            oa_logger.debug(e)
            traceback.print_exc()