Spaces:
Sleeping
Sleeping
Download utils/remove_html.py from tkbarb10/ads505-app: direct link, hf CLI and curl.
- Browser
- Download file 727 Bytes
-
https://huggingface.co/spaces/tkbarb10/ads505-app/resolve/main/utils/remove_html.py
- Command line
-
hf download hf://spaces/tkbarb10/ads505-app/utils/remove_html.py
-
curl -L -o remove_html.py https://huggingface.co/spaces/tkbarb10/ads505-app/resolve/main/utils/remove_html.py
727 Bytes
| import re | |
| def remove_html_tags(text): | |
| # Replace common HTML entities with their corresponding characters | |
| text = text.replace('"', '"') # Replace " | |
| text = text.replace('"', '"') # Also replace the named entity for " | |
| text = text.replace(''', "'") # Replace ' | |
| text = text.replace(''', "'") # Also replace the numeric entity for ' | |
| text = text.replace('&', '&') # Replace & | |
| text = text.replace('<br />', ' ') # Replace line breaks with a space | |
| text = text.replace('<br>', ' ') # Also handle <br> | |
| # Use regex to remove any remaining HTML tags (e.g., <p>, <div>, <span>) | |
| clean_text = re.sub(r'<[^>]+>', '', text) | |
| return clean_text.lower() |