mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nlp.git
synced 2025-01-13 13:10:34 +00:00
31 lines
975 B
Python
Executable File
31 lines
975 B
Python
Executable File
#!/usr/bin/env python3.7
|
|
# coding=utf-8
|
|
|
|
from argparse import ArgumentParser
|
|
from stand_off_data import StandOffData
|
|
import hashlib
|
|
import json
|
|
|
|
|
|
def main():
|
|
# Parse the given arguments
|
|
parser = ArgumentParser(description='Create a vrt from JSON and txt')
|
|
parser.add_argument('text', help='Path to txt file')
|
|
parser.add_argument('stand_off_data', help='Path to JSON file')
|
|
parser.add_argument('output', help='Path to vrt output file')
|
|
args = parser.parse_args()
|
|
|
|
with open(args.stand_off_data) as stand_of_data_file:
|
|
stand_off_data = StandOffData(json.load(stand_of_data_file))
|
|
|
|
with open(args.text, "rb") as text_file:
|
|
text_md5 = hashlib.md5()
|
|
for chunk in iter(lambda: text_file.read(128 * text_md5.block_size), b''): # noqa
|
|
text_md5.update(chunk)
|
|
if text_md5.hexdigest() != stand_off_data.meta['file']['md5']:
|
|
raise Exception('md5 not equal')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|