Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,10 @@ import matplotlib.pyplot as plt
|
|
9 |
import streamlit as st
|
10 |
import os
|
11 |
import base64
|
|
|
|
|
|
|
|
|
12 |
|
13 |
# NLTK kütüphanesinden gerekli bileşenleri indir
|
14 |
nltk.download('stopwords')
|
@@ -48,7 +52,7 @@ def preprocess_and_create_stylecloud(file_path, output_name='stylecloud.png',
|
|
48 |
plt.show()
|
49 |
|
50 |
def create_stylecloud(text, language, icon):
|
51 |
-
output_file =
|
52 |
stylecloud.gen_stylecloud(text=text, icon_name=icon, output_name=output_file)
|
53 |
# Dosyayı Base64 olarak kodla
|
54 |
with open(output_file, "rb") as file:
|
@@ -106,5 +110,5 @@ if file is not None:
|
|
106 |
image = Image.open("static/stylecloud.png")
|
107 |
st.image(image, caption='WordCloud', use_column_width=True)
|
108 |
# Ensure the file is deleted after display
|
109 |
-
if os.path.exists(
|
110 |
-
os.
|
|
|
9 |
import streamlit as st
|
10 |
import os
|
11 |
import base64
|
12 |
+
import os
|
13 |
+
|
14 |
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
15 |
+
STATIC_DIR = os.path.join(BASE_DIR, 'static')
|
16 |
|
17 |
# NLTK kütüphanesinden gerekli bileşenleri indir
|
18 |
nltk.download('stopwords')
|
|
|
52 |
plt.show()
|
53 |
|
54 |
def create_stylecloud(text, language, icon):
|
55 |
+
output_file = os.path.join(STATIC_DIR, 'stylecloud.png')
|
56 |
stylecloud.gen_stylecloud(text=text, icon_name=icon, output_name=output_file)
|
57 |
# Dosyayı Base64 olarak kodla
|
58 |
with open(output_file, "rb") as file:
|
|
|
110 |
image = Image.open("static/stylecloud.png")
|
111 |
st.image(image, caption='WordCloud', use_column_width=True)
|
112 |
# Ensure the file is deleted after display
|
113 |
+
if not os.path.exists(STATIC_DIR):
|
114 |
+
os.makedirs(STATIC_DIR)
|