(model, sgm_path)
| 67 | |
| 68 | |
| 69 | def 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 | |
| 85 | def parse_xml(xml_path): |