<jupyter_start><jupyter_text><jupyter_code># mount drive
from google.colab import drive
drive.mount('/drive',force_remount=True)
from tensorflow.keras.preprocessing.text import one_hot
### sentences
sent=[  'the glass of milk',
     'the glass of juice',
     'the cup of tea',
    'I am a good boy',
     'I am a good developer',
     'understand the meaning of words',
     'your videos are good',]
sent
### Vocabulary size
voc_size=10000<jupyter_output><empty_output><jupyter_text>One Hot Representation<jupyter_code>onehot_repr=[one_hot(words,voc_size)for words in sent] 
print(onehot_repr)<jupyter_output>[[8350, 4173, 2286, 7438], [8350, 4173, 2286, 1747], [8350, 1785, 2286, 5440], [8603, 8189, 7598, 2484, 518], [8603, 8189, 7598, 2484, 9179], [3614, 8350, 4073, 2286, 3130], [1963, 6215, 291, 2484]]<jupyter_text>Word Embedding Representation<jupyter_code>from tensorflow.keras.layers import Embedding
from tensorflow.keras.preprocessing.sequence import pad_sequences
from tensorflow.keras.models import Sequential
import numpy as np
sent_length=8
embedded_docs=pad_sequences(onehot_repr,padding='pre',maxlen=sent_length)
print(embedded_docs)
dim=10
model=Sequential()
model.add(Embedding(voc_size,10,input_length=sent_length))
model.compile('adam','mse')
model.summary()
print(model.predict(embedded_docs))
embedded_docs[0]
print(model.predict(embedded_docs)[0])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12696148359486448, 'fraction_numerical': 0.09557774607703282, 'mean_word_length': 7.554878048780488, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '211773', 'license': 'MIT', 'n_tokens_mistral': 612, 'n_tokens_neox': 507, 'n_words': 113, 'path': 'word_embedding.ipynb', 'repo_name': 'deep1185/ga-learner-dsmp-repo', 'size': '1402'}