Advertisement
Guest User

Untitled

a guest
Nov 8th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. def build_ngram_counts(words,n):
  2. d={}
  3. for i in range(len(words)-n):
  4. key=[]
  5. for j in range(n)
  6. :
  7. key.append(words[i+j])
  8. temp_list=[[],[]]
  9. for each_word in words:
  10. if each_word==key[-1]:
  11. index=find_index(words,each_word)
  12. temp_list[0]=[words[u] for u in index]
  13. counter=0
  14. while counter<0:
  15.  
  16.  
  17.  
  18. #find the number of appearances STILL
  19.  
  20.  
  21. d[tuple(key)]=temp_list
  22. print(d)
  23. def find_index(array,word_of_good): #used for function 3 build_n_gram
  24. index=[]
  25. for x in range(len(array)):
  26. if word_of_good==array[x]:
  27. index.append(x+1)
  28. return index
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement