def word_count(text: str, word: str='') -> int:
    """
    Count the number of occurences of ``word`` in a string.

    If ``word`` is not set, count all words.
    """
    if word:
        count = 0
        for text_word in text.split():
            if text_word == word:
                count += 1
        return count
    else:
        return len(text.split())