A portable document embedding using SWEM.
Project description
SWEM
Implementation of SWEM(Simple Word-Embedding-based Models)
Baseline Needs More Love: On Simple Word-Embedding-Based Models and Associated Pooling Mechanisms (ACL 2018)
Installation
pip install swem
Example
Examples are available in examples directory.
Japanese
import swem
from gensim.models import KeyedVectors
if __name__ == '__main__':
model = KeyedVectors.load('wiki_mecab-ipadic-neologd.kv')
swem_embed = swem.SWEM(model)
doc = 'すもももももももものうち'
embed = swem_embed.infer_vector(doc, method='max')
print(embed.shape)
Results
(200,)
English
import swem
from gensim.models import KeyedVectors
if __name__ == '__main__':
model = KeyedVectors.load('wiki_mecab-ipadic-neologd.kv')
swem_embed = swem.SWEM(model, lang='en')
doc = 'This is an implementation of SWEM.'
embed = swem_embed.infer_vector(doc, method='max')
print(embed.shape)
Results
(200,)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
swem-0.1.3.tar.gz
(6.2 kB
view hashes)
Built Distribution
swem-0.1.3-py3-none-any.whl
(4.9 kB
view hashes)