* WGs marked with an * asterisk has had at least one new draft made available during the last 5 days

Idspell Tool

Version: 0.11
Author:
Idspell Webservice | Change log | Browse code | | Copyright

Code

#!/usr/bin/python
# Based on Sam Ruby's http://www.intertwingly.net/code/spellcheck.py 09 May 2006:

__version__ = "0.11"

import commands, re, sys

def spellcheck(filename, extradict):

    # call out to aspell program
    #print 'aspell --lang=en -p %s -a < %s' % (extradict, filename)
    aspell=commands.getoutput('aspell --lang=en -p %s -a < %s' % (extradict, filename))

    # split out all questionable words, with replacement alternatives
    aspell=dict(re.compile('^& (\w+) \d+ \d+: (.*)',re.M).findall(aspell))

    # substitute questionable words in text with a titled span
    if aspell:
        text = open(filename).read()
        words=re.split(r'\b(\S+)\b', text)
        count = 0
        prevcount = 0
        badwords = {}
        for j in range(0,len(words)):
            if words[j] in aspell:
                count += 1
                badwords[words[j]] = 1
                words[j] = """<a name="word-%d" class="spellcheck" href="http://google.com/search?q=define:%s" title="%s">%s</a>""" % (count, words[j], aspell[words[j]],words[j])
            if "\n" in words[j]:
                if count > prevcount:
                    prevcount = count
                    words[j] = words[j].replace("\n", """<div style="float:right"><a style="text-decoration: none" href="#word-%d"><b>&darr;</b></a></div>\n""" % (count+1), 1)

        text="".join(words)

        # return the concatenated result
        return count, badwords, text
    else:
        return -1, {}, "No output from spelling checker"

if __name__ == '__main__':
    if len(sys.argv) > 1:
        if sys.argv[1] == "--version":
            print "idspell %s" % __version__
        elif sys.argv[1] == "--help":
            print """

idspell is a shell around aspell (http://aspell.sourceforge.net/) and a
custom-built additional ietf wordlist. The wordlist is built from the last 2
years' published RFCs, augmented with the surnames of I-D authors culled from
xml2rfc's reference bibliography and a short list of manually added words.

       """
        else:
            print spellcheck(sys.argv[1], "/www/tools.ietf.org/tools/idspell/ietf-words.wl" )[2]
    else:
        print """Usage: spellcheck FILE"""

Latest update: 2007-03-28 08:43 PDT - webmaster@tools.ietf.org