Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import re | |
| def extract_entities(text): | |
| # Using regex to find Pakistani phone numbers | |
| phone_numbers = re.findall(r'\+\d{2,3}\d{9,12}\b', text) | |
| # Using regex to find emails | |
| emails = re.findall(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b', text) | |
| return phone_numbers, emails | |
| def display_extracted_info(phone_numbers, emails): | |
| if phone_numbers: | |
| st.subheader("π Extracted Pakistani Phone Numbers:") | |
| for phone in phone_numbers: | |
| st.write(f"- {phone}") | |
| else: | |
| st.info("No Pakistani phone numbers found.") | |
| if emails: | |
| st.subheader("βοΈ Extracted Emails:") | |
| for email in emails: | |
| st.write(f"- {email}") | |
| else: | |
| st.info("No emails found.") | |
| def main(): | |
| st.title("π Pakistan Resume Information Extractor") | |
| apply_custom_styles() | |
| st.write("Enter resume text below to extract Pakistani phone numbers and emails.") | |
| input_text = st.text_area("Paste your resume text here:", height=200) | |
| if st.button("Extract"): | |
| if input_text: | |
| st.markdown("---") | |
| st.header("π Extracted Information") | |
| phone_numbers, emails = extract_entities(input_text) | |
| display_extracted_info(phone_numbers, emails) | |
| else: | |
| st.warning("Please enter some text to extract entities.") | |
| # Add a "Clear" button to reset the input text area | |
| if st.button("Clear"): | |
| st.text_area("Paste your resume text here:", value="", height=200) | |
| def apply_custom_styles(): | |
| st.markdown( | |
| """ | |
| <style> | |
| body { | |
| background-color: #f5f5f5; /* Light gray background */ | |
| color: #333333; /* Dark gray text */ | |
| } | |
| .stTextInput textarea { | |
| background-color: #ffffff; /* White text area */ | |
| color: #333333; /* Dark gray text in text area */ | |
| border: 2px solid #d9d9d9; /* Light gray border */ | |
| } | |
| .stButton button { | |
| background-color: #F16623; /* Orange button */ | |
| color: #ffffff; /* White text on the button */ | |
| } | |
| .stButton button:hover { | |
| background-color: #e55c1e; /* Darker orange on hover */ | |
| } | |
| .st-info { | |
| background-color: #e6f7ff; /* Light blue info box */ | |
| color: #004085; /* Dark blue text in info box */ | |
| border: 1px solid #b8daff; /* Light blue border */ | |
| } | |
| </style> | |
| """, | |
| unsafe_allow_html=True, | |
| ) | |
| if __name__ == "__main__": | |
| main() | |