Spaces:
Sleeping
Sleeping
File size: 1,572 Bytes
e74eb58 | 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | import re
def extract_deadline(text):
pattern = r"\b\d{1,2}\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec|January|February|March|April|May|June|July|August|September|October|November|December)\s\d{4}\b"
matches = re.findall(
pattern,
text,
re.IGNORECASE
)
return matches[0] if matches else "Not Found"
def extract_documents(text):
common_docs = [
"aadhaar",
"income certificate",
"marksheet",
"passport photo",
"domicile certificate",
"caste certificate",
"bank passbook"
]
found = []
lower_text = text.lower()
for doc in common_docs:
if doc in lower_text:
found.append(doc.title())
return found
def extract_form_name(text):
lines = text.split("\n")
for line in lines:
if len(line.strip()) > 5:
return line.strip()
return "Unknown Form"
def extract_eligibility(text):
eligibility_keywords = [
"eligibility",
"eligible",
"income"
]
lines = text.split("\n")
for line in lines:
lower = line.lower()
if any(
keyword in lower
for keyword in eligibility_keywords
):
return line.strip()
return "Not Found"
def build_master_json(text):
return {
"form_name": extract_form_name(text),
"deadline": extract_deadline(text),
"eligibility": extract_eligibility(text),
"documents": extract_documents(text),
"contact_info": ""
} |