MCPcopy Create free account
hub / github.com/OpenBMB/DecT / load_data

Method load_data

src/process_data.py:344–370  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

342
343 @staticmethod
344 def load_data(file):
345 data = []
346 xs = []
347 ys = []
348 spans = []
349
350 for line in file.readlines():
351 pair = line.split()
352 if pair == []:
353 if xs != []:
354 data.append((xs, ys, spans))
355 xs = []
356 ys = []
357 spans = []
358 else:
359 xs.append(pair[0])
360
361 tag = pair[-1]
362 if tag != 'O':
363 if len(ys) == 0 or tag != ys[-1][2:]:
364 tag = 'B-' + tag
365 spans.append([len(ys), len(ys)])
366 else:
367 tag = 'I-' + tag
368 spans[-1][-1] = len(ys)
369 ys.append(tag)
370 return data
371
372PROCESSORS = {
373 "agnews": AgnewsProcessor,

Callers 1

get_examplesMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected