Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,7 +27,14 @@ def topic_modeling(texts, n_components):
|
|
| 27 |
data_vectorized = vectorizer.fit_transform(texts)
|
| 28 |
lda = LatentDirichletAllocation(n_components=n_components, random_state=0)
|
| 29 |
lda.fit(data_vectorized)
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
topics = {}
|
| 32 |
for topic_idx, topic in enumerate(lda.components_):
|
| 33 |
topics[f"Topic {topic_idx + 1}"] = [features[i] for i in topic.argsort()[:-21:-1]]
|
|
|
|
| 27 |
data_vectorized = vectorizer.fit_transform(texts)
|
| 28 |
lda = LatentDirichletAllocation(n_components=n_components, random_state=0)
|
| 29 |
lda.fit(data_vectorized)
|
| 30 |
+
|
| 31 |
+
# 여기서 get_feature_names 대신 get_feature_names_out을 사용합니다
|
| 32 |
+
try:
|
| 33 |
+
features = vectorizer.get_feature_names_out()
|
| 34 |
+
except AttributeError:
|
| 35 |
+
# 이전 버전과의 호환성을 위해 예외 처리
|
| 36 |
+
features = vectorizer.get_feature_names()
|
| 37 |
+
|
| 38 |
topics = {}
|
| 39 |
for topic_idx, topic in enumerate(lda.components_):
|
| 40 |
topics[f"Topic {topic_idx + 1}"] = [features[i] for i in topic.argsort()[:-21:-1]]
|