-
Notifications
You must be signed in to change notification settings - Fork 2
/
parse_message.py
68 lines (63 loc) · 1.69 KB
/
parse_message.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import re
import time
from dfa import IdentityAutomata
def extract_user_info(msg: str):
machine = IdentityAutomata()
msg = msg.lower()
tokens = msg.split()
potentialIds = [word for word in tokens if word[0] =='b']
for college_id in potentialIds:
if machine.is_accepted(college_id[1:]):
return college_id
return None
messages = [
'''
Soubhik Gon
B422056
Day 25:
Continued learning elastic beanstalk and cloud functions
Started working on a project using React-RTK
solved some leetcode problem
''',
'''
Samarth Thaker
B122126
Day 25:
Solved leetcode problems. Continued working on the app.
''',
'''
Pruthiraj panda
ID B122085
Day 22
solved some questions in GFG Root to leaf paths , reverse level order traversal, k distance from root, nodes at odd level, sum of longest path from root to leaf.
solved sort a linklist by bubble sort algorithm.
solved some questions on string largest odd number in a string and reverse words in a string.
''',
'''
Sarthak Mishra
ID - B122100
Day 25:
• Completed learning javascript
• Solved leetcode problems based on sliding window
''',
'''
Binashak Mohanty
B122038
Day 15 :
Learnt about working of sensors and their applications.
Started working on a Scanner app.
''',
'''Aurojyoti Das
B422017
Day 24:
. Continued studying html
. Solved 2 question on gfg
'''
]
if __name__ == "__main__":
for msg in messages:
user_id, name = extract_user_info(msg)
if user_id and name:
print(f"ID: {user_id}")
print(f"Name: {name}")
print("-----")