9
9
10
10
11
11
12
- # print("\n Dla jakiej partii chcesz wygenerować tweet?")
13
- # party = (str(input())).upper()
14
12
15
- # filename = "models/" + party + "_15-iter_trained_model.sav"
16
- # loaded_model = pickle.load(open(filename, "rb"))
17
-
18
-
19
- # print("\n Podaj liczbę słów wejciowych:")
20
- # input_words_num = int(input())
21
-
22
- # print("\n Podaj oczekiwaną liczbę słów w zdaniu:")
23
- # total_words_num = int(input())
24
-
25
- # print("\n Które w kolejnoci najbliższe słowo ma zostać wygenerowane jako następne? Podaj liczbę większą od 0.")
26
- # n = int(input())
27
-
28
-
29
- # word_list = []
30
-
31
- # if input_words_num == 1:
32
-
33
- # print("\n Podaj pierwsze słowo:")
34
-
35
- # first_word = str(input())
36
- # word_list.append(first_word)
37
-
38
- # elif input_words_num > 1:
39
-
40
- # for i in range(0, input_words_num):
41
-
42
- # print("\n Podaj " + str(i+1) + " słowo:")
43
-
44
- # word = str(input())
45
- # word_list.append(word)
46
13
47
14
class Tweet_generator ():
48
15
@@ -61,13 +28,13 @@ def tweet_gen(input_words_num, total_words_num, word_list, similar_num, party):
61
28
62
29
63
30
predicted_word = loaded_model .wv .most_similar (positive = word_list )
64
- # print(predicted_word)
31
+
65
32
next_word = predicted_word [similar_num - 1 ][0 ]
66
33
if next_word in word_list :
67
34
next_word = predicted_word [similar_num ][0 ]
68
35
69
36
word_list .append (next_word )
70
- # print(word_list)
37
+
71
38
72
39
73
40
elif input_words_num > 1 :
@@ -86,13 +53,6 @@ def tweet_gen(input_words_num, total_words_num, word_list, similar_num, party):
86
53
sentence = sentence + word + " "
87
54
88
55
return sentence
89
- # print("\n" + sentence)
90
-
91
-
92
-
93
-
94
-
95
- #Tweet_generator.tweet_gen(input_words_num, total_words_num, word_list)
96
-
56
+
97
57
98
58
0 commit comments