Question: 1. Find the most frequent bigrams (20 pts) Please complete the freq_bigram function to find the nn most frequent bigrams. Your function should return

1. Find the most frequent bigrams (20 pts) Please complete the freq_bigram 

 

 

function to find the nn most frequent bigrams. Your function should return 


1. Find the most frequent bigrams (20 pts) Please complete the freq_bigram function to find the nn most frequent bigrams. Your function should return a list of top_n tuples. Each of the tuples should contain a bigram tuple (such as ('.')) and its number of occurrence. def freq_bigrams(tweets, top_n): bigram_counter = Counter() for tweet in tweets: # YOUR CODE HERE return bigram_counter.most_common(top_n) 2. Find the most frequent skipgrams (20 pts) In this exercise we will compute another commonly defined type of sequential patterns -- the skip-grams. Luckily this is also supported by NLTK. You can find the documentation here. Please implement the freq_skipgrams function to calculate the most frequently used kk-skip-nn-grams. Your function should return a list of top_n tuples. Each of the tuples should contain a kk-skip-nn-gram tuple (such as (Happy', 'Birthday', '')) and its number of occurrences. def freq_skipgrams (tweets, n, k, top_n): skipgram_counter = Counter() # YOUR CODE HERE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

1 To complete the function freqbigrams you need to iterate through the provided list of tweets extract all the bigrams pairs of consecutive items and ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!