代码拉取完成,页面将自动刷新
#! usr/bin/env python3
# -*- coding:utf-8 -*-
"""
@Author:zhoukaiyin
"""
def _read_data(input_file):
"""Read a BIO data!"""
rf = open(input_file, 'r')
lines = []; words = []; labels = []
for line in rf:
word = line.strip().split(' ')[0]
label = line.strip().split(' ')[-1]
# here we dont do "DOCSTART" check
if len(line.strip()) == 0 and words[-1] == '.':
l = ' '.join([label for label in labels if len(label) > 0])
w = ' '.join([word for word in words if len(word) > 0])
lines.append((l, w))
words = []
labels = []
words.append(word)
labels.append(label)
return lines
def main():
lines = _read_data("./data/train.txt")
print(lines)
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。