Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to TCL programming need some help

Status
Not open for further replies.

tmilstead77

Technical User
Jun 24, 2013
4
0
0
US
I am learning TCL and have been given an assignment to test my knowledge. I am trying to create a simple spell checker, but am having a hard time getting all my parameters met. I think I can accomplish these requirements with regular expressions, but I am not sure how to go about it properly. Here is my problem:

Spell check rules:

1. The spell checker should be case insensitive. Meaning, if the word ‘APRIL’ is found in the input file and the word ‘April’ is defined in the dictionary file, then it should not regard this as a mistake.

2. Punctuation marks and symbols should be ignored. Words enclosed in quotes should still be checked.

3. Numbers should be ignored unless they are in ordinal form (e.g. 1st, 2nd, 3rd, etc). Commas in large numbers are valid (e.g. 29,300).

4. Words ending with a possessive apostrophe (’s) should be ignored and not considered mistakes.


Now I've worked out the problem for case 1. But like I said I believe I can work out the other requirements with regex(es) but Im not sure how to go about it. Any help would be greatly appreciated.
 
And just let me say I am not a student. I have to learn this language for my job, but I'm not getting any help in learning other than here's the material go learn it. I'm a show me kinda learner that's all.
 
What form does your dictionary have (a list of valid words?)?

_________________
Bob Rashkin
 
OK. You say you have the case sensitivity issue resolved but let's review. The list (dictionary) should be all lower case. Then you use "string tolower ..." on each word being tested. Then on the words that fail, use regsub to remove everything but the letters. So let's say you have a word, test_word (that's a variable name). Then:
Code:
regsub -all ![a-zA-z] $test_word "" test_word
then test it again.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top