forked from mhezarei/ai-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
find_events_in_sentence.py
29 lines (26 loc) · 1015 Bytes
/
find_events_in_sentence.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import pandas as pd
def find_events_in_sentence(sentence):
p = os.path.dirname(os.path.abspath(__file__))
url1 = os.path.join(p, "find important events.csv")
df1 = pd.read_csv(url1)
important_events = df1['event']
important_events_key = df1['event_key']
events = []
event_keys = []
for i in range(len(important_events)):
if important_events_key[i] in sentence:
events.append(important_events[i])
event_keys.append(important_events_key[i])
elif important_events[i] in sentence:
events.append(important_events[i])
event_keys.append(important_events_key[i])
more_events = {
"عاشورا": "عاشورای حسینی",
"تاسوعا": "تاسوعای حسینی"
}
for key in more_events.keys():
if not more_events[key] in events and key in sentence:
events.append(more_events[key])
event_keys.append(more_events[key])
return events, event_keys