abdulmatinomotoso
commited on
Commit
·
458779c
1
Parent(s):
a7cc36c
Update app.py
Browse files
app.py
CHANGED
@@ -18,6 +18,7 @@ tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
18 |
def read_in_text(url):
|
19 |
with open(url, 'r') as file:
|
20 |
article = file.read()
|
|
|
21 |
return article
|
22 |
|
23 |
def clean_text(url):
|
@@ -36,6 +37,7 @@ def clean_text(url):
|
|
36 |
|
37 |
text = re.sub(r'Date\s\d{1,2}\/\d{1,2}\/\d{4}', '', text) #remove date
|
38 |
text = re.sub(r'\d{1,2}:\d{2}\s[A-Z]+\s[A-Z]+', '', text) #remove time
|
|
|
39 |
return text
|
40 |
|
41 |
#Defining a function to get the category of the news article
|
@@ -50,6 +52,7 @@ def get_category(file):
|
|
50 |
probs = probs.cpu().detach().numpy()
|
51 |
max_index = np.argmax(probs)
|
52 |
emotion = labels[max_index]
|
|
|
53 |
return emotion
|
54 |
|
55 |
#Creating the interface for the radio app
|
|
|
18 |
def read_in_text(url):
|
19 |
with open(url, 'r') as file:
|
20 |
article = file.read()
|
21 |
+
|
22 |
return article
|
23 |
|
24 |
def clean_text(url):
|
|
|
37 |
|
38 |
text = re.sub(r'Date\s\d{1,2}\/\d{1,2}\/\d{4}', '', text) #remove date
|
39 |
text = re.sub(r'\d{1,2}:\d{2}\s[A-Z]+\s[A-Z]+', '', text) #remove time
|
40 |
+
|
41 |
return text
|
42 |
|
43 |
#Defining a function to get the category of the news article
|
|
|
52 |
probs = probs.cpu().detach().numpy()
|
53 |
max_index = np.argmax(probs)
|
54 |
emotion = labels[max_index]
|
55 |
+
|
56 |
return emotion
|
57 |
|
58 |
#Creating the interface for the radio app
|