Spaces:
Runtime error
Runtime error
Update app.py
Browse files1 unmodified line23456789101145 unmodified lines5758596061626364656667686970137 unmodified lines208209210211212213214215216217218164 unmodified lines3833843853863871 unmodified lineimport requestsimport pandas as pdfrom datetime import datetime, timedelta# import nltk# from wordcloud import WordCloud# import base64# from io import BytesIOimport numpy as npfrom sklearn.linear_model import LinearRegressionimport plotly.graph_objects as go45 unmodified linesreturn float(score)# def generate_wordcloud(text):# stopwords = nltk.corpus.stopwords.words('english')# wordcloud = WordCloud(width=800, height=400, background_color="white", stopwords=stopwords).generate(text)# buf = BytesIO()# wordcloud.to_image().save(buf, format="PNG")# return base64.b64encode(buf.getvalue()).decode()# --------------------------# แปลงชื่อ/ตัวย่อ → (Company Name, Symbol)# --------------------------137 unmodified linescol2.metric("ข่าวเชิงบวก", f"{pos_pct:.1f}%")col3.metric("ข่าวเชิงลบ", f"{neg_pct:.1f}%")# # WordCloud# st.subheader("☁️ Word Cloud")# all_text = " ".join(news_df["text"].tolist())# img = generate_wordcloud(all_text)# st.image(f"data:image/png;base64,{img}", use_column_width=True)# ---------------------------------------------------------# เตรียมข้อมูลสำหรับกราฟ Sentiment & Price164 unmodified lines# RUN APP# ---------------------------------------------------------if __name__ == "__main__":# nltk.download("stopwords", quiet=True)main()1 unmodified line23456745 unmodified lines535455565758137 unmodified lines196197198199200201164 unmodified lines3663673683691 unmodified lineimport requestsimport pandas as pdfrom datetime import datetime, timedeltaimport numpy as npfrom sklearn.linear_model import LinearRegressionimport plotly.graph_objects as go45 unmodified linesreturn float(score)# --------------------------# แปลงชื่อ/ตัวย่อ → (Company Name, Symbol)# --------------------------137 unmodified linescol2.metric("ข่าวเชิงบวก", f"{pos_pct:.1f}%")col3.metric("ข่าวเชิงลบ", f"{neg_pct:.1f}%")# ---------------------------------------------------------# เตรียมข้อมูลสำหรับกราฟ Sentiment & Price164 unmodified lines# RUN APP# ---------------------------------------------------------if __name__ == "__main__":main()
app.py-18