def analyze_text(spacy_doc):
    """Lemmatize, get word frequencies and part-of-speech tags

    Parameters:
    spacy_doc (spacy nlp object): output from spacy_analyze

    Returns:
    dictionary: {'lemma': {'orig': list, 'pos': string, 'count': int}}
    """
    worddict = {}
    for word in spacy_doc:
        key = word.lemma_.lower()
        # filter out non-alphabetic words
        if word.is_alpha:
            # store word counts and tokens
            if key in worddict:
                orig = worddict[key].get('orig')
                if key == word.text.lower():
                    worddict[key]['count'] += 1
                elif orig:
                    if word.text.lower() not in orig:
                        worddict[key]['orig'].append(word.text.lower())
                        worddict[key]['count'] += 1
                    else:
                        worddict[key]['count'] += 1
                else:
                    worddict[key]['orig'] = [word.text.lower()]
                    worddict[key]['count'] += 1
            elif key == word.text.lower():
                worddict[key] = {'pos': word.pos_, 'count': 1}
            else:
                worddict[key] = {
                    'orig': [word.text.lower()],
                    'pos': word.pos_,
                    'count': 1
                }

    return worddict