Title: Python Gensim Dictionary
Tags: python;gensim
Question: This is my input (sample*)
data = ["['human', 'interface', 'computer']",
"['survey', 'user', 'computer', 'system', 'response', 'time']",
"['eps', 'user', 'interface', 'system']",
"['system', 'human', 'system', 'eps']",
"['user', 'response', 'time']",
"['trees']"]
And I have tried implementing
dictionary = corpora.Dictionary(text_data)
But this is the error I get,
TypeError: doc2bow expects an array of unicode tokens on input, not a single string
Please help if you see why that wouldn't work


Here is another answer: This error means that each "sentence" fed into doc2bow is expected to be an array of strings ("tokens"), whereas you are providing each "sentence" as a string:
# Your input sentences:
data = [
"['human', 'interface', 'computer']",
"['survey', 'user', 'computer', 'system', 'response', 'time']",
"['eps', 'user', 'interface', 'system']",
"['system', 'human', 'system', 'eps']",
"['user', 'response', 'time']",
"['trees']"]
# Expected input sentences:
data = [
['human', 'interface', 'computer'],
['survey', 'user', 'computer', 'system', 'response', 'time'],
['eps', 'user', 'interface', 'system'],
['system', 'human', 'system', 'eps'],
['user', 'response', 'time'],
['trees']]

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:03/17/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><gensim>', 'Title': 'Python Gensim Dictionary', 'ViewCount': 64, 'id': 60729841, 'user_AboutMe': None, 'user_AccountId': 17995584.0, 'user_DisplayName': 'seraphine', 'user_Reputation': 1.0, 'user_Views': 0.0, 'user_id': 13078688.0}}