求帮忙!万分感谢!
中文分词模型代码报错:
sen_tags.append(data[1])
IndexError: list index out of range
报错的部分代码如下:
```python
def get_sens_tags(file):
with open(file, 'r', encoding='utf8') as f:
#with open('data/zhongyi.txt', 'r', encoding='utf8') as f:
sens_tags = []
sen_words = []
sen_tags = []
n_sens = 0
#for line in f:
for line in f.readlines():
if not line.strip(): continue
line = line.strip("\n")
if line:
data = line.split("\t")
sen_words.append(data[0])
sen_tags.append(data[1])
elif sen_words:
n_sens += 1
sens_tags.append((sen_words,sen_tags))
sen_words = []
sen_tags = []
print('句子数量:%s' % n_sens)
return sens_tags
```