<commit_before>import unittest

from rasa.intent_threshold import IntentThreshold
from rasa.rasa_classifier import RasaClassifier
import json
import codecs
import os



class TestNLPIntegration(unittest.TestCase):
    rasaClassifier = None
    intentThreshold = None

    @classmethod
    def setUpClass(cls):
        cls.rasaClassifier = RasaClassifier()
        cls.rasaClassifier.train(force_train=True)
        cls.intentThreshold = IntentThreshold(min_percent_difference=0.3, min_confidence_threshold=0.4)

    def test_all_claim_category_text(self):
        filepath = os.getcwd() + '/rasa/data/category/claim_category.json'
        data = json.loads(codecs.open(filepath, 'r', 'utf-8').read().encode('utf-8'))
        example_objects = data['rasa_nlu_data']['common_examples']

        for example in example_objects:
            classify_dict = self.rasaClassifier.classify_problem_category(example['text'])
            determined_claim_category = classify_dict['intent']['name']
            self.assertTrue(self.intentThreshold.is_sufficient(classify_dict))
            self.assertTrue(determined_claim_category == example['intent'])<commit_msg>[#280] Added printout for NLP integration test<commit_after>import unittest

from rasa.intent_threshold import IntentThreshold
from rasa.rasa_classifier import RasaClassifier
import json
import codecs
import os


class TestNLPIntegration(unittest.TestCase):
    rasaClassifier = None
    intentThreshold = None

    @classmethod
    def setUpClass(cls):
        cls.rasaClassifier = RasaClassifier()
        cls.rasaClassifier.train(force_train=True)
        cls.intentThreshold = IntentThreshold(min_percent_difference=0.3, min_confidence_threshold=0.4)

    def test_all_claim_category_text(self):
        filepath = os.getcwd() + '/rasa/data/category/claim_category.json'
        data = json.loads(codecs.open(filepath, 'r', 'utf-8').read().encode('utf-8'))
        example_objects = data['rasa_nlu_data']['common_examples']

        for example in example_objects:
            classify_dict = self.rasaClassifier.classify_problem_category(example['text'])
            determined_claim_category = classify_dict['intent']['name']
            self.assertTrue(self.intentThreshold.is_sufficient(classify_dict),
                            "Insufficient Confidence - Intent: {}, Confidence {}"
                            .format(
                                determined_claim_category,
                                classify_dict['intent']['confidence'])
                            )
            self.assertTrue(determined_claim_category == example['intent'])
{'fraction_non_alphanumeric': 0.09736540664375716, 'fraction_numerical': 0.0057273768613974796, 'mean_word_length': 3.3021346469622332, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4219951', 'n_tokens_mistral': 750, 'n_tokens_neox': 723, 'n_words': 118}