blob: 6ccb64a32d4deb8fb1bb18c47b2964e25e23ade2 [file] [log] [blame]
daza972aabc2020-09-01 16:41:30 +02001# TODO: write a client to make multiple requests to the server!
2import subprocess, json, time
3import requests, glob, logging
4import os.path, sys
5from CoNLL_Annotation import CoNLL09_Token
6from my_utils import *
7
8
9TIGER_CORPUS = "/home/daza/datasets/TIGER_conll/tiger_release_aug07.corrected.16012013.conll09"
10
11
12if __name__ == "__main__":
13 file_has_next, chunk_ix = True, 0
14 CHUNK_SIZE = 10000
15
16 # =====================================================================================
17 # LOGGING INFO ...
18 # =====================================================================================
19 logger = logging.getLogger(__name__)
20 console_hdlr = logging.StreamHandler(sys.stdout)
21 file_hdlr = logging.FileHandler(filename=f"ParseTests.log")
22 logging.basicConfig(level=logging.INFO, handlers=[console_hdlr, file_hdlr])
23 logger.info(f"Chunking TIGER Corpus in chunks of {CHUNK_SIZE} Sentences")
24
25 # =====================================================================================
26 # PROCESS (PARSE) TIGER Corpus ...
27 # =====================================================================================
28 start = time.time()
29 total_processed_sents = 0
30 line_generator = file_generator(TIGER_CORPUS)
31 while file_has_next:
32 raw_text, file_has_next, n_sents = get_file_chunk(line_generator, chunk_size=CHUNK_SIZE, token_class=CoNLL09_Token)
33 total_processed_sents += n_sents
34 if len(raw_text) > 0:
35 turku_parse_file(raw_text, TIGER_CORPUS, chunk_ix)
36 now = time.time()
37 elapsed = (now - start)
38 logger.info(f"Time Elapsed: {elapsed}. Processed {total_processed_sents}. [{total_processed_sents/elapsed} Sents/sec]\n") # Toks/Sec???
39 chunk_ix += 1
40 if chunk_ix == 10: break
41 end = time.time()
42 logger.info(f"Processing File {TIGER_CORPUS} took {(end - start)} seconds!")
43
44