FaisalAlsalm
FaisalAlsalm

Reputation: 109

texts_to_sequences() missing 1 required positional argument: 'texts'

i have a array of comments with shape ((8084,)) (UTF-8) when i ran this cod i got error

from keras.preprocessing.text import Tokenizer
X = Tokenizer.texts_to_sequences(data['comment_text'].values)

the error is TypeError: texts_to_sequences() missing 1 required positional argument: 'texts'

Upvotes: 2

Views: 7431

Answers (1)

Mohammad Jafar Mashhadi
Mohammad Jafar Mashhadi

Reputation: 4251

texts_to_sequence is not a class method, that's not the way to call it. Check out the docs for an example.

You should first create a Tokenizer object and fit it, then you can call texts_to_sequence.

from keras.preprocessing.text import Tokenizer
texts = data['comment_text'].values
tokenizer = Tokenizer()
tokenizer.fit_on_texts(texts)
X = tokenizer.texts_to_sequences(texts)

Upvotes: 4

Related Questions