Beispiel #1
0
 def test_read_words(self):
     words = ["This", "is", "words,", "Anthony!"]
     with tempfile.TemporaryFile(mode="w+") as tmp:
         tmp.write(" ".join(words))
         tmp.seek(0)
         reader = Reader(tmp)
         self.assertEqual(words, [w for w in reader.read_words()])
Beispiel #2
0
    def _build_bohr(self):
        self.bohr = TaskBohr()
        reader = Reader(self.file)

        words = deque()

        for index, word in enumerate(reader.read_words()):
            words.append((index, word))
            if len(words) >= self.MAX_KEY_SIZE:
                self._add_word(words)
                words.popleft()

        while len(words) > 0:
            self._add_word(words)
            words.popleft()