MCPcopy Create free account
hub / github.com/Clearailhc/ACE2005-toolkit / parse_sgm

Function parse_sgm

format.py:69–82  ·  view source on GitHub ↗
(model, sgm_path)

Source from the content-addressed store, hash-verified

67
68
69def parse_sgm(model, sgm_path):
70 sgm_file = os.path.join(args.data, '{}.sgm'.format(sgm_path))
71 with open(sgm_file, 'r') as f:
72 soup = BeautifulSoup(f.read(), features='html.parser')
73 sgm_text = soup.text
74
75 sentences = model.tokenize(sgm_text, 'ranges')
76 total_words = 0
77 for s in sentences:
78 total_words += len(s.words)
79 model.tag(s)
80 model.parse(s)
81 conllu = model.write(sentences, "conllu")
82 return conllu, len(sentences), total_words
83
84
85def parse_xml(xml_path):

Callers 1

process_dataFunction · 0.85

Calls 5

readMethod · 0.80
tokenizeMethod · 0.80
tagMethod · 0.80
parseMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected