Created
March 6, 2025 22:15
-
-
Save nithyadurai87/5d5835844dddcc01b468d3fa6d473d97 to your computer and use it in GitHub Desktop.
03_dense_vector.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.preprocessing import LabelEncoder | |
import numpy as np | |
paragraph = "Periyar was a social reformer in Tamil Nadu. He founded the Self-Respect Movement. This movement aimed to promote equality and end caste discrimination. Today, he is celebrated as a key figure in the fight for social justice and equality in Tamil Nadu." | |
x = [i for i in paragraph.split('.')] | |
l1 = [] | |
for i in x: | |
l1.append(LabelEncoder().fit_transform(i.split())) | |
padded_arrays = [np.pad(i, (0, max(len(i) for i in l1) - len(i)), 'constant', constant_values=99) for i in l1] | |
print(np.array(padded_arrays)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment