Exemple #1
0
 def test_export_import(self):
     test_dict = dictionary.Dictionary(["test_data/test_file.txt"])
     dictionary.Dictionary.export_dict(test_dict,
                                       "test_data/test_file.pickle")
     imported_dict = dictionary.Dictionary.import_dict(
         "test_data/test_file.pickle")
     self.assertEqual(test_dict, imported_dict)
Exemple #2
0
 def test_get_children(self):
     test_dict = dictionary.Dictionary(["test_data/test_file.txt"])
     self.assertEqual(test_dict.get_children("Gdańsk"), [
         'Gdański', 'Gdańska', 'Gdańsków', 'Gdańskowi', 'Gdańskom',
         'Gdańsk', 'Gdański', 'Gdańskiem', 'Gdańskami', 'Gdańsku',
         'Gdańskach', 'Gdańsku', 'Gdański'
     ])
Exemple #3
0
 def test_get_children_multisegmented(self):
     test_dict = dictionary.Dictionary(["test_data/pospolite.txt"])
     test_dict.add_multisegmented(["test_data/WS_test.txt"])
     self.assertEqual(test_dict.get_children_multisegmented("albo Argus"), [
         'albo Argusa', 'albo Argusowi', 'albo Argusa', 'albo Argusem',
         'albo Argusie', 'albo Argusie'
     ])
Exemple #4
0
 def test_get_parent_multisegmented(self):
     test_dict = dictionary.Dictionary(["test_data/pospolite.txt"])
     test_dict.add_multisegmented(["test_data/WS_test.txt"])
     self.assertEqual(
         test_dict.get_parent_multisegmented("złej Apokalipsy"),
         ('zła Apokalipsa', [[False, False], None]))
Exemple #5
0
 def test_get_word_by_relationship(self):
     test_dict = dictionary.Dictionary(["test_data/pospolite.txt"])
     test_dict.add_gradation_relationship("test_data/adj.txt")
     self.assertEqual(
         test_dict.get_word_by_relationship("hst", "największy"),
         ('duży', '*CAB', []))
Exemple #6
0
 def test_get_all_relationships(self):
     test_dict = dictionary.Dictionary(["test_data/pospolite.txt"])
     test_dict.add_gradation_relationship("test_data/adj.txt")
     self.assertEqual(test_dict.get_all_relationships(), ['hr', 'hst'])
Exemple #7
0
 def test_get_parent(self):
     test_dict = dictionary.Dictionary(["test_data/test_file.txt"])
     self.assertEqual(test_dict.get_parent("Gdańska")[0], "Gdańsk")
     self.assertEqual(test_dict.get_parent("Gdańska")[1], "AA")
Exemple #8
0
if __name__ == '__main__':
    print("-----------------------Test szybkości biblioteki - część jednosegmentowa-----------------------")
    for i in [100, 300, 600, 900]:
        filename = "test_data/test_file_" + str(i) + ".txt"
        print("===============================================================================================")
        print("Rozmiar testowanego pliku: " + str(
            math.ceil(os.stat(filename).st_size / 1024)) + "KB")

        number_of_lines = 0
        with open(filename, 'r', encoding="utf8") as f:
            for line in f:
                number_of_lines += 1
        print("Ilość wpisów w testowanym pliku: ", number_of_lines)

        start_of_building = time()
        test_dict = dictionary.Dictionary([filename])
        end_of_building = time()
        print("Czas budowy struktury: " + str(end_of_building - start_of_building) + "s")
        print("Średni czas trwania przetworzenia jednego wpisu: "
              + str((end_of_building - start_of_building) / number_of_lines))

        start_get_parent = time()
        test_dict.get_parent("Gdański")
        end_get_parent = time()
        print("Czas odpytania o rodzica: " + str(end_get_parent - start_get_parent) + "s")

        start_get_children = time()
        test_dict.get_parent("Gdański")
        end_get_children = time()
        print("Czas odpytania o dziecko: " + str(end_get_children - start_get_children) + "s")