Capitalize first letter for each words except function words.

    Example::

        title = "Beautiful is Better than Ugly"

    **中文文档**

    将文本 "标题化", 即除了虚词, 每一个英文单词的第一个字母大写。

def format_title(text):
    """Capitalize first letter for each words except function words.

    Example::

        title = "Beautiful is Better than Ugly"

    **中文文档**

    将文本 "标题化", 即除了虚词, 每一个英文单词的第一个字母大写。
    """
    text = text.strip()
    # if empty string, return ""
    if len(text) == 0:
        return text
    else:
        text = text.lower()  # lower all char

        # Change to in single space format
        words = [word for word in text.strip().split(" ") if len(word) >= 1]

        # Capitalize all words except function word
        words_new = list()
        for word in words:
            if word not in FUNCTION_WORD:
                word = word[0].upper() + word[1:]
            words_new.append(word)

        # Make sure first word always be capitalized
        words_new[0] = words_new[0][0].upper() + words_new[0][1:]

        return " ".join(words_new)