File size: 7,288 Bytes
86ba49a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9ea88f8
86ba49a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9ea88f8
86ba49a
 
 
 
 
 
9ea88f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb4068f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9ea88f8
 
86ba49a
 
 
 
 
 
 
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# Gerekli kütüphaneleri içe aktar
import nltk
from nltk import *
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
import string
import stylecloud
from PIL import Image
import matplotlib.pyplot as plt

# NLTK kütüphanesinden gerekli bileşenleri indir
nltk.download('stopwords')
nltk.download('punkt')

def preprocess_and_create_stylecloud(file_path, output_name='stylecloud.png', 
                                     icon_name='fas fa-coffe', lang='english'):
    # Metni dosyadan oku
    with open(file_path, 'r', encoding='utf-8') as f:
        text = f.read()

    # Türkçe stopwords listesini yükle
    stop_words = set(stopwords.words(lang))

    # Noktalama işaretlerini kaldır
    translator = str.maketrans('', '', string.punctuation)
    text = text.translate(translator)

    # Metni tokenlere ayır ve küçük harfe çevir
    tokens = word_tokenize(text.lower(), language=lang)

    # Stopwords'ü filtrele
    filtered_tokens = [word for word in tokens if word not in stop_words]

    # Filtrelenmiş tokenleri birleştir
    processed_text = ' '.join(filtered_tokens)

    # StyleCloud oluştur
    stylecloud.gen_stylecloud(text=processed_text,
                              icon_name=icon_name,
                              output_name=output_name)
    # Oluşturulan StyleCloud'u göster
    im = Image.open(output_name)
    plt.figure(figsize=(10, 10))
    plt.imshow(im)
    plt.axis('off')  # Eksenleri gizle
    plt.show()

import streamlit as st
import stylecloud

def create_stylecloud(text, language, icon):
    output_file = "stylecloud.png"
    
    stylecloud.gen_stylecloud(text=text,
                              icon_name=icon,
                              output_name=output_file)
    
    return output_file

st.title("WordCloud Creator")

file = st.file_uploader("Text File Import", type=["txt"])

if file is not None:
    text = file.getvalue().decode("utf-8")
    
    language = st.radio("Language", ["tr", "en"])
    
    icon_options = [
    "fas fa-car",
    "fas fa-star",
    "fas fa-trophy",
    "fas fa-heart",
    "fas fa-wifi",
    "fas fa-laptop",
    "fas fa-coffee",
    "fas fa-radio",
    "fas fa-snowflake",
    "fas fa-apple",
    "fas fa-basketball-ball",
    "fas fa-bell",
    "fas fa-bicycle",
    "fas fa-binoculars",
    "fas fa-birthday-cake",
    "fas fa-blender",
    "fas fa-bomb",
    "fas fa-book",
    "fas fa-bowling-ball",
    "fas fa-box",
    "fas fa-bread-slice",
    "fas fa-briefcase",
    "fas fa-broom",
    "fas fa-brush",
    "fas fa-bug",
    "fas fa-building",
    "fas fa-bullhorn",
    "fas fa-bullseye",
    "fas fa-bus",
    "fas fa-calculator",
    "fas fa-calendar",
    "fas fa-camera",
    "fas fa-campground",
    "fas fa-candy-cane",
    "fas fa-carrot",
    "fas fa-cat",
    "fas fa-chair",
    "fas fa-chess",
    "fas fa-chess-king",
    "fas fa-chess-knight",
    "fas fa-chess-pawn",
    "fas fa-chess-queen",
    "fas fa-chess-rook",
    "fas fa-child",
    "fas fa-church",
    "fas fa-circle",
    "fas fa-city",
    "fas fa-clipboard",
    "fas fa-clock",
    "fas fa-cloud",
    "fas fa-cloud-moon",
    "fas fa-cloud-sun",
    "fas fa-cocktail",
    "fas fa-code",
    "fas fa-coins",
    "fas fa-compass",
    "fas fa-cookie",
    "fas fa-couch",
    "fas fa-crown",
    "fas fa-cube",
    "fas fa-database",
    "fas fa-desktop",
    "fas fa-dice",
    "fas fa-dog",
    "fas fa-dragon",
    "fas fa-drum",
    "fas fa-dumbbell",
    "fas fa-envelope",
    "fas fa-eye",
    "fas fa-fan",
    "fas fa-feather",
    "fas fa-fighter-jet",
    "fas fa-fire",
    "fas fa-fire-extinguisher",
    "fas fa-flag",
    "fas fa-flask",
    "fas fa-football-ball",
    "fas fa-frog",
    "fas fa-gamepad",
    "fas fa-gem",
    "fas fa-gift",
    "fas fa-glasses",
    "fas fa-globe",
    "fas fa-guitar",
    "fas fa-hammer",
    "fas fa-hat-cowboy",
    "fas fa-headphones",
    "fas fa-helicopter",
    "fas fa-home",
    "fas fa-hourglass",
    "fas fa-ice-cream",
    "fas fa-inbox",
    "fas fa-key",
    "fas fa-laptop",
    "fas fa-leaf",
    "fas fa-lemon",
    "fas fa-lightbulb",
    "fas fa-lock",
    "fas fa-magic",
    "fas fa-map",
    "fas fa-microphone",
    "fas fa-moon",
    "fas fa-motorcycle",
    "fas fa-mountain",
    "fas fa-mug-hot",
    "fas fa-music",
    "fas fa-newspaper",
    "fas fa-palette",
    "fas fa-paw",
    "fas fa-peace",
    "fas fa-pen",
    "fas fa-penguin",
    "fas fa-phone",
    "fas fa-pizza-slice",
    "fas fa-plane",
    "fas fa-plant",
    "fas fa-plug",
    "fas fa-poo",
    "fas fa-print",
    "fas fa-puzzle-piece",
    "fas fa-robot",
    "fas fa-rocket",
    "fas fa-route",
    "fas fa-rss",
    "fas fa-satellite",
    "fas fa-shield-alt",
    "fas fa-shipping-fast",
    "fas fa-shoe-prints",
    "fas fa-skull",
    "fas fa-smile",
    "fas fa-space-shuttle",
    "fas fa-spider",
    "fas fa-sun",
    "fas fa-swatchbook",
    "fas fa-sword",
    "fas fa-table-tennis",
    "fas fa-tag",
    "fas fa-taxi",
    "fas fa-teeth",
    "fas fa-theater-masks",
    "fas fa-thermometer",
    "fas fa-toolbox",
    "fas fa-train",
    "fas fa-tree",
    "fas fa-tshirt",
    "fas fa-umbrella",
    "fas fa-utensils",
    "fas fa-venus",
    "fas fa-virus",
    "fas fa-walking",
    "fas fa-water",
    "fas fa-webcam",
    "fas fa-wine-bottle",
    "fas fa-wrench",
    "fas fa-yin-yang",
    "fas fa-anchor",
    "fas fa-battery-full",
    "fas fa-bowling-pins",
    "fas fa-brain",
    "fas fa-bugle",
    "fas fa-campfire",
    "fas fa-chess-bishop",
    "fas fa-cloud-showers-heavy",
    "fas fa-crow",
    "fas fa-dice-d20",
    "fas fa-feather-alt",
    "fas fa-fighter-jet",
    "fas fa-film",
    "fas fa-football-helmet",
    "fas fa-frog",
    "fas fa-funnel-dollar",
    "fas fa-gas-pump",
    "fas fa-gifts",
    "fas fa-glasses",
    "fas fa-hiking",
    "fas fa-ice-skate",
    "fas fa-laptop-medical",
    "fas fa-mitten",
    "fas fa-mosque",
    "fas fa-oil-can",
    "fas fa-palette",
    "fas fa-parachute-box",
    "fas fa-pepper-hot",
    "fas fa-piggy-bank",
    "fas fa-robot",
    "fas fa-route",
    "fas fa-ruler",
    "fas fa-ruler-combined",
    "fas fa-shapes",
    "fas fa-skating",
    "fas fa-sleigh",
    "fas fa-smoking",
    "fas fa-snowboarding",
    "fas fa-snowplow",
    "fas fa-stethoscope",
    "fas fa-stroopwafel",
    "fas fa-subway",
    "fas fa-swatchbook",
    "fas fa-swimmer",
    "fas fa-tachometer-alt",
    "fas fa-theater-masks",
    "fas fa-tractor",
    "fas fa-tree-decorated",
    "fas fa-tree-large",
    "fas fa-truck-monster",
    "fas fa-tv-retro",
    "fas fa-umbrella-beach",
    "fas fa-unicorn",
    "fas fa-user-astronaut",
    "fas fa-user-ninja",
    "fas fa-user-secret",
    "fas fa-volleyball-ball",
    "fas fa-walking",
    "fas fa-wind",
    "fas fa-window-maximize",
    "fas fa-windsock",
    "fas fa-wine-glass",
    "fas fa-wizard-hat",
    "fas fa-yen-sign",
    "fas fa-zeppelin"
  ]

    icon = st.selectbox("Select Icon", icon_options, index=1)
    
    if st.button("Create"):
        output_file = create_stylecloud(text, language, icon)
        st.markdown(f"### [Download WordCloud](./{output_file})")

        image = Image.open(output_file)
        st.image(image, caption='WordCloud', use_column_width=True)