Download parse_file.py from Icelandic-lt/biaffine_parser: direct link, hf CLI and curl.
- Browser
- Download file 609 Bytes
-
https://huggingface.co/Icelandic-lt/biaffine_parser/resolve/main/parse_file.py
- Command line
-
hf download hf://Icelandic-lt/biaffine_parser/parse_file.py
-
curl -L -o parse_file.py https://huggingface.co/Icelandic-lt/biaffine_parser/resolve/main/parse_file.py
609 Bytes
| from argparse import ArgumentParser | |
| from diaparser.parsers import Parser | |
| from Tokenizer.src.tokenizer import split_into_sentences | |
| parser = ArgumentParser() | |
| parser.add_argument('--parser') | |
| parser.add_argument('--infile') | |
| args = parser.parse_args() | |
| PARSER = Parser.load(args.parser) | |
| def read_test_file(file): | |
| with open(file, 'r', encoding='utf-8') as infile: | |
| for line in infile: | |
| yield [tok for tok in ' '.join(split_into_sentences(line)).split()] | |
| test_file = list(read_test_file(args.infile)) | |
| dataset = PARSER.predict(test_file, prob=True) | |
| for i in dataset.sentences: | |
| print(i) | |