def position_of_ngram(ngram, sentence):
 for (i, sublist) in enumerate(ngrams(sentence, len(ngram))):
  if (ngram == sublist):
   return i

def position_of_ngram ( ngram , sentence ) : for ( i , sublist ) in enumerate ( ngrams ( sentence , len ( ngram ) ) ) : if ( ngram == sublist ) : return i
this function returns the position of the first instance of the ngram appearing in a sentence .