Skip to content

Commit

Permalink
Convert examples in bysize to doctest.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Oct 20, 2022
1 parent 74cc135 commit 7638e3f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions inflect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,14 @@ def joinstem(cutpoint: Optional[int] = 0, words: Optional[Iterable[str]] = None)

def bysize(words: Iterable[str]) -> Dict[int, set]:
"""
take a list of words and return a dict of sets sorted by word length
e.g.
ret[3]=set(['ant', 'cat', 'dog', 'pig'])
ret[4]=set(['frog', 'goat'])
ret[5]=set(['horse'])
ret[8]=set(['elephant'])
From a list of words, return a dict of sets sorted by word length.
>>> words = ['ant', 'cat', 'dog', 'pig', 'frog', 'goat', 'horse', 'elephant']
>>> ret = bysize(words)
>>> sorted(ret[3])
['ant', 'cat', 'dog', 'pig']
>>> ret[5]
{'horse'}
"""
ret: Dict[int, set] = {}
for w in words:
Expand Down

0 comments on commit 7638e3f

Please sign in to comment.