make sure that we can still mutate cfd normally create cfd with word length as condition incrementing previously unseen key is still possible nonexistent keys shouldn t be added nonexistent keys shouldn t be added make sure that we can still mutate cfd normally create cfd with word length as condition incrementing previously unseen key is still possible new condition added key s frequency incremented from 0 unseen to 1
import unittest

import pytest

from nltk import ConditionalFreqDist, tokenize


class TestEmptyCondFreq(unittest.TestCase):
    def test_tabulate(self):
        empty = ConditionalFreqDist()
        self.assertEqual(empty.conditions(), [])
        with pytest.raises(ValueError):
            empty.tabulate(conditions="BUG")  
        self.assertEqual(empty.conditions(), [])

    def test_plot(self):
        empty = ConditionalFreqDist()
        self.assertEqual(empty.conditions(), [])
        empty.plot(conditions=["BUG"])  
        self.assertEqual(empty.conditions(), [])

    def test_increment(self):
        
        text = "cow cat mouse cat tiger"
        cfd = ConditionalFreqDist()

        
        for word in tokenize.word_tokenize(text):
            condition = len(word)
            cfd[condition][word] += 1

        self.assertEqual(cfd.conditions(), [3, 5])

        
        cfd[2]["hi"] += 1
        self.assertCountEqual(cfd.conditions(), [3, 5, 2])  
        self.assertEqual(
            cfd[2]["hi"], 1
        )