Exemplo n.º 1
0
def create_representation(args):
    rep_type = args['<representation>']
    path = args['<representation_path>']
    w_c = args['--w+c']
    eig = float(args['--eig'])

    if rep_type == 'PPMI':
        if w_c:
            raise Exception('w+c is not implemented for PPMI.')
        else:
            return Explicit.load(path, True)

    elif rep_type == 'SVD':
        if w_c:
            return EnsembleEmbedding(SVDEmbedding(path, False, eig, False),
                                     SVDEmbedding(path, False, eig, True),
                                     True)
        else:
            return SVDEmbedding(path, True, eig)

    else:
        if w_c:
            return EnsembleEmbedding(Embedding.load(path + '.words', False),
                                     Embedding.load(path + '.contexts', False),
                                     True)
        else:
            return Embedding.load(path, True)
def create_representation(args):
    rep_type = args['<representation>']
    path = args['<representation_path>']
    neg = int(args['--neg'])
    w_c = args['--w+c']
    eig = float(args['--eig'])
    normalize = args['--normalize']

    if rep_type == 'PPMI':
        if w_c:
            raise Exception('w+c is not implemented for PPMI.')
        else:
            return PositiveExplicit(path, normalize, neg)

    elif rep_type == 'SVD':
        if w_c:
            return EnsembleEmbedding(SVDEmbedding(path, normalize, eig, False),
                                     SVDEmbedding(path, normalize, eig, True),
                                     normalize)
        else:
            return SVDEmbedding(path, normalize, eig)

    else:
        if w_c:
            return EnsembleEmbedding(Embedding(path + '.words', normalize),
                                     Embedding(path + '.contexts', normalize),
                                     normalize)
        else:
            return Embedding(path + '.words', normalize)
def create_representation(args):
    rep_type = args['<representation>']
    path = args['<representation_path>']
    neg = int(args['--neg'])
    w_c = args['--w+c']
    eig = float(args['--eig'])

    if rep_type == 'PPMI':
        if w_c:
            raise Exception('w+c is not implemented for PPMI.')
        else:
            return PositiveExplicit(path, True, neg)

    elif rep_type == 'SVD':
        if w_c:
            return EnsembleEmbedding(SVDEmbedding(path, False, eig, False),
                                     SVDEmbedding(path, False, eig, True),
                                     True)
        else:
            return SVDEmbedding(path, True, eig)

    elif rep_type == 'SGNS':
        if w_c:
            return EnsembleEmbedding(Embedding(path + '.words', False),
                                     Embedding(path + '.contexts', False),
                                     True)
        else:
            return Embedding(path + '.words', True)
    elif rep_type == 'discriminative':
        return discriminative_embedding(path, True, eig)
    elif rep_type == 'discriminative_SGNS':
        return discriminative_SGNS(path, True)

    elif rep_type == 'projective':
        return Projective_embedding(path)
def create_representation(rep_type, path, *args, **kwargs):
    if rep_type == 'Explicit' or rep_type == 'PPMI':
        return Explicit.load(path, *args, **kwargs)
    elif rep_type == 'SVD':
        return SVDEmbedding(path, *args, **kwargs)
    elif rep_type == 'GIGA':
        return GigaEmbedding(path, *args, **kwargs)
    elif rep_type == 'Embedding':
        return Embedding.load(path, *args, **kwargs)