def extract_user_keywords_generator(twitter_lists_gen, lemmatizing="wordnet"):
    """
    Based on the user-related lists I have downloaded, annotate the users.

    Inputs: - twitter_lists_gen: A python generator that yields a user Twitter id and a generator of Twitter lists.
            - lemmatizing: A string containing one of the following: "porter", "snowball" or "wordnet".

    Yields: - user_twitter_id: A Twitter user id.
            - user_annotation: A python dictionary that contains two dicts:
                * bag_of_lemmas: Maps emmas to multiplicity.
                * lemma_to_keywordbag: A python dictionary that maps stems/lemmas to original topic keywords.
    """
    ####################################################################################################################
    # Extract keywords serially.
    ####################################################################################################################
    for user_twitter_id, twitter_lists_list in twitter_lists_gen:
        if twitter_lists_list is not None:
            if "lists" in twitter_lists_list.keys():
                twitter_lists_list = twitter_lists_list["lists"]

            bag_of_lemmas, lemma_to_keywordbag = user_twitter_list_bag_of_words(twitter_lists_list, lemmatizing)

            for lemma, keywordbag in lemma_to_keywordbag.items():
                lemma_to_keywordbag[lemma] = dict(keywordbag)
            lemma_to_keywordbag = dict(lemma_to_keywordbag)

            user_annotation = dict()
            user_annotation["bag_of_lemmas"] = bag_of_lemmas
            user_annotation["lemma_to_keywordbag"] = lemma_to_keywordbag

            yield user_twitter_id, user_annotation
def extract_user_keywords_generator ( twitter_lists_gen , lemmatizing = "wordnet" ) : for user_twitter_id , twitter_lists_list in twitter_lists_gen : if twitter_lists_list is not None : if "lists" in twitter_lists_list . keys ( ) : twitter_lists_list = twitter_lists_list [ "lists" ] bag_of_lemmas , lemma_to_keywordbag = user_twitter_list_bag_of_words ( twitter_lists_list , lemmatizing ) for lemma , keywordbag in lemma_to_keywordbag . items ( ) : lemma_to_keywordbag [ lemma ] = dict ( keywordbag ) lemma_to_keywordbag = dict ( lemma_to_keywordbag ) user_annotation = dict ( ) user_annotation [ "bag_of_lemmas" ] = bag_of_lemmas user_annotation [ "lemma_to_keywordbag" ] = lemma_to_keywordbag yield user_twitter_id , user_annotation
Based on the user-related lists I have downloaded, annotate the users.

    Inputs: - twitter_lists_gen: A python generator that yields a user Twitter id and a generator of Twitter lists.
            - lemmatizing: A string containing one of the following: "porter", "snowball" or "wordnet".

    Yields: - user_twitter_id: A Twitter user id.
            - user_annotation: A python dictionary that contains two dicts:
                * bag_of_lemmas: Maps emmas to multiplicity.
                * lemma_to_keywordbag: A python dictionary that maps stems/lemmas to original topic keywords.