A place to discuss Joel on Software. Now closed.
This community works best when people use their real names. Please register for a free account.
Joel on Software
Business of Software
Design of Software (CLOSED)
.NET Questions (CLOSED)
Fog Creek Copilot
The Old Forum
Albert D. Kallal
To cut a very long story short, I've got an automated build process for some application that writes out a set of string resources as a text files. This text file then gets whizzed over to somebody else to review all the text, mainly to make sure our software never ends up on TheDailyWTF's "Error'd" section ;-)
To streamline things a bit, I'd like to run an automatic spell check on this file as part of our build, so if somebody writes a string resource with a spelling mistake, it gets caught and thrown back immediately at build time, rather than waiting for a human to check it.
A couple of options that spring to mind:
* Download the source to aspell and port it to Windows via cygwin.
* Use Windows Powershell to launch Word in the background and spell check the file.
Do any of you lot have any better ideas? Somebody else somewhere must have done something similar....
PS: Yes, I make spelling mistakes too.
There is already a compiled windows port on the aspell website, I use it to spell check my latex sources. It works fine.
Wednesday, January 28, 2009
Yup, aspell looks like it'll do the job perfectly. End of thread.
This script will use Word in the background and spell checks the clipboard. You can modify the msgbox part to handle errors the way you want plus look elsewhere other than the clipboard for the text. Its mainly an idea on how to use the Word object that you can learn from and modify.
Dim oWD, RangeOriginal, RangeCorrected, Cnt, Status
Set oWD = WScript.CreateObject("Word.Application")
On Error Resume Next
If err.number<>0 then
MsgBox "Clipboard was Empty"
If oWD.CheckSpelling(RangeOriginal)=False Then
Set RangeCorrected = oWD.ActiveDocument.Range(0,oWD.Selection.End)
If RangeCorrected.Words.Count>7 Then
Status= "The text beginning with: "&_
RangeCorrected.Words.Item(1)&" "&RangeCorrected.Words.Item(2)&" "&_
RangeCorrected.Words.Item(3)&"....."&vbCRLF&"and ending with: ....."&_
" "&RangeCorrected.Words.Item(Cnt)&vbCRLF&"has been checked "&_
"and corrected version copied to the clipboard"
Status= "<< "&RangeCorrected&" >>"&vbCRLF&"has been checked and the"&_
" corrected version was copied to the clipboard"
Status= "All words in the clipboard were spelled correctly"
That looks terrifying! I solved my problem in the end with a one line bash script calling out to aspell, awk and uniq (but not necessarily in that order).
Sorry, that was a bit caustic - I know you're trying to help and it would work, albeit with some changes.
Thursday, January 29, 2009
This topic is archived. No further replies will be accepted.Other recent topics
Powered by FogBugz