glove-android
is an Android library that provides an interface for using popular GloVe
word embeddings.
- Download
glove-android.aar
from the latest release. (See Releases) - Move the AAR to
app/libs
. - In module-level
build.gradle
, add the dependency,
dependencies {
...
implementation files('libs/glove-android.aar')
...
}
To load the embeddings from storage, use the GloVe.loadEmbeddings
method, which returns a GloveEmbeddings
object as a parameter in the given lambda function.
val gloveEmbeddings: GloVeEmbeddings
GloVe.loadEmbeddings {
gloveEmbeddings = it
}
Call the gloveEmbeddings.getEmbedding
method providing a word as parameter. The resultant embedding
is returned as a FloatArray
with size=50
(indicating a 50-D embedding).
val embedding = gloveEmbeddings.getEmbedding( "hello" )
println( embedding.contentToString() )
If no embedding is found for the given word, an empty
FloatArray
is returned
@inproceedings{pennington2014glove,
author = {Jeffrey Pennington and Richard Socher and Christopher D. Manning},
booktitle = {Empirical Methods in Natural Language Processing (EMNLP)},
title = {GloVe: Global Vectors for Word Representation},
year = {2014},
pages = {1532--1543},
url = {http://www.aclweb.org/anthology/D14-1162},
}