What you are trying to do is text normalization, which is a part of NLP pipeline.
To successfully preprocess your data, please try this below:
Install ekphrasis
pip install ekphrasis
Apply seg & spell correction:
from ekphrasis.classes.spellcorrect import SpellCorrector
from ekphrasis.classes.segmenter import Segmenter
sp = SpellCorrector(corpus="English")
seg_eng = Segmenter(corpus="English")
words_to_correct = ['Carpanter','Carepnter','Carpentor','Labourer','Labor','Labour','Housewife','House Wife','housewife.']
for word in words_to_correct:
segmented = seg_eng.segment(word)
corrected = sp.correct(segmented)
print(word + " -> " + corrected)
Outputs as:
Carpanter -> carpenter
Carepnter -> carpenter
Carpentor -> carpenter
Labourer -> labourer
Labor -> labor
Labour -> labour
Housewife -> housewife
House Wife -> housewife
housewife. -> housewife
Note: Check this amazing work and paper if you are interested in!