Spaces:
Runtime error
Runtime error
abdulmatinomotoso
commited on
Commit
•
4758cc2
1
Parent(s):
22c525a
Update app.py
Browse files
app.py
CHANGED
@@ -15,11 +15,29 @@ sentiment = pipeline("sentiment-analysis", model=finbert, tokenizer=tokenizer)
|
|
15 |
|
16 |
#defining a function to give us the sentiment of the article
|
17 |
def return_sentiment(text):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
results = sentiment(text[:512])
|
19 |
return (f"{results[0]['label']} ---> {results[0]['score']}")
|
20 |
|
21 |
#defining a function to return the names of the organization present in the article
|
22 |
def show_org(text):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
org = []
|
24 |
doc = nlp(text)
|
25 |
if doc.ents:
|
|
|
15 |
|
16 |
#defining a function to give us the sentiment of the article
|
17 |
def return_sentiment(text):
|
18 |
+
text = re.sub(r'Photo by.+', '', text)
|
19 |
+
text = re.sub(r"\n", " ", text)
|
20 |
+
text = re.sub(r"\n\n", " ", text)
|
21 |
+
text = re.sub(r"\t", " ", text)
|
22 |
+
text = text.strip(" ")
|
23 |
+
text = re.sub(
|
24 |
+
" +", " ", text
|
25 |
+
).strip() # get rid of multiple spaces and replace with a single
|
26 |
+
|
27 |
results = sentiment(text[:512])
|
28 |
return (f"{results[0]['label']} ---> {results[0]['score']}")
|
29 |
|
30 |
#defining a function to return the names of the organization present in the article
|
31 |
def show_org(text):
|
32 |
+
text = re.sub(r'Photo by.+', '', text)
|
33 |
+
text = re.sub(r"\n", " ", text)
|
34 |
+
text = re.sub(r"\n\n", " ", text)
|
35 |
+
text = re.sub(r"\t", " ", text)
|
36 |
+
text = text.strip(" ")
|
37 |
+
text = re.sub(
|
38 |
+
" +", " ", text
|
39 |
+
).strip() # get rid of multiple spaces and replace with a single
|
40 |
+
|
41 |
org = []
|
42 |
doc = nlp(text)
|
43 |
if doc.ents:
|