text_plain_output_1.png
from tensorflow.keras.preprocessing.text import Tokenizer

import json

import numpy as np

dataset = []
for line in open('/kaggle/input/news-headlines-dataset-for-sarcasm-detection/Sarcasm_Headlines_Dataset.json', 'r'):
    dataset.append(json.loads(line))
    json.load

article_link = []
headline = []
is_sarcastic = []

for item in dataset:
    article_link.append(item['article_link'])
    headline.append(item['headline'])
    is_sarcastic.append(item['is_sarcastic'])

data_len = len(headline)
train_size = round(data_len * 80 / 100)

train_headline = headline[0:train_size]
test_headline = headline[train_size:]
train_result = is_sarcastic[0:train_size]
test_result = is_sarcastic[train_size:]

token2 = Tokenizer(oov_token='<OOV>')

token2.fit_on_texts(train_headline)
word_index_2 = token2.word_index
train_seq = token2.texts_to_sequences(train_headline)
train_pad = pd(train_seq)
test_seq = token2.texts_to_sequences(test_headline)
test_pad = pd(test_seq)

train_pad = np.array(train_pad)
train_result = np.array(train_result)
test_pad = np.array(test_pad)
test_result = np.array(test_result)

type(train_pad)