Created
October 16, 2019 08:27
-
-
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.
This file contains hidden or 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
| 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