I just started learning python. I was trying to clean a sentence by breaking into words and joining back to a sentence. the document big.txt has some words like youth, caretaker etc. The problem is in the final procedure : looper , This produces an output by each line.
Correct is an another procedure defined before this code that corrects each word
here is the code :
zebra = 'Yout caretak taking care of something'
count = len(re.findall(r'\w+', zebra))
def looper(a,count):
words = nltk.word_tokenize(zebra)
for i in range(len(words)):
X = correct(words[i])
print (X)
final = looper(zebra)
The output it produces:
youth
caretaker
walking
car
in
something
How should I take all the individual outputs and make a sentence:
Expected Result:
youth caretaker walking car in something
Please let me know if you need additional details.
Thanks in advance