Giter VIP home page Giter VIP logo

shreyanshchordia / wordembedder Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 19 KB

Use this repository to effectively use word embeddings for your next NLP Project!

License: MIT License

Python 40.78% Jupyter Notebook 59.22%
natural-language-processing nlp glove-embeddings word-emeddings embedding-layer-keras embedding-matrix embeddings-word2vec neural-networks cosine-similarity open-source

wordembedder's Introduction

WordEmbedder

Importing the WordEmbedder can simplify a lot of necessary preprocessing tasks that need to be done when working on NLP Projects.

Tasks like:

  1. Getting embeddings of words in the dataset

  2. Generating vocabulary for your tokenized sentences

  3. Converting tokenized sentences in number sequences

  4. Retrieving the tokenized sentences back from the number sequences

  5. Generate an embedding matrix for the vocabulary that is demanded by the Embedding Layer from tensorflow.keras.layers as the weights parameter when using pre-trained embeddings.

consume a lot of our time and lines of code.

All these tasks can individually be done in a single line of code by importing the WordEmbedder script.

Other than the above mentioned tasks there are few other features that the script provides as well:

  1. Getting K most similar words to a given word
  2. Getting K top words that satisfy an analogy
  3. Getting cosine similarity between two words
  4. Getting the cosine similarity score for a 4-word analogy

How To Use The WordEmbedder

The notebook how_to_use_WordEmbedder.ipynb in the repository specifies all the details on how to use the WordEmbedder.

Sample Code

#### Initiating an object of Embedder class
emb = Embedder(dimensions=50) # dimensions can be 50, 100, 200 or 300 # This line take a while to execute when run for the first time because the embeddings are downloaded

#### This embedder maps words to their embeddings

embedder = emb.get_embedder()
print(embedder['beautiful']) 

#### Generating Vocabulary
vocab, vocab_dict = generate_vocabulary(tokenized_sentences) # To generate vocabulary for the tokenized sentences

#### Generating the embedding_matrix
embedding_matrix, id2token, token2id = emb.get_embedding_matrix(vocab, num_words=10)

#### Generating number sequences from tokenized sentences
num_sequences = token_seq_to_num_seq(tokenized_sentences, token2id, oov_token='<oov>')

#### Retrieving  tokenized sentences from number sequences
retrieved_tokenized_sequences = num_seq_to_token_seq(num_sequences, id2token)

Refer how_to_use_WordEmbedder.ipynb for the other features.

Open to contributions! :)

wordembedder's People

Contributors

shreyanshchordia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.