Skip to content

Instantly share code, notes, and snippets.

@irdanish11
Created October 16, 2019 08:27
Show Gist options
  • Select an option

  • Save irdanish11/94391ffd230b42752fa8b00818594790 to your computer and use it in GitHub Desktop.

Select an option

Save irdanish11/94391ffd230b42752fa8b00818594790 to your computer and use it in GitHub Desktop.
Converting the whole text into text sequences of four words and after that we count all the unique words and also count how many times a single word appeared in the corpus.
train_len = 3+1
text_sequences = []
for i in range(train_len,len(tokens)):
seq = tokens[i-train_len:i]
text_sequences.append(seq)
sequences = {}
count = 1
for i in range(len(tokens)):
if tokens[i] not in sequences:
sequences[tokens[i]] = count
count += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment