-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSchedule.py
More file actions
48 lines (42 loc) · 1.52 KB
/
Schedule.py
File metadata and controls
48 lines (42 loc) · 1.52 KB
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
import pdfplumber
from nltk.tokenize import sent_tokenize, word_tokenize
from nltk.corpus import stopwords
import nltk
import re
Assessments = {'Assignments': 'ASSIGNMENT',
'Quizzes': 'QUIZ',
'Tests': 'TEST',
'Labs': 'LAB',
'Exams': 'EXAM',
'Mid-terms': 'MID-TERM',
'Midterms': 'MIDTERM',
'Finals': 'FINAL',
'Projects': 'PROJECT'}
Months = {'January': 'JAN',
'February': 'FEB',
'March': 'MAR',
'April': 'APR',
'May': 'MAY',
'June': 'JUN',
'July': 'JUL',
'August': 'AUG',
'September': 'SEP',
'October': 'OCT',
'November': 'NOV',
'December': 'DEC'}
with pdfplumber.open('5400.pdf') as pdf:
for pdf_page in pdf.pages:
data = pdf_page.extract_text()
start = data.upper().find("ASSESSMENT")
end = data.find(":", (start+100))
Assessment = data[start:end]
tokenize_text = word_tokenize(Assessment)
stop_words = set(stopwords.words("english"))
punctuations = ['.']
filered_text = [w for w in tokenize_text if w not in punctuations]
for a, t in enumerate(filered_text):
if t.upper().startswith(tuple(Months.values())):
for f, b in enumerate(reversed(filered_text[:a])):
if b.upper().startswith(tuple(Assessments.values())):
print(b, t, filered_text[a+1])
break