Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132923 views
License: OTHER
1
import re
2
3
4
class TransformUtil:
5
6
@classmethod
7
def remove_punctuation(cls, value):
8
"""Removes !, #, and ?.
9
"""
10
return re.sub('[!#?]', '', value)
11
12
@classmethod
13
def clean_strings(cls, strings, ops):
14
"""General purpose method to clean strings.
15
16
Pass in a sequence of strings and the operations to perform.
17
"""
18
result = []
19
for value in strings:
20
for function in ops:
21
value = function(value)
22
result.append(value)
23
return result
24