src.utils.text

Module Contents

Functions

isolate_punctuation(text)

Isolate punctuation in a sentence.

replace_urls(text, replace_with=’<URL>’)

Replace urls in a sentence with a chosen string.

src.utils.text.isolate_punctuation(text)[source]

Isolate punctuation in a sentence.

>>> split_punctuation('Hi there!')
'Hi there !'
Parameters

text (str) – Input sentence

Returns

Output sentence with isolated punctuation

Return type

str

src.utils.text.replace_urls(text, replace_with='<URL>')[source]

Replace urls in a sentence with a chosen string.

>>> replace_urls("I love https://github.com")
"I love <URL>"
Parameters
  • text (str) – Input sentence

  • replace_with (str, optional) – string to replace the url with. Defaults to “<URL>”.

Returns

Output sentence with replaced url

Return type

str