autocorrection distance limit is set to 5, rather than unlimited

This commit is contained in:
Mattias Andrée 2012-10-23 22:09:59 +02:00
parent 002f42fb0f
commit e726084422
3 changed files with 9 additions and 3 deletions

View file

@ -7,6 +7,9 @@ Version 2.9
The options --f and --F has been added. The options --f and --F has been added.
Weighted distance for autocorrection on pony names and boolean style name is set to 5, rather
than unlimited. Currently this cannot be modified (without editing the source code.)
Version 2.8 Version 2.8

View file

@ -1991,6 +1991,9 @@ may be used multiple times for more arguments.
The old option @option{-q} is renamed to @option{--q}. The old option @option{-q} is renamed to @option{--q}.
@item @item
The options @option{--f} and @option{--F} has been added. The options @option{--f} and @option{--F} has been added.
@item
Weighted distance for autocorrection on pony names and boolean style name is set to 5, rather
than unlimited. Currently this cannot be modified (without editing the source code.)
@end itemize @end itemize

View file

@ -319,7 +319,7 @@ class Ponysay():
if not alt: if not alt:
autocorrect = SpelloCorrecter(ponydirs, '.pony') autocorrect = SpelloCorrecter(ponydirs, '.pony')
(alternatives, dist) = autocorrect.correct(pony) (alternatives, dist) = autocorrect.correct(pony)
if len(alternatives) > 0: if (len(alternatives) > 0) and (dist <= 5): # TODO the limit `dist` should be configureable
return self.__getponypath(alternatives, True) return self.__getponypath(alternatives, True)
sys.stderr.write('I have never heard of anypony named %s\n' % (pony)); sys.stderr.write('I have never heard of anypony named %s\n' % (pony));
exit(1) exit(1)
@ -672,8 +672,8 @@ class Ponysay():
if balloon not in balloons: if balloon not in balloons:
if not alt: if not alt:
autocorrect = SpelloCorrecter(balloondirs, '.think' if isthink else '.say') autocorrect = SpelloCorrecter(balloondirs, '.think' if isthink else '.say')
alternatives = autocorrect.correct(balloon)[0] (alternatives, dist) = autocorrect.correct(balloon)
if len(alternatives) > 0: if (len(alternatives) > 0) and (dist <= 5): # TODO the limit `dist` should be configureable
return self.__getponypath(alternatives, True) return self.__getponypath(alternatives, True)
sys.stderr.write('That balloon style %s does not exist\n' % (balloon)); sys.stderr.write('That balloon style %s does not exist\n' % (balloon));
exit(1) exit(1)