Spaces:
Configuration error
Configuration error
Update utils.py
Browse files
utils.py
CHANGED
@@ -12,7 +12,7 @@ from gtts import gTTS
|
|
12 |
import os
|
13 |
import platform
|
14 |
|
15 |
-
# Download required NLTK data files
|
16 |
nltk.download('vader_lexicon')
|
17 |
|
18 |
nltk.download('averaged_perceptron_tagger')
|
@@ -21,7 +21,6 @@ nltk.download('stopwords')
|
|
21 |
def get_bing_news_articles(company_name, num_articles=10):
|
22 |
"""
|
23 |
Scrapes Bing News search results for a given company name.
|
24 |
-
Returns a list of articles with metadata: title, summary, URL, and source.
|
25 |
"""
|
26 |
query = company_name.replace(" ", "+")
|
27 |
url = f"https://www.bing.com/news/search?q={query}&FORM=HDRSC6"
|
@@ -86,10 +85,6 @@ def extract_topics(text):
|
|
86 |
def comparative_analysis(articles):
|
87 |
"""
|
88 |
Performs comparative analysis across articles.
|
89 |
-
Returns a dictionary with:
|
90 |
-
- Sentiment Distribution: Count of articles per sentiment.
|
91 |
-
- Coverage Differences: Insights based on keyword presence.
|
92 |
-
- Topic Overlap: Common topics and unique topics per article.
|
93 |
"""
|
94 |
sentiment_distribution = {"Positive": 0, "Negative": 0, "Neutral": 0}
|
95 |
sales_keywords = {"sales", "growth", "record", "profit"}
|
|
|
12 |
import os
|
13 |
import platform
|
14 |
|
15 |
+
# Download required NLTK data files.
|
16 |
nltk.download('vader_lexicon')
|
17 |
|
18 |
nltk.download('averaged_perceptron_tagger')
|
|
|
21 |
def get_bing_news_articles(company_name, num_articles=10):
|
22 |
"""
|
23 |
Scrapes Bing News search results for a given company name.
|
|
|
24 |
"""
|
25 |
query = company_name.replace(" ", "+")
|
26 |
url = f"https://www.bing.com/news/search?q={query}&FORM=HDRSC6"
|
|
|
85 |
def comparative_analysis(articles):
|
86 |
"""
|
87 |
Performs comparative analysis across articles.
|
|
|
|
|
|
|
|
|
88 |
"""
|
89 |
sentiment_distribution = {"Positive": 0, "Negative": 0, "Neutral": 0}
|
90 |
sales_keywords = {"sales", "growth", "record", "profit"}
|