def get_is_head_of_word(naive_tokens, sequence_tokens):
    """
    Return a list of flags whether the token is head(prefix) of naively split tokens

    ex) naive_tokens: ["hello.", "how", "are", "you?"]
        sequence_tokens: ["hello", ".", "how", "are", "you", "?"]

        => [1, 0, 1, 1, 1, 0]

    * Args:
        naive_tokens: a list of tokens, naively split by whitespace
        sequence_tokens: a list of tokens, split by 'word_tokenizer'

    * Returns:
        is_head_of_word: a list with its length the same as that of 'sequence_tokens'.
            has 1 if the tokenized word at the position is head(prefix) of a `naive_token`
            and 0 if otherwise.
    """
    is_head_of_word = []
    for naive_token in naive_tokens:
        consumed_chars = 0
        consumed_words = 0
        for sequence_token in sequence_tokens:
            if naive_token[consumed_chars:].startswith(sequence_token):
                is_head_of_word.append(0 if consumed_chars else 1)
                consumed_chars += len(sequence_token)
                consumed_words += 1
            else:
                break
        sequence_tokens = sequence_tokens[consumed_words:]
    return is_head_of_word
