DEV Community

Ben
Ben

Posted on

Introducing Safe-Text API

I made an API for text cleansing, most of Python enthusiast already dealt with text right ? Some among us have probably a web-app or other solution based on user content.

The thing about text, is that it is so fragile; It can break the whole website, or at least can have rest in DB as scrambled as the user posted it but finally ends again screwing UI and giving a bad end user experience

For this, there are already many solutions, some rely on complex #regex, basic or advanced algorithms, or even heavy machine learning models.
I wrapped dozens of solutions of a multitude of technologies, from #Python to #Rust to #WebAssembly all in one single API !

It is only accessible through #RapidAPI but it comes with a generous free tier 📷
Please, give us a start if you are already on
@rapid_api

If you feel like criticizing, please keep it constructive, I will be happy to follow with your ideas.

Current models:

  • FixHTML.
  • DOMPurify.
  • Linkify.
  • Fix mojibark.
  • Punctuate.
  • Decancer.
  • Remove bad words.
  • Remove sensitive data.
  • Strip tags.
  • Wrap text. (comming soon)
  • Detect Language.

Examples of effective cleansing

FixHTML
<p>here is a para <b>bold <i>bold italic</i></b> bold? normal?

turns into

</p><p>here is a para <b>bold <i>bold italic</i> bold?</b> normal?

DOMPurify
very bad html (cannot post here)

turns into

safe html

Linkify
Any links to github.com here? If not, contact test@example.com

turns into

'Any links to <a href="https://github.com">github.com</a> here? If not, contact <a href="mailto:test@example.com">test@example.com</a>'

Fix mojibark

The Mona Lisa doesn’t have eyebrows.

turns into

The Mona Lisa doesn't have eyebrows.

Punctuate
hello world

turns into
Hello world.

Decancer
vEⓡ𝔂 𝔽𝕌Ňℕy ţ乇𝕏𝓣

turns into

very funny text

Remove bad words

you are a bad ass

turns into
you are a bad ***

Remove sensitive data

My dads credit card number is: 5555555555554444

turns into
My dads credit card number is: ################

Strip tags

<a href="#"> this is my cat</a>

turns into
this is my cat

Wrap text

(comming soon)

Detect Language

Bonjour Paris

gives

french

Note that Safe-Text API is a gigantic wrapper on top of other bright solutions; We have glued many other bright libraries to work in one single API. It is a complex solution technically as many technologies (Python, Rust, Wasm, Node ...) are all working together in one single API call.

Link to doc: https://ns514514.ip-142-4-215.net/
Link to RapidAPI: https://rapidapi.com/bacloud14/api/safe-text

You can head to https://ns514514.ip-142-4-215.net/documentation to try the API.

Kindly

Top comments (0)