Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- AI.txt +6 -0
- app.py +82 -0
- requirements.txt +10 -0
AI.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Artificial intelligence, or AI, is technology that enables computers and machines to simulate human intelligence and problem-solving capabilities.
|
2 |
+
On its own or combined with other technologies (e.g., sensors, geolocation, robotics) AI can perform tasks that would otherwise require human intelligence or intervention. Digital assistants, GPS guidance, autonomous vehicles, and generative AI tools (like Open AI's Chat GPT) are just a few examples of AI in the daily news and our daily lives.
|
3 |
+
|
4 |
+
As a field of computer science, artificial intelligence encompasses (and is often mentioned together with) machine learning and deep learning. These disciplines involve the development of AI algorithms, modeled after the decision-making processes of the human brain, that can ‘learn’ from available data and make increasingly more accurate classifications or predictions over time.
|
5 |
+
|
6 |
+
Artificial intelligence has gone through many cycles of hype, but even to skeptics, the release of ChatGPT seems to mark a turning point. The last time generative AI loomed this large, the breakthroughs were in computer vision, but now the leap forward is in natural language processing (NLP). Today, generative AI can learn and synthesize not just human language but other data types including images, video, software code, and even molecular structures.
|
app.py
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Gerekli kütüphaneleri içe aktar
|
2 |
+
import nltk
|
3 |
+
from nltk.corpus import stopwords
|
4 |
+
from nltk.tokenize import word_tokenize
|
5 |
+
import string
|
6 |
+
import stylecloud
|
7 |
+
from PIL import Image
|
8 |
+
import matplotlib.pyplot as plt
|
9 |
+
import streamlit as st
|
10 |
+
|
11 |
+
# NLTK kütüphanesinden gerekli bileşenleri indir
|
12 |
+
nltk.download('stopwords')
|
13 |
+
nltk.download('punkt')
|
14 |
+
|
15 |
+
def preprocess_and_create_stylecloud(file_path, output_name='stylecloud.png',
|
16 |
+
icon_name='fas fa-laptop', lang='english'):
|
17 |
+
# Metni dosyadan oku
|
18 |
+
with open(file_path, 'r', encoding='utf-8') as f:
|
19 |
+
text = f.read()
|
20 |
+
|
21 |
+
# Stopwords listesini yükle
|
22 |
+
stop_words = set(stopwords.words(lang))
|
23 |
+
|
24 |
+
# Noktalama işaretlerini kaldır
|
25 |
+
translator = str.maketrans('', '', string.punctuation)
|
26 |
+
text = text.translate(translator)
|
27 |
+
|
28 |
+
# Metni tokenlere ayır ve küçük harfe çevir
|
29 |
+
tokens = word_tokenize(text.lower(), language=lang)
|
30 |
+
|
31 |
+
# Stopwords'ü filtrele
|
32 |
+
filtered_tokens = [word for word in tokens if word not in stop_words]
|
33 |
+
|
34 |
+
# Filtrelenmiş tokenleri birleştir
|
35 |
+
processed_text = ' '.join(filtered_tokens)
|
36 |
+
|
37 |
+
# StyleCloud oluştur
|
38 |
+
stylecloud.gen_stylecloud(text=processed_text,
|
39 |
+
icon_name=icon_name,
|
40 |
+
output_name=output_name)
|
41 |
+
# Oluşturulan StyleCloud'u göster
|
42 |
+
im = Image.open(output_name)
|
43 |
+
plt.figure(figsize=(10, 10))
|
44 |
+
plt.imshow(im)
|
45 |
+
plt.axis('off') # Eksenleri gizle
|
46 |
+
plt.show()
|
47 |
+
|
48 |
+
def create_stylecloud(text, language, icon):
|
49 |
+
output_file = "stylecloud.png"
|
50 |
+
|
51 |
+
stylecloud.gen_stylecloud(text=text,
|
52 |
+
icon_name=icon,
|
53 |
+
output_name=output_file)
|
54 |
+
|
55 |
+
return output_file
|
56 |
+
|
57 |
+
st.title("WordCloud Creator")
|
58 |
+
|
59 |
+
file = st.file_uploader("Import txt file", type=["txt"])
|
60 |
+
|
61 |
+
if file is not None:
|
62 |
+
text = file.getvalue().decode("utf-8")
|
63 |
+
|
64 |
+
language = st.radio("Language", ["tr", "en"])
|
65 |
+
|
66 |
+
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']
|
67 |
+
icon = st.selectbox("Icon Selection", icon_options, index=1)
|
68 |
+
|
69 |
+
if st.button("Create"):
|
70 |
+
output_file = create_stylecloud(text, language, icon)
|
71 |
+
st.success(f"Here is your file: {output_file}")
|
72 |
+
|
73 |
+
image = Image.open(output_file)
|
74 |
+
st.image(image, caption='WordCloud', use_column_width=True)
|
75 |
+
|
76 |
+
with open(output_file, "rb") as file:
|
77 |
+
btn = st.download_button(
|
78 |
+
label="Download WordCloud",
|
79 |
+
data=file,
|
80 |
+
file_name=output_file,
|
81 |
+
mime="image/png"
|
82 |
+
)
|
requirements.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
pandas
|
2 |
+
plotly
|
3 |
+
streamlit
|
4 |
+
yfinance
|
5 |
+
pandas-datareader
|
6 |
+
prophet
|
7 |
+
nltk
|
8 |
+
stylecloud
|
9 |
+
pillow==9.4
|
10 |
+
Image
|