Hey ,
Have a task i want to do I have a .txt file with mispelt words and a .txt file which is a dictionary and has correct spelling of words now i know that i need to split both of the .txt files into words , i need to convert the mispelt.txt to lower case (but alway get object has no attribute) and then subtract them form each other and whats left will be the mispelt words
mispel.txt is text with mispelt words
corspel.txt is dictionary
here is what i have so far that split the mispelt.txt into lines

import sys
import string
infile = open('mispel.txt', 'r') 
infile2 = open('corspel.txt', 'r').read()
words = set(open('mispel.txt').read().split())

Recommended Answers

All 5 Replies

sorry what i have their splits the mispelt.txt into words so need to conevrt them to lowercase get error all the time using lower() and then somehow subtract the two to see the mispelt words

put lower() after read().: words = set(open('mispel.txt').read().lower().split()) Do you need to suggest correct spelling for the incorrect words?

yes i do but im struggling so much that i havent thought that far ahead and have no idea how to do that

ok so not sure of exact syntax to replace punctuation with " "
i think it would be something like

def pun(s):
    for ch in 'mispel.txt'.punctuation:
        s = s.replace(ch, ' ')
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.