File size: 1,765 Bytes
91da6cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# general
import os

# visual
import matplotlib.pyplot as plt

cols = ["precision", "recall", "f1-score", "support"]


def generate_plot_by_nikud_dagesh_sin_dict(nikud_dagesh_sin_dict, title, y_axis, plot_folder=None):
    # Create a figure and axis
    plt.figure(figsize=(8, 6))
    plt.title(title)

    ax = plt.gca()
    indexes = list(range(1, len(nikud_dagesh_sin_dict["nikud"]) + 1))

    # Plot data series with different colors and labels
    ax.plot(indexes, nikud_dagesh_sin_dict["nikud"], color='blue', label='Nikud')
    ax.plot(indexes, nikud_dagesh_sin_dict["dagesh"], color='green', label='Dagesh')
    ax.plot(indexes, nikud_dagesh_sin_dict["sin"], color='red', label='Sin')

    # Add legend
    ax.legend()

    # Set labels and title
    ax.set_xlabel('Epoch')
    ax.set_ylabel(y_axis)

    if plot_folder is None:
        plt.show()
    else:
        plt.savefig(os.path.join(plot_folder, f'{title.replace(" ", "_")}_plot.jpg'))


def generate_word_and_letter_accuracy_plot(word_and_letter_accuracy_dict, title, plot_folder=None):
    # Create a figure and axis
    plt.figure(figsize=(8, 6))
    plt.title(title)

    ax = plt.gca()
    indexes = list(range(1, len(word_and_letter_accuracy_dict["all_nikud_letter"]) + 1))

    # Plot data series with different colors and labels
    ax.plot(indexes, word_and_letter_accuracy_dict["all_nikud_letter"], color='blue', label='Letter')
    ax.plot(indexes, word_and_letter_accuracy_dict["all_nikud_word"], color='green', label='Word')

    # Add legend
    ax.legend()

    # Set labels and title
    ax.set_xlabel("Epoch")
    ax.set_ylabel("Accuracy")

    if plot_folder is None:
        plt.show()
    else:
        plt.savefig(os.path.join(plot_folder, 'word_and_letter_accuracy_plot.jpg'))