koaning/whatlies

Allow `merge` to also accept a single Embedding.

koaning opened this issue · 2 comments

I wrote myself a helper today, it looked like this;

def add_origin(emb):
    return emb.merge(EmbeddingSet(Embedding("origin", np.zeros(emb.ndim))))

embset.pipe(add_origin)

It looks a bit silly, but it works. It's probably cleaner if EmbeddingSet.merge also accepts a single Embedding as input. @mkaze I recall a conversation about this but I couldn't find it. Would you agree though that it might be nice to be able to add a single embedding this way? That way, the code might look like:

def add_origin(emb):
    return emb.merge(Embedding("origin", np.zeros(emb.ndim)))

embset.pipe(add_origin)
mkaze commented

Sure, I am in favor of having this.

@mkaze I recall a conversation about this but I couldn't find it.

Yeah, it was suggested here.

I'm closing issues because ever since the project moved to my personal account it's been more into maintenance mode than a "active work" mode.