It seems you are swapping variables and strings.
news is a variable
'news' is a string
Try this:
def lexical_diveristy (genre):
genre_text = brown.words(categories=genre)
genre_text_lower = [w.lower() for w in genre_text]
return len(genre_text_lower)/len(set(genre_text_lower))
lexical_diversity('news')
The function then binds the input string to the variable genre,
allowing it to be used in the function.
–
Kyle Marek-Spartz
University of Minnesota – Twin Cities: Linguistics Undergraduate
Computer Science Teaching Assistant
Amateur Radio Callsign – KDØGTK
kyle.mar...@gmail.com
mare...@umn.edu