-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutputFormatter.py
More file actions
25 lines (22 loc) · 850 Bytes
/
OutputFormatter.py
File metadata and controls
25 lines (22 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class OutputFormatter:
def __init__(self): pass
# Output Biasa/ngikutin Input
class Original(OutputFormatter):
def format(self, originalText, processedText):
text = list(originalText)
cpr = list(processedText)
text = [cpr.pop(0) if c.isalpha() else c for c in text]
return "".join(text)
# Output Tanpa Spasi
class NoSpaces(OutputFormatter):
def format(self, originalText, processedText):
text = list(originalText)
cpr = list(processedText)
text = [cpr.pop(0) if c.isalpha() else c for c in text]
text = "".join(text)
return text.replace(' ', '')
# Output Kelompok 5 Huruf
class GroupOfWords(OutputFormatter):
def format(self, originalText, processedText):
N = 5
return " ".join([processedText[i:i+N] for i in range(0, len(processedText), N)])