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 keras.preprocessing.text import Tokenizer | |
from numpy import array | |
from numpy import argmax | |
from keras.utils import to_categorical | |
doc = "Can I eat the Pizza".lower().split() | |
def using_Tokenizer(doc): | |
# create the tokenizer |
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 numpy import array | |
from numpy import argmax | |
from sklearn.preprocessing import LabelEncoder | |
from sklearn.preprocessing import OneHotEncoder | |
# define example | |
# data = ['cold', 'cold', 'warm', 'cold', 'hot', 'hot', 'warm', 'cold', 'warm', 'hot'] | |
doc1 = "Can I eat the Pizza".lower() | |
doc2 = "You can eat the Pizza".lower() |
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
import numpy as np | |
docs = "Can I eat the Pizza".lower().split() | |
doc1 = set(docs) | |
doc1 = sorted(doc1) | |
print ("\nvalues: ", doc1) | |
integer_encoded = [] | |
for i in docs: | |
v = np.where( np.array(doc1) == i)[0][0] | |
integer_encoded.append(v) |
NewerOlder