<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
from vocabulary import Vocabulary as vb
# import Vocabulary as vb
try:
    import simplejson as json
except ImportError:
    import json


class TestModule(unittest.TestCase):
    """Checks for the sanity of all module methods"""

    def test_meaning(self):
        current_result = vb.meaning("humming")
        result = '[{"seq": 0, "text": "Present participle of hum."}]'
        middle_val = json.loads(result)
        expected_result = json.dumps(middle_val)
        self.assertEqual(current_result, expected_result)

    def test_synonym(self):
        current_result = vb.synonym("repudiate")
        result = '[{"seq": 0, "text": "deny"}]'
        middle_val = json.loads(result)
        expected_result = json.dumps(middle_val)
        self.assertEqual(current_result, expected_result)

    def test_antonym_1(self):
        current_result = vb.antonym("love")
        result = '{"text": ["hate"]}'
        expected_result = json.loads(result)
        self.assertEqual(current_result, expected_result)

    def test_antonym_2(self):
        current_result = vb.antonym("respect")
        result = '{"text": ["disesteem", "disrespect"]}'
        expected_result = json.loads(result)
        self.assertEqual(current_result, expected_result)

    def test_partOfSpeech_1(self):
        current_result = vb.part_of_speech("hello")
        result = '[{"text": "interjection", "example:": "Used to greet someone, answer the telephone, or express surprise.", "seq": 0}]'
        middle_val = json.loads(result)
        expected_result = json.dumps(middle_val)
        self.assertEqual(current_result, expected_result)

    def test_partOfSpeech_2(self):
        current_result = vb.part_of_speech("rapidly")
        result = '[{"text": "adverb", "example:": "With speed; in a rapid manner.", "seq": 0}]'
        middle_val = json.loads(result)
        expected_result = json.dumps(middle_val)
        self.assertEqual(current_result, expected_result)

    def test_usageExamples(self):
        current_result = vb.usage_example("hillock")
        result = '[{"seq": 0, "text": "I went to the to of the hillock to look around."}]'
        middle_val = json.loads(result)
        expected_result = json.dumps(middle_val)
        self.assertEqual(current_result, expected_result)
    
    def test_pronunciation(self):
        current_result = vb.pronunciation("hippopotamus")
        result = '[{"rawType": "ahd-legacy", "raw": "(hĭpˌə-pŏtˈə-məs)", "seq": 0}, {"rawType": "arpabet", "raw": "HH IH2 P AH0 P AA1 T AH0 M AH0 S", "seq": 0}]'
        expected_result = json.loads(result)
        self.assertEqual(current_result, expected_result)
    
    def test_hyphenation(self):
        current_result = vb.hyphenation("hippopotamus")
        result = '[{"seq": 0, "text": "hip", "type": "secondary stress"}, {"seq": 1, "text": "po"}, {"seq": 2, "text": "pot", "type": "stress"}, {"seq": 3, "text": "a"}, {"seq": 4, "text": "mus"}]'
        middle_val = json.loads(result)
        expected_result = json.dumps(middle_val)
        self.assertEqual(current_result, expected_result)

if __name__ == "__main__":
    unittest.main()<commit_msg>adding usageExamples test for non valid word<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
from vocabulary import Vocabulary as vb
# import Vocabulary as vb
try:
    import simplejson as json
except ImportError:
    import json


class TestModule(unittest.TestCase):
    """Checks for the sanity of all module methods"""

    def test_meaning(self):
        current_result = vb.meaning("humming")
        result = '[{"seq": 0, "text": "Present participle of hum."}]'
        middle_val = json.loads(result)
        expected_result = json.dumps(middle_val)
        self.assertEqual(current_result, expected_result)

    def test_synonym(self):
        current_result = vb.synonym("repudiate")
        result = '[{"seq": 0, "text": "deny"}]'
        middle_val = json.loads(result)
        expected_result = json.dumps(middle_val)
        self.assertEqual(current_result, expected_result)

    def test_antonym_1(self):
        current_result = vb.antonym("love")
        result = '{"text": ["hate"]}'
        expected_result = json.loads(result)
        self.assertEqual(current_result, expected_result)

    def test_antonym_2(self):
        current_result = vb.antonym("respect")
        result = '{"text": ["disesteem", "disrespect"]}'
        expected_result = json.loads(result)
        self.assertEqual(current_result, expected_result)

    def test_partOfSpeech_1(self):
        current_result = vb.part_of_speech("hello")
        result = '[{"text": "interjection", "example:": "Used to greet someone, answer the telephone, or express surprise.", "seq": 0}]'
        middle_val = json.loads(result)
        expected_result = json.dumps(middle_val)
        self.assertEqual(current_result, expected_result)

    def test_partOfSpeech_2(self):
        current_result = vb.part_of_speech("rapidly")
        result = '[{"text": "adverb", "example:": "With speed; in a rapid manner.", "seq": 0}]'
        middle_val = json.loads(result)
        expected_result = json.dumps(middle_val)
        self.assertEqual(current_result, expected_result)

    def test_usageExamples1(self):
        current_result = vb.usage_example("hillock") # for valid word
        result = '[{"seq": 0, "text": "I went to the to of the hillock to look around."}]'
        middle_val = json.loads(result)
        expected_result = json.dumps(middle_val)
        self.assertEqual(current_result, expected_result)
        
    def test_usageExamples2(self):
        current_result = vb.usage_example("lksj") # # for non valid word
        expected_result = False
        self.assertEqual(current_result, expected_result)
    
    def test_pronunciation(self):
        current_result = vb.pronunciation("hippopotamus")
        result = '[{"rawType": "ahd-legacy", "raw": "(hĭpˌə-pŏtˈə-məs)", "seq": 0}, {"rawType": "arpabet", "raw": "HH IH2 P AH0 P AA1 T AH0 M AH0 S", "seq": 0}]'
        expected_result = json.loads(result)
        self.assertEqual(current_result, expected_result)
    
    def test_hyphenation(self):
        current_result = vb.hyphenation("hippopotamus")
        result = '[{"seq": 0, "text": "hip", "type": "secondary stress"}, {"seq": 1, "text": "po"}, {"seq": 2, "text": "pot", "type": "stress"}, {"seq": 3, "text": "a"}, {"seq": 4, "text": "mus"}]'
        middle_val = json.loads(result)
        expected_result = json.dumps(middle_val)
        self.assertEqual(current_result, expected_result)

if __name__ == "__main__":
    unittest.main()
{'fraction_non_alphanumeric': 0.1412133891213389, 'fraction_numerical': 0.006873879258816497, 'mean_word_length': 3.380235602094241, 'pattern_counts': {'":': 66, '<': 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': '1474357', 'n_tokens_mistral': 2164, 'n_tokens_neox': 2107, 'n_words': 490}