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 tensorflow.keras.preprocessing.text import Tokenizer | |
from tensorflow.keras.preprocessing.sequence import pad_sequences | |
#Let's add custom sentences | |
sentences = [ | |
"Apples are red", | |
"Apples are round", | |
"Oranges are round", | |
'Grapes are sour, oranges are sweet' | |
] |
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 tensorflow.keras.preprocessing.text import Tokenizer | |
#Let's add custom sentences | |
sentences = [ | |
"Apples are red", | |
"Apples are round", | |
"Oranges are round", | |
"Grapes are green" | |
] |
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
# Unseen Words | |
test_data = [ | |
'Grapes are sour but oranges are sweet', | |
] | |
test_seq = myTokenizer.texts_to_sequences(test_data) | |
print("\nTest Sequence = ", test_seq, " => ", [x for x in myTokenizer.sequences_to_texts_generator(test_seq)]) |
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 tensorflow.keras.preprocessing.text import Tokenizer | |
#Let's add custom sentences | |
sentences = [ | |
"Apples are red", | |
"Apples are round", | |
"Oranges are round", | |
"Grapes are green" | |
] |
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 tensorflow.keras.preprocessing.text import Tokenizer | |
#Let's add custom sentences | |
sentences = [ | |
"One plus one is two!", | |
"Two plus two is four!" | |
] | |
for num_w in range(1,7): | |
myTokenizer = Tokenizer(num_words=num_w) |
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 tensorflow.keras.preprocessing.text import Tokenizer | |
#Let's add custom sentences | |
sentences = [ | |
"One plus one is two!", | |
"Two plus two is four!" | |
] | |
#most frequent words | |
for num_w in range(1,8): |
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 tensorflow.keras.preprocessing.text import Tokenizer | |
#Let's add custom sentences | |
sentences = [ | |
"One plus one is two!", | |
"Two plus two is four!" | |
] | |
#Tokenize the sentences | |
myTokenizer = Tokenizer(num_words=10) |
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
//Create set from an array | |
var set1 = new Set([1, 2, 2, 3, 3, 3, 4, 4, 4, 4]); | |
console.log(set1); | |
//Add a new element to it | |
set1.add(5); | |
console.log(set1); |
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
//Default parameter z | |
var sum = function (x, y, z = 10) { | |
return x + y + z; | |
}; | |
console.log(`Sum = ${sum(10, 20)}`); | |
console.log(`Sum = ${sum(10, 20, 5)}`); |
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
//The old way of writing functions | |
var addf = function add(x, y) { | |
var sum = x + y; | |
return sum; | |
}; | |
console.log(`The sum is : ${addf(10, 20)}`); | |
//The new way of writing functions | |
var newAdd = (x, y) => x + y; | |
console.log(`The sum is : ${newAdd(10, 20)}`); |
NewerOlder