aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-10-23 22:09:59 +0200
committerMattias Andrée <maandree@operamail.com>2012-10-23 22:09:59 +0200
commite726084422b59e5167c5cb0fdb5909c753e31e10 (patch)
treef59e3d8698430f6a50defc3595665e8e8f697f04
parent002f42fb0f8da093c9f1cd4b531c7ad3f5970ed3 (diff)
downloadponysay-e726084422b59e5167c5cb0fdb5909c753e31e10.tar.gz
ponysay-e726084422b59e5167c5cb0fdb5909c753e31e10.tar.bz2
ponysay-e726084422b59e5167c5cb0fdb5909c753e31e10.zip
autocorrection distance limit is set to 5, rather than unlimited
-rw-r--r--CHANGELOG3
-rw-r--r--manuals/ponysay.texinfo3
-rwxr-xr-xponysay.py6
3 files changed, 9 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 3e77fdf..56ebff2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,9 @@ Version 2.9
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
diff --git a/manuals/ponysay.texinfo b/manuals/ponysay.texinfo
index fc96d07..f2c9cb8 100644
--- a/manuals/ponysay.texinfo
+++ b/manuals/ponysay.texinfo
@@ -1991,6 +1991,9 @@ may be used multiple times for more arguments.
The old option @option{-q} is renamed to @option{--q}.
@item
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
diff --git a/ponysay.py b/ponysay.py
index 44ff009..502b85f 100755
--- a/ponysay.py
+++ b/ponysay.py
@@ -319,7 +319,7 @@ class Ponysay():
if not alt:
autocorrect = SpelloCorrecter(ponydirs, '.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)
sys.stderr.write('I have never heard of anypony named %s\n' % (pony));
exit(1)
@@ -672,8 +672,8 @@ class Ponysay():
if balloon not in balloons:
if not alt:
autocorrect = SpelloCorrecter(balloondirs, '.think' if isthink else '.say')
- alternatives = autocorrect.correct(balloon)[0]
- if len(alternatives) > 0:
+ (alternatives, dist) = autocorrect.correct(balloon)
+ if (len(alternatives) > 0) and (dist <= 5): # TODO the limit `dist` should be configureable
return self.__getponypath(alternatives, True)
sys.stderr.write('That balloon style %s does not exist\n' % (balloon));
exit(1)