def translate(words, tab=None):
    """Enumerates a collection of words.

    Each word will be translated into a integer.
    """
    tab = tab if isinstance(tab, dict) else {}
    i = 0
    for word in words:
        if word not in tab:
            tab[word] = i
            i += 1
        yield tab[word]
