Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
import feedparser
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
model = pipeline("sentiment-analysis", model="
|
| 6 |
|
| 7 |
# Bitcoin haberleri için RSS feed URL'si
|
| 8 |
rss_url = "https://news.google.com/rss/search?q=Bitcoin&hl=en-US&gl=US&ceid=US:en"
|
|
@@ -18,23 +18,24 @@ for entry in feed.entries:
|
|
| 18 |
title = entry.title
|
| 19 |
sentiment = model(title)[0]
|
| 20 |
|
| 21 |
-
# Etiketi puana çevir
|
| 22 |
label = sentiment['label'].upper()
|
|
|
|
|
|
|
| 23 |
if label == "POSITIVE":
|
| 24 |
-
|
| 25 |
elif label == "NEGATIVE":
|
| 26 |
-
|
| 27 |
else:
|
| 28 |
-
|
| 29 |
|
| 30 |
-
total_score += score
|
| 31 |
count += 1
|
| 32 |
|
| 33 |
# Ortalama skor hesapla
|
| 34 |
average_score = total_score / count if count > 0 else 0
|
| 35 |
|
| 36 |
# Long / Short / Neutral kararı
|
| 37 |
-
threshold = 0.
|
| 38 |
if average_score > threshold:
|
| 39 |
signal = "LONG 🟢"
|
| 40 |
elif average_score < -threshold:
|
|
|
|
| 1 |
import feedparser
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# FinBERT modelini yükle (CPU kullanmak için device=-1)
|
| 5 |
+
model = pipeline("sentiment-analysis", model="yiyanghkust/finbert-tone", device=-1)
|
| 6 |
|
| 7 |
# Bitcoin haberleri için RSS feed URL'si
|
| 8 |
rss_url = "https://news.google.com/rss/search?q=Bitcoin&hl=en-US&gl=US&ceid=US:en"
|
|
|
|
| 18 |
title = entry.title
|
| 19 |
sentiment = model(title)[0]
|
| 20 |
|
| 21 |
+
# Etiketi puana çevir (POSITIVE = +1, NEGATIVE = -1, NEUTRAL = 0)
|
| 22 |
label = sentiment['label'].upper()
|
| 23 |
+
score = sentiment['score'] # güven skorunu ağırlık olarak kullan
|
| 24 |
+
|
| 25 |
if label == "POSITIVE":
|
| 26 |
+
total_score += score # ağırlıklı pozitif
|
| 27 |
elif label == "NEGATIVE":
|
| 28 |
+
total_score -= score # ağırlıklı negatif
|
| 29 |
else:
|
| 30 |
+
total_score += 0 # nötr = 0
|
| 31 |
|
|
|
|
| 32 |
count += 1
|
| 33 |
|
| 34 |
# Ortalama skor hesapla
|
| 35 |
average_score = total_score / count if count > 0 else 0
|
| 36 |
|
| 37 |
# Long / Short / Neutral kararı
|
| 38 |
+
threshold = 0.05 # küçük değişimleri nötr say
|
| 39 |
if average_score > threshold:
|
| 40 |
signal = "LONG 🟢"
|
| 41 |
elif average_score < -threshold:
|