ieml/distance/projection.py
def project_usl_with_data(usls_data, metric=None):
    """
    usls_data: usl => data[]
    :param usls_data:
    :return:
    """

    projection = project_usls_on_dictionary(usls_data)
    all_terms = set(c for u in usls_data for t in u.objects(Term) for c in t.singular_sequences)
    if metric is None:
        metric = lambda e: len(e['posts']) * len(all_terms.intersection(e['table'].singular_sequences))

    return sorted(({
        'table': table,
        'usls': usls,
        'posts': list(set(chain.from_iterable(usls_data[u] for u in usls)))
    } for table, usls in projection.items()), key=metric, reverse=True)
def project_usl_with_data(usls_data, metric=None):
    """
    usls_data: usl => data[]
    :param usls_data:
    :return:
    """

    projection = project_usls_on_dictionary(usls_data)
    all_terms = set(c for u in usls_data for t in u.objects(Term) for c in t.singular_sequences)
    if metric is None:
        metric = lambda e: len(e['posts']) * len(all_terms.intersection(e['table'].singular_sequences))

    return sorted(({
        'table': table,
        'usls': usls,
        'posts': list(set(chain.from_iterable(usls_data[u] for u in usls)))
    } for table, usls in projection.items()), key=metric, reverse=True)
def project_usl_with_data ( usls_data , metric = None ) : projection = project_usls_on_dictionary ( usls_data ) all_terms = set ( c for u in usls_data for t in u . objects ( Term ) for c in t . singular_sequences ) if metric is None : metric = lambda e : len ( e [ 'posts' ] ) * len ( all_terms . intersection ( e [ 'table' ] . singular_sequences ) ) return sorted ( ( { 'table' : table , 'usls' : usls , 'posts' : list ( set ( chain . from_iterable ( usls_data [ u ] for u in usls ) ) ) } for table , usls in projection . items ( ) ) , key = metric , reverse = True )
usls_data: usl => data[]
    :param usls_data:
    :return:
usls_data : usl = > data [] : param usls_data : : return :