Hides non-desired text
Project description
Hidetext
Extensible Python library to hide fragments of text.
Installation
Requirements: python >= 3.8
It can be easily installed with:
pip install -U hidetext
Basic usage
from hidetext import Hidetext
hide = Hidetext()
print(hide.character("""
Dear Mr Robinson,
I'm contacting you regarding
My DNI is 43244328J.
Email: fdsfsd@gmail.com
"""))
Dear Mr Robinson,
I'm contacting you regarding
My DNI is *********.
Email: ****************
print(hide.kind("""
Dear Mr Robinson,
I'm contacting you regarding
My DNI is 43244328J.
Email: fdsfsd@gmail.com
"""))
Dear Mr Robinson,
I'm contacting you regarding
My DNI is <ID_CARD>.
Email: <EMAIL>
Creating custom filters
It's easy to create custom filters to remove undesired text using PatternFilter
:
from typing import Dict
from hidetext import Hidetext
from hidetext.filters import PatternFilter
class HourFilter(PatternFilter):
name: str = "HOUR"
patterns: Dict[str, str] = {
"digital_hour": r"\d{2}(:\d{2}){1,2}",
"hour": "\d{1,2}\s?(am|pm)"
}
hide = Hidetext(filters=[HourFilter()])
hide.kind("The train departs at 15:45 and arrives at 19:35, therefore I'll be at the party at 8pm.")
"The train departs at <HOUR> and arrives at <HOUR>, therefore I'll be at the party at <HOUR>."
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hidetext-0.1.1.tar.gz
(7.3 kB
view hashes)
Built Distribution
hidetext-0.1.1-py3-none-any.whl
(10.3 kB
view hashes)