def to_relevance_scores(y_true, y_pred):
    """
    Returns a list of relevance scores (binary), which can be used in various
    information retrieval metrics

    :param y_true: a list of relevant items (such as document ids)
    :param y_pred: a list of predicted items
    :return: a list of binary relevance scores, ex. [1, 0, 1, 1, 0, ...]
    """
    rel_scores = [0] * len(y_pred)
    for i, d in enumerate(y_pred):
        if d in y_true and d not in y_pred[:i]:
            rel_scores[i] = 1
    return rel_scores