Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_co_occurrences(data):
- com = defaultdict(dict)
- for temp in data:
- for i in range(len(city_list)-1):
- for j in range(i+1, len(city_list)):
- w1, w2 = city_list[i], city_list[j]
- if " " + w1 + " " in temp and " " + w2 + " " in temp:
- print(w1,w2)
- if com[w1].get(w2) is None:
- com[w1][w2] = 1
- else:
- com[w1][w2] += 1
- return com
Add Comment
Please, Sign In to add comment