May-07-2017, 06:14 AM
Hey guys I need help with this program please :)
I need to
[*]Write a function checkWork(word, correctionList) that can check a word against the list of errors, and if it's incorrect, return the correct spelling.
The function returns
[*]Then write a test framework that lets you input a sentence that may contain errors and displays a corrected version.
So far all I have is this and I am pretty stuck
Appreciate any clarification cheers :)
I need to
- Turn the string into a list of lists, where each sublist has two elements (the mispelling and the correctly spelt word). This is your correctionList
You can do this by (1) splitting first on the newline character ("\n") and (2) splitting each of those element on the colon (':').
TESTCASE (1): After the split using '\n' (showing only the first few items):
['adress:address', 'alot:a lot', 'athiest:atheist', 'noone:no one' …]
- After the split using :
[ ['adress', 'address'], ['alot', 'a lot'], ['athiest', 'atheist'], ['noone', 'no one'] … ]
[*]Write a function checkWork(word, correctionList) that can check a word against the list of errors, and if it's incorrect, return the correct spelling.
The function returns
- None, if the word wasn't in the list of mispellings OR
- the correct spelling of the original word
[*]Then write a test framework that lets you input a sentence that may contain errors and displays a corrected version.
So far all I have is this and I am pretty stuck
1 2 3 4 5 6 7 8 9 |
def spell_chk(): checked_list = [] for item in word_list: replacer = SpellingReplacer() r = replacer.replace(item) checked_list.append(r) return checked_list word_list = [ [ 'adress' , 'address' ], [ 'alot' , 'a lot' ], [ 'athiest' , 'atheist' ], [ 'noone' , 'no one' ]] |