Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. from collections import defaultdict
  2. import re
  3. import numpy as np
  4.  
  5. c=0
  6.  
  7. f = open('/Users/Half_Pint_Boy/Desktop/sentenses.txt', 'r')
  8.  
  9. for line in f:
  10. c = c + 1
  11.  
  12. word_positions = {}
  13.  
  14. with open('/Users/Half_Pint_Boy/Desktop/sentenses.txt', 'r') as f:
  15. index = 0
  16. for word in re.findall(r'[a-z]+', f.read().lower()):
  17. if word not in word_positions:
  18. word_positions[word] = index
  19. index += 1
  20. print(word_positions)
  21.  
  22. matrix=np.zeros(c,index)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement