It's quite easy to do n gram in python, for example:
def n_gram(list,n): return [ list[i:i+n] for i in range(len(list)-n+1) ]
and if you do :
str = "I really like python, it's pretty awesome."n_gram(str.split(" "),4)
You will get
[['I', 'really', 'like', 'python,'], ['really', 'like', 'python,', "it's"], ['like', 'python,', "it's", 'pretty'], ['python,', "it's", 'pretty', 'awesome.']]