rain1024 commited on
Commit
ad00e52
1 Parent(s): 7cf0f1d
Files changed (1) hide show
  1. UTS_WTK_v1.py +17 -4
UTS_WTK_v1.py CHANGED
@@ -50,7 +50,20 @@ class UTS_WTK_v1(datasets.GeneratorBasedBuilder):
50
  with open(filepath, encoding="utf-8") as f:
51
  guid = 0
52
  for line in f:
53
- text = line.strip()
54
- datarow = {"tokens": [], "tags": []}
55
- yield guid, datarow
56
- guid += 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  with open(filepath, encoding="utf-8") as f:
51
  guid = 0
52
  for line in f:
53
+ tokens = []
54
+ tags = []
55
+ if line.startswith("-DOCSTART-") or line == "" or line == "\n":
56
+ if tokens:
57
+ yield guid, {
58
+ "id": str(guid),
59
+ "tokens": tokens,
60
+ "pos_tags": tags
61
+ }
62
+ guid += 1
63
+ tokens = []
64
+ tags = []
65
+ else:
66
+ # each line is tab separated
67
+ splits = line.split("\t")
68
+ tokens.append(splits[0])
69
+ tags.append(splits[1])