Guest User

Untitled

a guest
Jan 17th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. from sklearn.feature_extraction.text import CountVectorizer
  2.  
  3. keys_1 = ['funny', 'amusing', 'humorous', 'hilarious', 'jolly']
  4. keys_2 = ['horror', 'fear', 'shock', 'panic', 'scream']
  5. keys_3 = ['romantic', 'intimate', 'passionate', 'love', 'fond']
  6.  
  7. text = ('funny amusing fear passionate')
  8.  
  9. for i in range(3):
  10. keys = 'keys_' + str(i+1)
  11. cv = CountVectorizer(vocabulary = keys)
  12. data = cv.fit_transform([text]).toarray()
  13. print(data)
  14.  
  15. cv1 = CountVectorizer(vocabulary = keys_1)
  16. data = cv1.fit_transform([text]).toarray()
  17. print(data)
  18.  
  19. cv2 = CountVectorizer(vocabulary = keys_2)
  20. data = cv2.fit_transform([text]).toarray()
  21. print(data)
  22.  
  23. cv3 = CountVectorizer(vocabulary = keys_3)
  24. data = cv3.fit_transform([text]).toarray()
  25. print(data)
Add Comment
Please, Sign In to add comment