from bs4 import BeautifulSoup
import re


def review_to_wordlist(review):
    """
    Function to convert a document to a sequence of words.
    Returns a list of words.
    """
    # Remove HTML
    review_text = BeautifulSoup(review).get_text()
    #
    # Remove non-letters
    review_text = re.sub("[^a-zA-Z]"," ", review_text)
    #
    # Convert words to lower case and split them
    words = review_text.lower().split()

    return(words)