utils4text.py
def find_speaker_frequent_words(df, num):
    """
    Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by speakers.

    Args:
        df: A specified dataframe from a subreddit.
        num: A ranking number used for finding the top frequent words.
             For example, if num = 5, then we'll find the top 5 frequent words.
    Return:
        result: A dataframe showing the top frequent words. 
    """
    # extract speakers' turn
    df_speaker = df[df['dialog turn'] == 1]

    # compute tokens
    df_speaker_filtered = compute_tokens(df_speaker)

    # find top (num) frequent words
    result = pd.DataFrame(Counter(df_speaker_filtered.sum()).most_common(num), columns = ["word", "count"])

    return result

    Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by speakers.

    Args:
        df: A specified dataframe from a subreddit.
        num: A ranking number used for finding the top frequent words.
             For example, if num = 5, then we'll find the top 5 frequent words.
    Return:
        result: A dataframe showing the top frequent words. 
    
Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by speakers.
Given a conversation dataframe from a certain subreddit find the top frequent words spoken by speakers .
def find_speaker_frequent_words(df, num):
    df_speaker = df[df['dialog turn'] == 1]
    df_speaker_filtered = compute_tokens(df_speaker)
    result = pd.DataFrame(Counter(df_speaker_filtered.sum()).most_common(num), columns = ["word", "count"])
    return result
def find_speaker_frequent_words ( df , num ) : df_speaker = df [ df [ 'dialog turn' ] == 1 ] df_speaker_filtered = compute_tokens ( df_speaker ) result = pd . DataFrame ( Counter ( df_speaker_filtered . sum ( ) ) . most_common ( num ) , columns = [ "word" , "count" ] ) return result
Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by speakers.
Given a conversation dataframe from a certain subreddit find the top frequent words spoken by speakers .
"""
    Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by speakers.

    Args:
        df: A specified dataframe from a subreddit.
        num: A ranking number used for finding the top frequent words.
             For example, if num = 5, then we'll find the top 5 frequent words.
    Return:
        result: A dataframe showing the top frequent words. 
    """ # extract speakers' turn # compute tokens # find top (num) frequent words
df
A specified dataframe from a subreddit.
A specified dataframe from a subreddit .
num
A ranking number used for finding the top frequent words.
For example, if num = 5, then we'll find the top 5 frequent words.
A ranking number used for finding the top frequent words . For example if num = 5 then we ' ll find the top 5 frequent words .