Allowed abbrev to accept the dictionary object (good for passing in shelves or PersistentDictionaries).

This commit is contained in:
Jeremy Fincher 2003-11-11 14:16:27 +00:00
parent 94041acb9b
commit 028b23d41c
1 changed files with 3 additions and 2 deletions

View File

@ -86,9 +86,10 @@ def eachSubstring(s):
for i in xrange(1, len(s)+1):
yield s[:i]
def abbrev(strings):
def abbrev(strings, d=None):
"""Returns a dictionary mapping unambiguous abbreviations to full forms."""
d = {}
if d is None:
d = {}
for s in strings:
for abbreviation in eachSubstring(s):
if abbreviation not in d: