zverok / spylls

Pure Python spell-checker, (almost) full port of Hunspell
https://spylls.readthedocs.io
Mozilla Public License 2.0
285 stars 21 forks source link

ValueError: invalid literal for int() with base 10: #14

Open zdenop opened 3 years ago

zdenop commented 3 years ago

Hello,

first of all: thanks for this project. I just try it for dictionary I maintained and it fails with : ValueError: invalid literal for int() with base 10: 'šími/Fs'

Which is great because .aff file has error, but this message does not said for ordinary user... Is there any function to check correctness of .dic and .aff files? Or at least please provide better error message with something like this:

@@ -246,10 +246,15 @@ def read_value(source: BaseReader, directive: str, *values, context: Context) ->
         ]
     if directive in ['SFX', 'PFX']:
         flag, crossproduct, count, *_ = values
-        return [
-            make_affix(directive, flag, crossproduct, *line, context=context)
-            for line in _read_array(int(count))
-        ]
+        try:
+            return [
+                make_affix(directive, flag, crossproduct, *line, context=context)
+                for line in _read_array(int(count))
+            ]
+        except ValueError as error:
+            print(f"Error at: directive, values: {directive}, {values}")
+            print(f"Maybe wrong count of rules?")
+            raise error

Most of the spellcheckers create function for end users but forgot about dictionary creators and maintainers ;-) (Aspell at least tried to report e.g. affix problems when creating dictionary from wordlist...)

zverok commented 3 years ago

Hey!

To be completely honest, when I started the project, that was one of the (distant) goals: tol also do a tool for dictionary investigation/debugging/validation (as Spylls attempts to make things more "understable and hackable"). But to put a basis in place, document it, and describe it all in a series of articles took 1,5 years of my OSS time, so currently my attention is mostly on other projects.

That being said, I'll gladly accept a PR which makes dictionary authors' life better :)