projects
/
python_utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
fc113e1
)
Clarify instructions for repopulation.
author
Scott
<
[email protected]
>
Wed, 26 Jan 2022 06:15:08 +0000
(22:15 -0800)
committer
Scott
<
[email protected]
>
Wed, 26 Jan 2022 06:15:08 +0000
(22:15 -0800)
unscrambler.py
patch
|
blob
|
history
diff --git
a/unscrambler.py
b/unscrambler.py
index 056107f3fb66f39e8c13f9082c922b544898f493..e53ec2a51dc91d095c697d8176127c94b4c5dc49 100755
(executable)
--- a/
unscrambler.py
+++ b/
unscrambler.py
@@
-8,8
+8,7
@@
import decorator_utils
import list_utils
cfg = config.add_commandline_args(
import list_utils
cfg = config.add_commandline_args(
- f'Unscramble! ({__file__})',
- 'A fast word unscrambler.'
+ f'Unscramble! ({__file__})', 'A fast word unscrambler.'
)
cfg.add_argument(
"--unscramble_indexfile",
)
cfg.add_argument(
"--unscramble_indexfile",
@@
-159,9
+158,9
@@
class Unscrambler(object):
@staticmethod
def repopulate(
@staticmethod
def repopulate(
-
letter_sigs: Dict[str, int],
-
dictfile: str = '/usr/share/dict/words',
-
indexfile: str = '/usr/share/dict/sparse_index',
+ letter_sigs: Dict[str, int],
+ dictfile: str = '/usr/share/dict/words',
+ indexfile: str = '/usr/share/dict/sparse_index',
) -> None:
"""Before calling this method, change letter_sigs from the default above
unless you want to populate the same exact files."""
) -> None:
"""Before calling this method, change letter_sigs from the default above
unless you want to populate the same exact files."""
@@
-196,7
+195,9
@@
class Unscrambler(object):
"""
sig = Unscrambler.compute_word_sig(word)
"""
sig = Unscrambler.compute_word_sig(word)
- return Unscrambler.lookup_by_sig(sig, include_fuzzy_matches=include_fuzzy_matches)
+ return Unscrambler.lookup_by_sig(
+ sig, include_fuzzy_matches=include_fuzzy_matches
+ )
@staticmethod
def lookup_by_sig(sig, *, include_fuzzy_matches=False) -> Dict[str, bool]:
@staticmethod
def lookup_by_sig(sig, *, include_fuzzy_matches=False) -> Dict[str, bool]:
@@
-241,15
+242,17
@@
class Unscrambler(object):
word = Unscrambler.words[x]
fsig = Unscrambler.sigs[x]
if include_fuzzy_matches is True or (fsig == sig):
word = Unscrambler.words[x]
fsig = Unscrambler.sigs[x]
if include_fuzzy_matches is True or (fsig == sig):
- ret[word] =
(fsig == sig)
+ ret[word] =
fsig == sig
return ret
return ret
+
#
# To repopulate, change letter_sigs and then call Unscrambler.repopulate.
#
# To repopulate, change letter_sigs and then call Unscrambler.repopulate.
-# See notes above.
+# See notes above.
See also ~/bin/unscramble.py --populate_destructively.
#
if __name__ == "__main__":
import doctest
#
if __name__ == "__main__":
import doctest
+
doctest.testmod()
doctest.testmod()