I am working with a very big file in python. I need to check whether a particular bigram is present in that file. I have written the code. It gives the correct output but is too slow. Is there any other alternative ?
def check(word1, word2):
with open("D:\bigram.txt", 'r') as file:
#bigram_list2=[]
for line in file:
phrase=word1 + " " + word2
if phrase in line:
return 1
return -1