def doc_to_labels(document):
    """
    Converts document to a label: list of cluster ids.
    :param document: Document object
    :return: list of cluster ids.
    """
    labels = []
    word_to_cluster = document.words_to_clusters()
    cluster_to_id = {cluster:cluster_id for cluster_id, cluster in enumerate(document.get_clusters())}

    for word in document.get_words():
        cluster = word_to_cluster[word]
        cluster_id = cluster_to_id[cluster] if cluster else -1
        labels.append(cluster_id)

    return labels