Spaces:
Build error
Build error
Download Components/FindKeyword.py from waloneai/Resume-filter-plus-QA-documents: direct link, hf CLI and curl.
- Browser
- Download file 809 Bytes
-
https://huggingface.co/spaces/waloneai/Resume-filter-plus-QA-documents/resolve/main/Components/FindKeyword.py
- Command line
-
hf download hf://spaces/waloneai/Resume-filter-plus-QA-documents/Components/FindKeyword.py
-
curl -L -o FindKeyword.py https://huggingface.co/spaces/waloneai/Resume-filter-plus-QA-documents/resolve/main/Components/FindKeyword.py
809 Bytes
| import re | |
| def FindKeyWords(keywords, text): | |
| highlighted_text = text | |
| for keyword in keywords: | |
| if re.search(r'\b({0})\b'.format(re.escape(keyword)), highlighted_text, flags=re.IGNORECASE): | |
| highlighted_text = re.sub(r'\b({0})\b'.format(re.escape(keyword)), r'<mark style="background-color: yellow;">\1</mark>', highlighted_text, flags=re.IGNORECASE) | |
| else: | |
| return "Keyword not found in the Resume." | |
| return highlighted_text | |
| def filter_keywords(all_text, keywords): | |
| filtered_text = [] | |
| for item in all_text: | |
| filename = item['filename'] | |
| text = item['text'] | |
| filtered_text_with_keywords = FindKeyWords(keywords, text) | |
| filtered_text.append({"filename": filename, "text": filtered_text_with_keywords}) | |
| return filtered_text |