Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def build_ngram_counts(words,n):
- d={}
- for i in range(len(words)-n):
- key=[]
- for j in range(n)
- :
- key.append(words[i+j])
- temp_list=[[],[]]
- for each_word in words:
- if each_word==key[-1]:
- index=find_index(words,each_word)
- temp_list[0]=[words[u] for u in index]
- counter=0
- while counter<0:
- #find the number of appearances STILL
- d[tuple(key)]=temp_list
- print(d)
- def find_index(array,word_of_good): #used for function 3 build_n_gram
- index=[]
- for x in range(len(array)):
- if word_of_good==array[x]:
- index.append(x+1)
- return index
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement