Skip to content
Advertisement

How to map list of string to existing list of integer?

I have this string vocab file: https://drive.google.com/file/d/1mL461QGC5KcA3M1r8AESaPjZ3D_ufgPA/view?usp=sharing.

I have this sentences file, made from all vocab file above: https://drive.google.com/file/d/1w5ma4ROjyp6xmZfvnIQjsdH2I_K7lHoo/view?usp=sharing.

I want to map every sentences into its corresponding integer in the vocab file.

What I have tried to di is, firsti, I put all sentence into a list to this DataFrame:

JavaScript

I have converted the vocabulary list (from vocab file) into list of integer

JavaScript

What I want to do is to put the encoded string into the DataFrame above. How can I do it? Example:

JavaScript

Advertisement

Answer

IIUC:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement