예제 #1
0
    def test_search_grid_for_words(self):
        '''
        Ensure that certain patterns can be found in a path_to_word
        '''
        # Create a mock grid with letters A, B, C and D so we can control our letters
        grid = {
            (0, 0): 'A',
            (0, 1): 'B',
            (1, 0): 'C',
            (1, 1): 'D',
        }
        # Define a dictionary of three words - two in the grid and should be found, one not in the grid and should not be found
        twoLetterWord = 'AB'
        threeLetterWord = 'ABC'
        notThereWord = 'EEE'

        # ***CHANGED AFTER PRUNING TO INCLUDE BOTH FULL WORDS AND STEMS***
        fullwords = [twoLetterWord, threeLetterWord, notThereWord]
        stems = ['A', 'AB', 'E', 'EE']
        dictionary = fullwords, stems

        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
예제 #2
0
    def test_search_grid_for_words(self):
        """
        Ensure that certain patterns can be found in a path_to_word
        """
        grid = {(0, 0): "A", (0, 1): "B", (1, 0): "C", (1, 1): "D"}
        twoLetterWord = "AB"
        threeLetterWord = "ABC"
        notThereWord = "EEE"

        print("twoLeterWord = ", twoLetterWord, "threeLetterWord = ",
              threeLetterWord, "notThereWord = ", notThereWord)

        full_words = [twoLetterWord, threeLetterWord, notThereWord]
        stems = ['A', 'AB', 'E', 'EE']
        dictionary = full_words, stems
        print("full_words = ", full_words)
        print("stems = ", stems)
        print("dictionary = ", dictionary)

        foundWords = boggle.search(grid, dictionary)
        print("foundWords = ", foundWords)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
예제 #3
0
    def test_converting_a_path_to_a_word(self):
        """
        Ensure that paths can be converted to words
        """
        grid = boggle.make_grid(2,2)
        oneLetterWord = boggle.path_to_word(grid, [(0,0)])
        twoLetterWord = boggle. path_to_word(grid, [(0,0), (1,1)])
        self. assertEqual(oneLetterWord, grid[(0,0)])
        self.assertEqual(twoLetterWord, grid[(0,0)] + grid[(1, 1)]
    def test_search_grid_for_words(self)
    """
    Ensure that certain patterns can be found in a path_to_word
    """
    grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D' }
    twoLetterWord = 'AB'
    threeLetterWord = 'ABC'
    notThereWord = 'EEE'
    fullwords = [twoLetterWord, threeLetterWord, notThereWord]
    stems = ['A', 'AB', 'E', 'EE']
    dictionary = fullwords, stems
    foundWords = boggle.search(grid, dictionary)
    self.assertTrue(twoLetterWord in foundWords)
    self.assertTrue(threeLetterWord in foundWords)
    self.assertTrue(notThereWord not in foundWords)
def test_load_dictionary(self):
    """
    Test that the 'get_dictionary' function returns a dictionary
    that has a length greater than 0
    """
    dictionary = boggle.get_dictionary('words.txt')
    self. assertGreater(len(dictionary), 0)
예제 #4
0
    def test_search_grid_for_words(self):
        """
        Ensure that certain patterns can be found in a `path_to_word`
        For this test we will create a mock grid so that we can control the letters.
        We also define a dictionary of three words. So ab, abc and eee. Two of those
        words are in the grid and should be found. One of those words is not in the 
        grid and should not be found. In this case we're using the assert true for 
        all three of the words 
        """
        """
        test creates a mock dictionary that no longer
        matches the tuple of two sets that the program now uses. A simple fix, although
        not the best one, is to modify the test to include the stems of the test word
        now if we rerun the unit tests you will see that they pass with. 
        
        dictionary = [twoLetterWord, threeLetterWord, notThereWord]
        """
        grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'}
        twoLetterWord = 'AB'
        threeLetterWord = 'ABC'
        notThereWord = 'EEE'
        fullwords = [twoLetterWord, threeLetterWord, notThereWord]
        stems = ['A', 'AB', 'E', 'EE']
        dictionary = fullwords, stems

        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
    def test_search_grid_for_words(self):
        grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'}
        twoLetterWord = 'AB'
        threeLetterWord = 'ABC'
        notThereWord = 'EEE'
        dictionary = [twoLetterWord, threeLetterWord, notThereWord]

        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
예제 #6
0
    def test_search_grid_for_words(self):
        grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'}
        twoLetterWord = 'AB'
        threeLetterWord = 'ABC'
        notThereWord = "EEE"
        dictionary = [twoLetterWord, threeLetterWord, notThereWord]

        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
예제 #7
0
def test_search_grid_for_words(self):
    grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'}
    two_letter_word = 'AB'
    three_letter_word = 'ABC'
    not_there_word = 'EEE'
    dictionary = [two_letter_word, three_letter_word, not_there_word]

    found_words = boggle.search(grid, dictionary)

    self.assertTrue(two_letter_word in found_words)
    self.assertTrue(three_letter_word in found_words)
    self.assertTrue(not_there_word not in found_words)
예제 #8
0
    def test_search_grid_for_words(self):
        # Esure that certain patterns can be found in a path_to_word
        grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'}
        twoLetterWord = 'AB'
        threeLetterWord = 'ABC'
        notThereWord = 'EEE'
        dictionary = [twoLetterWord, threeLetterWord, notThereWord]

        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
 def test_search_grid_for_words(self):
     """
     ensure that certain patterns can be found in a path_to_word
     """
     grid = {(0, 0) : "A", (0, 1) : "B", (1, 0) : "C", (1, 1) : "D"}
     twoLetterWord = "AB"
     threeLetterWord = "ABC"
     notThereWord = "EEE"
     dictionary = [twoLetterWord, threeLetterWord, notThereWord]
     
     foundWords = boggle.search(grid, dictionary)
     self.assertTrue(twoLetterWord in foundWords)
     self.assertTrue(threeLetterWord in foundWords)
     self.assertTrue(notThereWord not in foundWords)
예제 #10
0
    def test_search_grid_for_words(self):

        #ensure that certain patterns can be found in a path_to_word
        #create mock grid so we can control the letters. `2x2  grid containing a,b,c,d
        grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'}
        twoLetterWord = 'AB'
        threeLetterWord = 'ABC'
        notThereWord = 'EEE'
        dictionary = [twoLetterWord, threeLetterWord, notThereWord]

        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
예제 #11
0
    def test_search_grid_for_words(self):
        grid = {(1, 0): 'C', (1, 1): 'D', (0, 0): 'A', (0, 1): 'B'}
        twoLetterWord = 'AB'
        threeLetterWord = 'BAD'
        notThereWord = 'EEE'

        fullWords = [twoLetterWord, threeLetterWord, notThereWord]
        stems = ['A', 'AB', 'B', 'BA', 'E', 'EE']
        dictionary = fullWords, stems

        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
예제 #12
0
    def test_search_grid_for_words(self):
        grid = {(0, 0): "A", (0, 1): "B", (1, 0): "C", (1, 1): "D"}
        twoLetterWord = "AB"
        threeLetterWord = "ABC"
        notThereWord = "EEE"
        fullwords = [twoLetterWord, threeLetterWord, notThereWord]
        stems = ['A', 'AB', 'E', 'EE']

        dictionary = fullwords, stems

        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
예제 #13
0
    def test_search_grid_for_words(self):
        """
        Ensure that certain patterns can be found in a `path_to_word`
        """  
        grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'}
        twoLetterWord = 'AB'
        threeLetterWord = 'ABC'
        notThereWord = 'EEE'
        fullwords = [twoLetterWord, threeLetterWord, notThereWord]
        stems = ['A','AB','E','EE']
        dictionary = fullwords, stems
        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
예제 #14
0
 def test_search_grid_for_words(self):
     #ensure certain patterns can be found in a path_to_word
     #create mock grid so we can control the letters
     
     grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'} #2x2 grid
     twoLetterWord = 'AB'
     threeLetterWord = 'ABC'
     notThereWord = 'EEE'
     fullwords = [twoLetterWord, threeLetterWord, notThereWord]
     stems = ['A', 'AB', 'E', 'EE']
     dictionary = fullwords, stems
     
     foundWords = boggle.search(grid, dictionary)
     
     self.assertTrue(twoLetterWord in foundWords)
     self.assertTrue(threeLetterWord in foundWords)
     self.assertTrue(notThereWord not in foundWords)
예제 #15
0
    def test_search_grid_for_words(self):
        """
        Test case to verify that a pattern of words can be found
        """
        grid = {(0, 0): "A", (0, 1): "B", (1, 0): "C", (1, 1): "D"}
        twoLetterWord = "AB"
        threeLetterWord = "ABC"
        wordNotInGrid = "EEE"

        full_words = [twoLetterWord, threeLetterWord, wordNotInGrid]
        stems = ["A", "AB", "E", "EE"]
        dictionary = full_words, stems

        wordMatch = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in wordMatch)
        self.assertTrue(threeLetterWord in wordMatch)
        self.assertTrue(wordNotInGrid not in wordMatch)
예제 #16
0
    def test_search_grid_for_words(self):
        """
        ENSURE THAT CERTAIN PATTERNS CAN BE FOUND IN path_to_word
        """
        grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'}
        twoLetterWord = 'AB'
        threeLetterWord = 'ABC'
        notThereWord = 'EEE'

        fullwords = [twoLetterWord, threeLetterWord, notThereWord]
        stems = ['A', 'AB', 'E', 'EE']
        dictionary = fullwords, stems

        foundwords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundwords)
        self.assertTrue(threeLetterWord in foundwords)
        self.assertTrue(notThereWord not in foundwords)
예제 #17
0
    def test_search_grid_for_words(self):
        """
        Ensure That Certain Patterns Can Be Found In A Path_To_Word
        """
        grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'}
        twoLetterWord = 'AB'
        threeLetterWord = 'ABC'
        notThereWord = 'EEE'

        fullwords = [twoLetterWord, threeLetterWord, notThereWord]
        stems = ['A', 'AB', 'E', 'EE']
        dictionary = fullwords, stems

        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
예제 #18
0
    def test_search_grid_for_words(self):
        """
        Ensure that certain pattersn can be found in path_to_word
        """
        grid = {
            (0, 0): "A",
            (0, 1): "B",
            (1, 0): "C",
            (1, 1): "D"
        }  # Define a mock grid to control the letters
        twoLetterWord = "AB"
        threeLetterWord = "ABC"  # We also define a dictionary of three words
        notThereWord = "EEE"
        dictionary = [twoLetterWord, threeLetterWord, notThereWord]

        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
예제 #19
0
   def test_search_grid_for_words(self):
        """
        Ensure that certain patterns can be found in a `path_to_word`
        For this test we will create a mock grid so that we can control the letters.
        We also define a dictionary of three words.
        """
        grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'}
        twoLetterWord = 'AB'
        threeLetterWord = 'ABC'
        notThereWord = 'EEE'
        
        fullwords = [twoLetterWord, threeLetterWord, notThereWord]
        stems = ['A', 'AB', 'E', 'EE']
        dictionary = fullwords, stems

        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
예제 #20
0
 def test_search_grid_for_words(self):
     """
     Ensure that certain patterns can be found in a path_to_word
     """
     # So for this test we will create a mock grid so that we can control the letters.
     # In this case it's a 2x2 grid containing the letters a b c and d
     
     grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'}
     twoLetterWord = 'AB'
     threeLetterWord = 'ABC'
     notThereWord = 'EEE'
     
     fullwords = [twoLetterWord, threeLetterWord, notThereWord]
     stems = ['A', 'AB', 'E', 'EE']
     dictionary = fullwords, stems
     
     foundWords = boggle.search(grid, dictionary)
     
     self.assertTrue(twoLetterWord in foundWords)
     self.assertTrue(threeLetterWord in foundWords)
     self.assertTrue(notThereWord not in foundWords)
예제 #21
0
def test_search_grid_for_words(self):
    #ensure certain patterns can be found in path_to_Word
    grid = {(0, 0): 'A' , (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'}
    twoLetterword = 'AB'
    threeLetterword = 'ABC'
    notThereWord= 'EEE'
    dictionary = [twoLetterword, threeLetterword, notThereWord
    
    foundwords = boggle.search(grid, dictionary)
    
    self.assertTrue(twoLetterword in foundwords)
    self.assertTrue(threeLetterword in foundwords)
    self.assertTrue(not  notThereWord in foundwords)
    
    def test_load_dictionary(self):
        #test that the 'get_dictionary' function returns a dictionary that has length greater than 0 
        dictionary = boggle.get_dictionary('words.txt'
        self.assertGreater(len(dictionary), 0)
        
        
    
예제 #22
0
    def test_search_grid_for_words(self):
        '''
        make sure that certain words can be found in certain path patterns 
        within the grid
        '''
        grid = {(0, 0): "A", (0, 1): "B", (1, 0): "C", (1, 1): "D"}
        oneLetterWord = "A"
        twoLetterWord = "AB"
        threeLetterWord = "ABC"
        notThereWord = "EEE"
        fullWords = [
            oneLetterWord, twoLetterWord, threeLetterWord, notThereWord
        ]
        partialWords = ["A", "AB", "E", "EE"]
        dictionary = fullWords, partialWords
        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(oneLetterWord in foundWords)
        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)
예제 #23
0
    def test_search_grid_for_words(
        self
    ):  # need to find words in the grid. need to ensure that certain patterns can be found in a path
        """
        Ensure that certain patterns can be found in a path_to_word
        """
        grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D'}
        twoLetterWord = 'AB'
        threeLetterWord = 'ABC'
        notThereWord = 'EEE'

        #dictionary = [twoLetterWord, threeLetterWord, notThereWord]
        fullwords = [twoLetterWord, threeLetterWord, notThereWord]
        stems = [
            'A', 'AB', 'E', 'EE'
        ]  # a fix not the best one is to include the stems of the test word
        dictionary = fullwords, stems

        foundWords = boggle.search(grid, dictionary)

        self.assertTrue(twoLetterWord in foundWords)
        self.assertTrue(threeLetterWord in foundWords)
        self.assertTrue(notThereWord not in foundWords)