6.创建n-gram的滑动窗口的方法在下面两种极端情况下是否正确:n=1,n=len(sent)?
正确
sent=['the','dog','gave','john','the','newspaper']
n=3
[sent[i:i+n] for i in range(len(sent)-n+1)]
a.使用split()和join()
s='this is an apple tree'
s_words=s.split()
s1=' '.join(s_words)
b.使用正则表达式替换
' ([\s]+' '+[\s]+' ') '