# pyemblib
A module for reading, writing, and using trained word embeddings.
## Installation
Install with pip!
`bash pip install pyemblib `
## Usage
This package currently supports word embeddings trained by the following packages:
[word2vec](https://code.google.com/archive/p/word2vec/)
### Reading
Both text-format and binary embedding files are supported.
The example below shows reading each format of embedding: `python ## import text embeddings text_embs = pyemblib.read('/tmp/text_embeddings.txt', mode=pyemblib.Mode.Text) ## import binary embeddings bin_embs = pyemblib.read('/tmp/bin_embeddings.bin', mode=pyemblib.Mode.Binary) `
Embeddings are read as a pyemblib.Embeddings object, which inherits from Python’s dictionary class; keys are words, and values are the embedding arrays.
To get the word vector for “python”, just use dictionary access: `python vec = embs['python'] print(vec) # [ 0.001 -0.237 ... ] `
### Writing
The same text and binary modes can be used for writing out embedding files as for reading.
`python embs = { 'a' : np.array([0.3 0.1 -0.2]), 'b' : np.array([-0.9, -0.2, -0.2]) } ## write as text pyemblib.write(embs, '/tmp/text_embeddings.txt', mode=pyemblib.Mode.Text) ## write as binary pyemblib.write(embs, '/tmp/bin_embeddings.bin', mode=pyemblib.Mode.Binary) `
## Feedback Please report any issues you encounter to the [Github Issues page](https://github.com/drgriffis/pyemblib/issues)!
Release files for pyemblib 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyemblib-0.1.2.tar.gz | 8.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyemblib-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.3 kB
Release files / pyemblib-0.1.2.tar.gz
| Download URL | pyemblib-0.1.2.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
06bc1065538c08ae6432d3899b4e2efa145c194e2a1f8b8cfbedc2c1981e31c0
|
|
BLAKE2b-256 checksum How to use checksums |
bc851755939056815f578861fd507bd79162fcd677e257e29d76f274578b7068
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / pyemblib-0.1.2-py3-none-any.whl
| Download URL | pyemblib-0.1.2-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5310389e0b8c9b2b779e9520d8f63ce4f85b6ce15dee8ff816068d583b685f8c
|
|
BLAKE2b-256 checksum How to use checksums |
4125ea8557bddb839b2dd3541c98dff7c49bd46bed372b9ef542b2e3b8270a7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|