Last active
August 7, 2021 16:13
-
-
Save Yuktha-Majella/a91725a89df8f29663489462ae50de3a to your computer and use it in GitHub Desktop.
Creating Bigrams and Trigrams in Gensim
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
import gensim.downloader as api | |
from gensim.models.phrases import Phrases | |
dataset = api.load("text8") | |
tokens = [word for word in dataset] | |
bigram_model = Phrases(tokens, min_count = 3, threshold = 10) | |
print(bigram_model[tokens[0]]) | |
trigram_model = Phrases(bigram_model[data], threshold = 10) | |
print(trigram_model[bigram_model[data[0]]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment