def is_abbrev(abbrev, text):
    abbrev = abbrev.lower()
text = text.lower()
words = text.split()
if not abbrev:
    return True
if abbrev and not text:
    return False
if abbrev[0] != text[0]:
    return False
else:
    return is_abbrev(abbrev[1:], ' '.join(words[1:])) or any(is_abbrev(
        abbrev[1:], text[i + 1:]) for i in range(len(words[0])))
for abbrev, text, answer in tests:
    result = is_abbrev(abbrev, text)
print((abbrev, text, result, answer))
assert result == answer
Check if a string is a possible abbrevation for a name