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)
Пример #2
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'])

    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)