Skip to content

This function interfaces with Python via reticulate to create a WordEmbeddings object using the Flair library. Users select which pre-trained embeddings to load by providing the appropriate ID string. Typically, a two-letter language code initializes an embedding (e.g., 'en' for English, 'de' for German). By default, this loads FastText embeddings trained over Wikipedia. For web crawl embeddings, use the '-crawl' suffix (e.g., 'de-crawl' for German). English offers more options like 'en-glove', 'en-extvec', etc.

Supported embeddings include:

  • 'en-glove' or 'glove': English GloVe embeddings

  • 'en-extvec' or 'extvec': English Komninos embeddings

  • 'en-crawl' or 'crawl': English FastText web crawl embeddings

  • 'en-twitter' or 'twitter': English Twitter embeddings

  • 'en-turian' or 'turian': English Turian embeddings (small)

  • 'en', 'en-news', or 'news': English FastText news and Wikipedia embeddings

  • 'de': German FastText embeddings

  • 'nl': Dutch FastText embeddings

  • 'fr': French FastText embeddings

  • 'it': Italian FastText embeddings

  • 'es': Spanish FastText embeddings

  • 'pt': Portuguese FastText embeddings

  • 'ro': Romanian FastText embeddings

  • 'ca': Catalan FastText embeddings

  • 'sv': Swedish FastText embeddings

  • 'da': Danish FastText embeddings

  • 'no': Norwegian FastText embeddings

  • 'fi': Finnish FastText embeddings

  • 'pl': Polish FastText embeddings

  • 'cz': Czech FastText embeddings

  • 'sk': Slovak FastText embeddings

  • 'sl': Slovenian FastText embeddings

  • 'sr': Serbian FastText embeddings

  • 'hr': Croatian FastText embeddings

  • 'bg': Bulgarian FastText embeddings

  • 'ru': Russian FastText embeddings

  • 'ar': Arabic FastText embeddings

  • 'he': Hebrew FastText embeddings

  • 'tr': Turkish FastText embeddings

  • 'fa': Persian FastText embeddings

  • 'ja': Japanese FastText embeddings

  • 'ko': Korean FastText embeddings

  • 'zh': Chinese FastText embeddings

  • 'hi': Hindi FastText embeddings

  • 'id': Indonesian FastText embeddings

  • 'eu': Basque FastText embeddings

For example, to load German FastText embeddings, use 'de' as the embeddings parameter.

Usage

flair_embeddings.WordEmbeddings(embeddings = "glove")

Arguments

embeddings

The type of pre-trained embeddings to use. Defaults to "glove".

Value

A Flair WordEmbeddings class.

References

Python equivalent:


from flair.embeddings import WordEmbeddings
embedding = WordEmbeddings('glove')

Examples

if (FALSE) { # \dontrun{
embedding <- flair_embeddings.WordEmbeddings("glove")
} # }