Issue
Change my dictionary, this is the initial code:
bow=[[i for i in all_docs[j] if i not in stopwords] for j in range(n_docs)]
bow=list(filter(None,bow))
bow
Here is bow output:
[['lunar',
'satellite',
'needs'],
['glad',
'see',
'griffin'] ]
worddict_two = [ (i,key) for i,key in enumerate(bow)]
worddict_two
From this output :
[(0,
['lunar',
'satellite',
'needs']),
(1,
['glad',
'see',
'griffin'])
to this output:
[(0,'lunar satellite needs'),
(1,'glad see griffin') ) ]
Solution
worddict_two = [ (i, " ".join(key)) for i,key in enumerate(bow)]
This would work. Use join to Join all items in a tuple into a string with space space as a separator
Answered By - Utsav Patel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.