Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -111,20 +111,18 @@ for t in topics.tolist():
|
|
111 |
freq = selected_data["scores"][selected_data.index[0]]
|
112 |
keyword_freq_pairs = zip(keywords, freq)
|
113 |
most_frequent_keyword = max(keyword_freq_pairs, key=lambda x: x[1])
|
114 |
-
mrk += most_frequent_keyword
|
115 |
input += ", [" + ", ".join(keywords) + "]"
|
116 |
|
117 |
|
118 |
input += " I want you to give me only one precise word that best describes the theme of this list. If I give you multiple lists, I want you to give me one word with a maj in front for each of those lists, and separate them by // (your answer should contain only one word for each, if I give you 100 lists, You give me 100 words)"
|
119 |
new_topics = "".join(gpt_predict(input))
|
120 |
nt = new_topics.split("//")
|
121 |
-
print(len(nt))
|
122 |
|
123 |
#in case chatgpt overloaded
|
124 |
i = 0
|
125 |
if len(nt) < len(topics.tolist()):
|
126 |
nt = [f"Topic {o+1}: {mrk[o]}" for o in range(len(topics.tolist()))]
|
127 |
-
print(nt)
|
128 |
for t in topics.tolist():
|
129 |
if t != -1:
|
130 |
readable_topics_dic[nt[i]] = t
|
@@ -134,7 +132,6 @@ for t in topics.tolist():
|
|
134 |
|
135 |
|
136 |
def display_topics(topic):
|
137 |
-
print(readable_topics_dic)
|
138 |
topic = readable_topics_dic[topic]
|
139 |
# Filter DataFrame based on the selected topic
|
140 |
selected_data = df[df['topic'] == topic]
|
|
|
111 |
freq = selected_data["scores"][selected_data.index[0]]
|
112 |
keyword_freq_pairs = zip(keywords, freq)
|
113 |
most_frequent_keyword = max(keyword_freq_pairs, key=lambda x: x[1])
|
114 |
+
mrk += most_frequent_keyword[0].capitalize()
|
115 |
input += ", [" + ", ".join(keywords) + "]"
|
116 |
|
117 |
|
118 |
input += " I want you to give me only one precise word that best describes the theme of this list. If I give you multiple lists, I want you to give me one word with a maj in front for each of those lists, and separate them by // (your answer should contain only one word for each, if I give you 100 lists, You give me 100 words)"
|
119 |
new_topics = "".join(gpt_predict(input))
|
120 |
nt = new_topics.split("//")
|
|
|
121 |
|
122 |
#in case chatgpt overloaded
|
123 |
i = 0
|
124 |
if len(nt) < len(topics.tolist()):
|
125 |
nt = [f"Topic {o+1}: {mrk[o]}" for o in range(len(topics.tolist()))]
|
|
|
126 |
for t in topics.tolist():
|
127 |
if t != -1:
|
128 |
readable_topics_dic[nt[i]] = t
|
|
|
132 |
|
133 |
|
134 |
def display_topics(topic):
|
|
|
135 |
topic = readable_topics_dic[topic]
|
136 |
# Filter DataFrame based on the selected topic
|
137 |
selected_data = df[df['topic'] == topic]
|