diff --git a/api/client2.py b/api/client2.py index 3127e42..f5d51b2 100644 --- a/api/client2.py +++ b/api/client2.py @@ -2,6 +2,7 @@ import requests import json import os +import time import argparse from prettytable import PrettyTable @@ -25,11 +26,12 @@ def __init__(self, args): self.interactive = args.interactive def __process_query(self, query_file): + start_time = time.time()*1000 with open(query_file, 'r') as file: query = json.load(file) response = requests.post(self.URL, json=query) - - return query['description'], response.json() + end_time = time.time()*1000 + return query['description'], response.json(), (end_time - start_time) def __adjust_results(self, result): if result: @@ -68,7 +70,7 @@ def __graph_results(self, description, result): def run_specific(self, specific_query): # print(f"Processing {specific_query} ...") - description, result = self.__process_query(specific_query) + description, result, runtime = self.__process_query(specific_query) # print(f"Result for {specific_query}:") res=None @@ -80,20 +82,33 @@ def run_specific(self, specific_query): else: for res in result: res = self.__adjust_results(res) + print(f"Running time: {runtime} ms") + print() print(res) else: for res in result: + res = self.__adjust_results(res) + print(f"Running time {runtime} ms") + print() print(res) + + if self.target_dir: + with open(f"{self.target_dir}/{specific_query[:-5]}_result.txt", 'w') as file: + print(result, file=file) + print(file=file) + print(f"Running time {runtime} ms", file=file) + print(file=file) + print(self.__adjust_results(result), file=file) + print(file=file) print() - res = self.__adjust_results(res) - print(res) def run(self): for filename in os.listdir(self.QueryDir): + if filename.endswith(".json"): query_file = os.path.join(self.QueryDir, filename) print(f"Processing {query_file} ...") - description, results = self.__process_query(query_file) + description, results, runtime = self.__process_query(query_file) for result in results: if self.interactive: @@ -101,16 +116,20 @@ def run(self): if graph == 'Y': self.__graph_results(description, result) else: + print(f"Result for {query_file}:") print(self.__adjust_results(result)) else: + print(result) print(f"Result for {query_file}:") print(self.__adjust_results(result)) if self.target_dir: with open(f"{self.target_dir}{filename[:-5]}_result.txt", 'w') as file: print(result, file=file) print(file=file) + print(f"Running time {runtime} ms", file=file) + print(file=file) res = self.__adjust_results(result) print(str(res), file=file) diff --git a/test/API/examples/actual/average_named_entity_references_by_ANO_members_result.txt b/test/API/examples/actual/average_named_entity_references_by_ANO_members_result.txt index ddbbdab..ea0907b 100644 --- a/test/API/examples/actual/average_named_entity_references_by_ANO_members_result.txt +++ b/test/API/examples/actual/average_named_entity_references_by_ANO_members_result.txt @@ -1,5 +1,7 @@ [{'affiliation.person_id': 'AndrejBabis.1954', 'average_named_entity_references': 81.39669421487604}, {'affiliation.person_id': 'VeraJourova.1964', 'average_named_entity_references': 50.0}, {'affiliation.person_id': 'RichardBrabec.1966', 'average_named_entity_references': 36.2}, {'affiliation.person_id': 'JosefKott.1970', 'average_named_entity_references': 22.4390243902439}, {'affiliation.person_id': 'AdamVojtech.1986', 'average_named_entity_references': 21.5}, {'affiliation.person_id': 'KarelHavlicek.1969', 'average_named_entity_references': 18.666666666666668}, {'affiliation.person_id': 'DanTok.1959', 'average_named_entity_references': 16.333333333333332}, {'affiliation.person_id': 'RobertPelikan.1979', 'average_named_entity_references': 16.0}, {'affiliation.person_id': 'JanaMrackovaVildumetzova.1973', 'average_named_entity_references': 12.326923076923077}, {'affiliation.person_id': 'LubomirMetnar.1967', 'average_named_entity_references': 12.0}, {'affiliation.person_id': 'BronislavSchwarz.1966', 'average_named_entity_references': 12.0}, {'affiliation.person_id': 'MarekNovak.1976', 'average_named_entity_references': 12.0}, {'affiliation.person_id': 'KlaraDostalova.1971', 'average_named_entity_references': 11.068965517241379}, {'affiliation.person_id': 'PetrVrana.1975', 'average_named_entity_references': 11.0}, {'affiliation.person_id': 'AlenaSchillerova.1964', 'average_named_entity_references': 10.455696202531646}, {'affiliation.person_id': 'RadekVondracek.1973', 'average_named_entity_references': 10.06561203319502}, {'affiliation.person_id': 'JaroslavFaltynek.1962', 'average_named_entity_references': 7.722614840989399}, {'affiliation.person_id': 'ZdenekSoukup.1952', 'average_named_entity_references': 7.5}, {'affiliation.person_id': 'RomanKubicek.1963', 'average_named_entity_references': 7.4}, {'affiliation.person_id': 'BerenikaPestova.1971', 'average_named_entity_references': 7.333333333333333}, {'affiliation.person_id': 'MiloslavJanulik.1962', 'average_named_entity_references': 7.0}, {'affiliation.person_id': 'IvoVondrak.1959', 'average_named_entity_references': 6.5}, {'affiliation.person_id': 'JiriZlatuska.1957', 'average_named_entity_references': 6.5}, {'affiliation.person_id': 'JosefHajek.1956', 'average_named_entity_references': 6.0}, {'affiliation.person_id': 'JaroslavaPokornaJermanova.1970', 'average_named_entity_references': 5.787781350482315}, {'affiliation.person_id': 'JanaHanzlikova.1966', 'average_named_entity_references': 5.5}, {'affiliation.person_id': 'RobertKralicek.1977', 'average_named_entity_references': 5.0}, {'affiliation.person_id': 'MartinStropnicky.1956', 'average_named_entity_references': 4.1875}, {'affiliation.person_id': 'MartinKolovratnik.1975', 'average_named_entity_references': 3.57847533632287}, {'affiliation.person_id': 'MilanBrazdil.1962', 'average_named_entity_references': 3.3548387096774195}, {'affiliation.person_id': 'RomanaFischerova.1969', 'average_named_entity_references': 3.0}, {'affiliation.person_id': 'JaroslavBzoch.1983', 'average_named_entity_references': 3.0}, {'affiliation.person_id': 'JanVolny.1959', 'average_named_entity_references': 2.1560283687943262}, {'affiliation.person_id': 'JiriBlaha.1961', 'average_named_entity_references': 2.0}, {'affiliation.person_id': 'HelenaValkova.1951', 'average_named_entity_references': 1.3804347826086958}, {'affiliation.person_id': 'RadkaMaxova.1968', 'average_named_entity_references': 1.0}, {'affiliation.person_id': 'MatejFichtner.1984', 'average_named_entity_references': 0.5588235294117647}, {'affiliation.person_id': 'PatrikNacher.1974', 'average_named_entity_references': 0.5}, {'affiliation.person_id': 'OndrejBabka.1994', 'average_named_entity_references': 0.0}, {'affiliation.person_id': 'DavidKasal.1969', 'average_named_entity_references': 0.0}] +Running time 20.072021484375 ms + +--------------------------------+---------------------------------+ | affiliation.person_id | average_named_entity_references | +--------------------------------+---------------------------------+ diff --git a/test/API/examples/actual/average_sentences_most_talkative_result.txt b/test/API/examples/actual/average_sentences_most_talkative_result.txt index 765ef9a..96b8a02 100644 --- a/test/API/examples/actual/average_sentences_most_talkative_result.txt +++ b/test/API/examples/actual/average_sentences_most_talkative_result.txt @@ -1,5 +1,7 @@ [{'affiliation.role': 'member', 'average_sentence_count': 10.937954642704321}, {'affiliation.role': 'head', 'average_sentence_count': 11.042723631508679}, {'affiliation.role': 'deputyHead', 'average_sentence_count': 8.285714285714286}] +Running time 14.8916015625 ms + +------------------+------------------------+ | affiliation.role | average_sentence_count | +------------------+------------------------+ diff --git a/test/API/examples/actual/average_tokens_by_position_result.txt b/test/API/examples/actual/average_tokens_by_position_result.txt index 0f6ec07..6b73af8 100644 --- a/test/API/examples/actual/average_tokens_by_position_result.txt +++ b/test/API/examples/actual/average_tokens_by_position_result.txt @@ -1,5 +1,7 @@ [{'speech.role': 'guest', 'average_tokens': 1077.8934426229507}, {'speech.role': 'regular', 'average_tokens': 496.90713671539123}, {'speech.role': 'chair', 'average_tokens': 143.19426456984274}] +Running time 7.8427734375 ms + +-------------+--------------------+ | speech.role | average_tokens | +-------------+--------------------+ diff --git a/test/API/examples/actual/average_words_per_minute_of_fastest_speaker_depending_on_time_result.txt b/test/API/examples/actual/average_words_per_minute_of_fastest_speaker_depending_on_time_result.txt index 44df0ce..4c3c237 100644 --- a/test/API/examples/actual/average_words_per_minute_of_fastest_speaker_depending_on_time_result.txt +++ b/test/API/examples/actual/average_words_per_minute_of_fastest_speaker_depending_on_time_result.txt @@ -1,5 +1,7 @@ [{'speech.earliest_timestamp': '12:48:00', 'average_wpm': 161.34031413612567}] +Running time 9.771728515625 ms + +---------------------------+--------------------+ | speech.earliest_timestamp | average_wpm | +---------------------------+--------------------+ diff --git a/test/API/examples/actual/fastest_speaking_speakers_result.txt b/test/API/examples/actual/fastest_speaking_speakers_result.txt index ef4348c..4f9554d 100644 --- a/test/API/examples/actual/fastest_speaking_speakers_result.txt +++ b/test/API/examples/actual/fastest_speaking_speakers_result.txt @@ -1,5 +1,7 @@ [{'speech.person_id': 'BronislavSchwarz.1966', 'average_wpm': 161.34031413612567}, {'speech.person_id': 'LukasKolarik.1984', 'average_wpm': 155.80850204389782}, {'speech.person_id': 'OndrejVesely.1976', 'average_wpm': 151.81583647549118}, {'speech.person_id': 'PavelBlazek.1969', 'average_wpm': 149.77964855666076}, {'speech.person_id': 'MilanChovanec.1970', 'average_wpm': 149.25437760129654}, {'speech.person_id': 'MarianJurecka.1981', 'average_wpm': 147.04994388205515}, {'speech.person_id': 'RobertPlaga.1978', 'average_wpm': 145.44581783271332}, {'speech.person_id': 'MarcelChladek', 'average_wpm': 145.00501169395255}, {'speech.person_id': 'MiloslavJanulik.1962', 'average_wpm': 143.10080192959902}, {'speech.person_id': 'MartinKolovratnik.1975', 'average_wpm': 142.27168366868392}] +Running time 8.635498046875 ms + +------------------------+--------------------+ | speech.person_id | average_wpm | +------------------------+--------------------+ diff --git a/test/API/examples/actual/gender_average_tokens_result.txt b/test/API/examples/actual/gender_average_tokens_result.txt index a4a854d..2e7287a 100644 --- a/test/API/examples/actual/gender_average_tokens_result.txt +++ b/test/API/examples/actual/gender_average_tokens_result.txt @@ -1,5 +1,7 @@ [{'person.sex': '', 'average_tokens': 1335.3333333333333}, {'person.sex': 'M', 'average_tokens': 325.23359818388195}, {'person.sex': 'F', 'average_tokens': 245.54014029618082}] +Running time 5.929931640625 ms + +------------+--------------------+ | person.sex | average_tokens | +------------+--------------------+ diff --git a/test/API/examples/actual/gender_total_speeches_result.txt b/test/API/examples/actual/gender_total_speeches_result.txt index 1e68170..7322b55 100644 --- a/test/API/examples/actual/gender_total_speeches_result.txt +++ b/test/API/examples/actual/gender_total_speeches_result.txt @@ -1,5 +1,7 @@ [{'person.sex': '', 'total_speeches': 3}, {'person.sex': 'M', 'total_speeches': 4405}, {'person.sex': 'F', 'total_speeches': 1283}] +Running time 5.25048828125 ms + +------------+----------------+ | person.sex | total_speeches | +------------+----------------+ diff --git a/test/API/examples/actual/most_speeches_male_result.txt b/test/API/examples/actual/most_speeches_male_result.txt index a6160e6..a4ffd92 100644 --- a/test/API/examples/actual/most_speeches_male_result.txt +++ b/test/API/examples/actual/most_speeches_male_result.txt @@ -1,5 +1,7 @@ [{'person.person_id': 'RadekVondracek.1973', 'total_speeches': 769}, {'person.person_id': 'JanHamacek.1978', 'total_speeches': 587}, {'person.person_id': 'TomioOkamura.1972', 'total_speeches': 303}, {'person.person_id': 'JanBartosek.1971', 'total_speeches': 287}, {'person.person_id': 'VojtechFilip.1955', 'total_speeches': 262}, {'person.person_id': 'MiroslavKalousek.1960', 'total_speeches': 160}, {'person.person_id': 'ZbynekStanjura.1964', 'total_speeches': 127}, {'person.person_id': 'PetrFiala.1964', 'total_speeches': 126}, {'person.person_id': 'JanSkopecek.1980', 'total_speeches': 119}, {'person.person_id': 'VojtechPikal.1987', 'total_speeches': 89}] +Running time 10.435791015625 ms + +-----------------------+----------------+ | person.person_id | total_speeches | +-----------------------+----------------+ diff --git a/test/API/examples/actual/most_talkative_regulars_result.txt b/test/API/examples/actual/most_talkative_regulars_result.txt index edd0720..079f8a5 100644 --- a/test/API/examples/actual/most_talkative_regulars_result.txt +++ b/test/API/examples/actual/most_talkative_regulars_result.txt @@ -1,5 +1,7 @@ [{'persName.forename': 'Josef', 'persName.surname': 'Bělica', 'total_tokens': 307}, {'persName.forename': 'Alena', 'persName.surname': 'Gajdůšková', 'total_tokens': 65}, {'persName.forename': 'Antonín', 'persName.surname': 'Seďa', 'total_tokens': 117}, {'persName.forename': 'Věra', 'persName.surname': 'Adámková', 'total_tokens': 7310}, {'persName.forename': 'Vít', 'persName.surname': 'Vomáčka', 'total_tokens': 29}, {'persName.forename': 'Stanislav', 'persName.surname': 'Juránek', 'total_tokens': 89}, {'persName.forename': 'Robert', 'persName.surname': 'Stržínek', 'total_tokens': 653}, {'persName.forename': 'Petr', 'persName.surname': 'Třešňák', 'total_tokens': 227}, {'persName.forename': 'Jakub', 'persName.surname': 'Michálek', 'total_tokens': 11491}, {'persName.forename': 'Vladimíra', 'persName.surname': 'Lesenská', 'total_tokens': 1003}] +Running time 9.15185546875 ms + +-------------------+------------------+--------------+ | persName.forename | persName.surname | total_tokens | +-------------------+------------------+--------------+ diff --git a/test/API/examples/actual/politician_comparisonCS_result.txt b/test/API/examples/actual/politician_comparisonCS_result.txt index 50c60c7..4905e8c 100644 --- a/test/API/examples/actual/politician_comparisonCS_result.txt +++ b/test/API/examples/actual/politician_comparisonCS_result.txt @@ -1,5 +1,7 @@ [{'person.person_id': 'AdamKalous.1979', 'persName.forename': 'Adam', 'persName.surname': 'Kalous', 'total_speeches': 0}, {'person.person_id': 'AdamRykala.1986', 'persName.forename': 'Adam', 'persName.surname': 'Rykala', 'total_speeches': 0}] +Running time 7.3037109375 ms + +------------------+-------------------+------------------+----------------+ | person.person_id | persName.forename | persName.surname | total_speeches | +------------------+-------------------+------------------+----------------+ diff --git a/test/API/examples/actual/speech_count_parties_result.txt b/test/API/examples/actual/speech_count_parties_result.txt index 89fc43b..5c712d9 100644 --- a/test/API/examples/actual/speech_count_parties_result.txt +++ b/test/API/examples/actual/speech_count_parties_result.txt @@ -1,5 +1,7 @@ [{'organisation.name': 'Poslanecký klub Úsvit - Národní Koalice', 'total_speeches': 105}, {'organisation.name': 'Úsvit přímé demokracie Tomia Okamury', 'total_speeches': 114}, {'organisation.name': 'Poslanecký klub České pirátské strany', 'total_speeches': 294}, {'organisation.name': 'Poslanecký klub Komunistické strany Čech a Moravy', 'total_speeches': 468}, {'organisation.name': 'Svoboda a prima demokracie - Tomio Okamura', 'total_speeches': 29}, {'organisation.name': 'Křesťanská a demokratická unie - Československá strana lidová', 'total_speeches': 253}, {'organisation.name': 'Česká strana sociálně demokratická', 'total_speeches': 735}, {'organisation.name': 'Poslanecký klub Starostové a nezávislí', 'total_speeches': 293}, {'organisation.name': 'Poslanecký klub TOP 09 a Starostové', 'total_speeches': 415}, {'organisation.name': 'Poslanecký klub Svoboda a přímá demokracie', 'total_speeches': 161}, {'organisation.name': 'Česká pirátská strana', 'total_speeches': 227}, {'organisation.name': 'Poslanecký klub Občanské demokratické strany', 'total_speeches': 550}, {'organisation.name': 'Poslanecký klub TOP 09', 'total_speeches': 197}, {'organisation.name': 'Občanská demokratická strana', 'total_speeches': 367}, {'organisation.name': 'Poslanecký klub ANO 2011', 'total_speeches': 1101}, {'organisation.name': 'TOP 09', 'total_speeches': 392}, {'organisation.name': 'Poslanecký klub České strany sociálně demokratické', 'total_speeches': 1362}, {'organisation.name': 'Poslanecký klub KDU-ČSL', 'total_speeches': 353}, {'organisation.name': 'Starostove a nezavisli', 'total_speeches': 45}, {'organisation.name': 'ANO2011', 'total_speeches': 25}, {'organisation.name': 'Komunistická strana Čech a Moravy', 'total_speeches': 399}] +Running time 15.8046875 ms + +---------------------------------------------------------------+----------------+ | organisation.name | total_speeches | +---------------------------------------------------------------+----------------+ diff --git a/test/API/examples/actual/total_duration_of_speeches_given_by_ANO_members_ms_result.txt b/test/API/examples/actual/total_duration_of_speeches_given_by_ANO_members_ms_result.txt index fbd46c9..5b524bb 100644 --- a/test/API/examples/actual/total_duration_of_speeches_given_by_ANO_members_ms_result.txt +++ b/test/API/examples/actual/total_duration_of_speeches_given_by_ANO_members_ms_result.txt @@ -1,5 +1,7 @@ [{'affiliation.person_id': 'RadekVondracek.1973', 'total_duration_ms': 291840000.0}, {'affiliation.person_id': 'JaroslavaPokornaJermanova.1970', 'total_duration_ms': 137331790.0}, {'affiliation.person_id': 'AndrejBabis.1954', 'total_duration_ms': 95323344.0}, {'affiliation.person_id': 'JaroslavFaltynek.1962', 'total_duration_ms': 62572336.0}, {'affiliation.person_id': 'JanaMrackovaVildumetzova.1973', 'total_duration_ms': 39024576.0}, {'affiliation.person_id': 'AlenaSchillerova.1964', 'total_duration_ms': 27244690.0}, {'affiliation.person_id': 'KarelHavlicek.1969', 'total_duration_ms': 15647360.0}, {'affiliation.person_id': 'AdamVojtech.1986', 'total_duration_ms': 13979280.0}, {'affiliation.person_id': 'MartinKolovratnik.1975', 'total_duration_ms': 11743220.0}, {'affiliation.person_id': 'RichardBrabec.1966', 'total_duration_ms': 10657070.0}, {'affiliation.person_id': 'KlaraDostalova.1971', 'total_duration_ms': 8251750.0}, {'affiliation.person_id': 'HelenaValkova.1951', 'total_duration_ms': 4230210.0}, {'affiliation.person_id': 'JanVolny.1959', 'total_duration_ms': 3914380.0}, {'affiliation.person_id': 'JosefKott.1970', 'total_duration_ms': 3703800.0}, {'affiliation.person_id': 'DanTok.1959', 'total_duration_ms': 3655100.0}, {'affiliation.person_id': 'MartinStropnicky.1956', 'total_duration_ms': 3646530.0}, {'affiliation.person_id': 'VeraJourova.1964', 'total_duration_ms': 3494370.0}, {'affiliation.person_id': 'ZdenekSoukup.1952', 'total_duration_ms': 3380260.0}, {'affiliation.person_id': 'BronislavSchwarz.1966', 'total_duration_ms': 3342500.0}, {'affiliation.person_id': 'MarekNovak.1976', 'total_duration_ms': 3037740.0}, {'affiliation.person_id': 'JiriZlatuska.1957', 'total_duration_ms': 2756800.0}, {'affiliation.person_id': 'JiriBlaha.1961', 'total_duration_ms': 2298300.0}, {'affiliation.person_id': 'PatrikNacher.1974', 'total_duration_ms': 1891340.0}, {'affiliation.person_id': 'RobertPelikan.1979', 'total_duration_ms': 1476220.0}, {'affiliation.person_id': 'RadkaMaxova.1968', 'total_duration_ms': 1434500.0}, {'affiliation.person_id': 'MilanBrazdil.1962', 'total_duration_ms': 1387340.0}, {'affiliation.person_id': 'LubomirMetnar.1967', 'total_duration_ms': 1017200.0}, {'affiliation.person_id': 'MatejFichtner.1984', 'total_duration_ms': 917380.0}, {'affiliation.person_id': 'JosefHajek.1956', 'total_duration_ms': 893160.0}, {'affiliation.person_id': 'MiloslavJanulik.1962', 'total_duration_ms': 788900.0}, {'affiliation.person_id': 'RomanKubicek.1963', 'total_duration_ms': 732260.0}, {'affiliation.person_id': 'BerenikaPestova.1971', 'total_duration_ms': 478290.0}, {'affiliation.person_id': 'RobertKralicek.1977', 'total_duration_ms': 414070.0}, {'affiliation.person_id': 'PetrVrana.1975', 'total_duration_ms': 244040.0}, {'affiliation.person_id': 'DavidKasal.1969', 'total_duration_ms': 150220.0}, {'affiliation.person_id': 'OndrejBabka.1994', 'total_duration_ms': 108290.0}, {'affiliation.person_id': 'IvoVondrak.1959', 'total_duration_ms': 18300.0}, {'affiliation.person_id': 'JanaHanzlikova.1966', 'total_duration_ms': 0.0}, {'affiliation.person_id': 'JaroslavBzoch.1983', 'total_duration_ms': 0.0}] +Running time 20.956298828125 ms + +--------------------------------+-------------------+ | affiliation.person_id | total_duration_ms | +--------------------------------+-------------------+ diff --git a/test/API/examples/actual/total_sentences_female_result.txt b/test/API/examples/actual/total_sentences_female_result.txt index d472399..1b2784e 100644 --- a/test/API/examples/actual/total_sentences_female_result.txt +++ b/test/API/examples/actual/total_sentences_female_result.txt @@ -1,5 +1,7 @@ [{'person.sex': 'F', 'total_sentences': 18642}] +Running time 7.7900390625 ms + +------------+-----------------+ | person.sex | total_sentences | +------------+-----------------+ diff --git a/test/API/examples/actual/total_speeches_by_organisation_roles_result.txt b/test/API/examples/actual/total_speeches_by_organisation_roles_result.txt index 1dd41f7..13f1bb3 100644 --- a/test/API/examples/actual/total_speeches_by_organisation_roles_result.txt +++ b/test/API/examples/actual/total_speeches_by_organisation_roles_result.txt @@ -1,5 +1,7 @@ [{'organisation.role': 'interparliamentaryFriendshipGroup', 'COUNT(speech.id) as total_speeches': 17013}, {'organisation.role': 'committee', 'COUNT(speech.id) as total_speeches': 9380}, {'organisation.role': 'parliament', 'COUNT(speech.id) as total_speeches': 6220}, {'organisation.role': 'parliamentaryGroup', 'COUNT(speech.id) as total_speeches': 5299}, {'organisation.role': 'subcommittee', 'COUNT(speech.id) as total_speeches': 4803}, {'organisation.role': 'politicalParty', 'COUNT(speech.id) as total_speeches': 2586}, {'organisation.role': 'commission', 'COUNT(speech.id) as total_speeches': 1890}, {'organisation.role': 'delegation', 'COUNT(speech.id) as total_speeches': 1452}, {'organisation.role': 'government', 'COUNT(speech.id) as total_speeches': 383}, {'organisation.role': 'supervisoryBoard', 'COUNT(speech.id) as total_speeches': 201}, {'organisation.role': 'boardOfDirectors', 'COUNT(speech.id) as total_speeches': 14}, {'organisation.role': 'republic', 'COUNT(speech.id) as total_speeches': 4}] +Running time 35.09228515625 ms + +-----------------------------------+------------------------------------+ | organisation.role | COUNT(speech.id) as total_speeches | +-----------------------------------+------------------------------------+ diff --git a/test/API/examples/actual/total_speeches_male_time_frame_result.txt b/test/API/examples/actual/total_speeches_male_time_frame_result.txt index 7554776..54e1781 100644 --- a/test/API/examples/actual/total_speeches_male_time_frame_result.txt +++ b/test/API/examples/actual/total_speeches_male_time_frame_result.txt @@ -1,5 +1,7 @@ [{'person.sex': 'M', 'total_speeches': 285}] +Running time 4.737060546875 ms + +------------+----------------+ | person.sex | total_speeches | +------------+----------------+ diff --git a/test/API/examples/expected/average_named_entity_references_by_ANO_members_result.txt b/test/API/examples/expected/average_named_entity_references_by_ANO_members_result.txt index ddbbdab..7c7a253 100644 --- a/test/API/examples/expected/average_named_entity_references_by_ANO_members_result.txt +++ b/test/API/examples/expected/average_named_entity_references_by_ANO_members_result.txt @@ -1,5 +1,7 @@ [{'affiliation.person_id': 'AndrejBabis.1954', 'average_named_entity_references': 81.39669421487604}, {'affiliation.person_id': 'VeraJourova.1964', 'average_named_entity_references': 50.0}, {'affiliation.person_id': 'RichardBrabec.1966', 'average_named_entity_references': 36.2}, {'affiliation.person_id': 'JosefKott.1970', 'average_named_entity_references': 22.4390243902439}, {'affiliation.person_id': 'AdamVojtech.1986', 'average_named_entity_references': 21.5}, {'affiliation.person_id': 'KarelHavlicek.1969', 'average_named_entity_references': 18.666666666666668}, {'affiliation.person_id': 'DanTok.1959', 'average_named_entity_references': 16.333333333333332}, {'affiliation.person_id': 'RobertPelikan.1979', 'average_named_entity_references': 16.0}, {'affiliation.person_id': 'JanaMrackovaVildumetzova.1973', 'average_named_entity_references': 12.326923076923077}, {'affiliation.person_id': 'LubomirMetnar.1967', 'average_named_entity_references': 12.0}, {'affiliation.person_id': 'BronislavSchwarz.1966', 'average_named_entity_references': 12.0}, {'affiliation.person_id': 'MarekNovak.1976', 'average_named_entity_references': 12.0}, {'affiliation.person_id': 'KlaraDostalova.1971', 'average_named_entity_references': 11.068965517241379}, {'affiliation.person_id': 'PetrVrana.1975', 'average_named_entity_references': 11.0}, {'affiliation.person_id': 'AlenaSchillerova.1964', 'average_named_entity_references': 10.455696202531646}, {'affiliation.person_id': 'RadekVondracek.1973', 'average_named_entity_references': 10.06561203319502}, {'affiliation.person_id': 'JaroslavFaltynek.1962', 'average_named_entity_references': 7.722614840989399}, {'affiliation.person_id': 'ZdenekSoukup.1952', 'average_named_entity_references': 7.5}, {'affiliation.person_id': 'RomanKubicek.1963', 'average_named_entity_references': 7.4}, {'affiliation.person_id': 'BerenikaPestova.1971', 'average_named_entity_references': 7.333333333333333}, {'affiliation.person_id': 'MiloslavJanulik.1962', 'average_named_entity_references': 7.0}, {'affiliation.person_id': 'IvoVondrak.1959', 'average_named_entity_references': 6.5}, {'affiliation.person_id': 'JiriZlatuska.1957', 'average_named_entity_references': 6.5}, {'affiliation.person_id': 'JosefHajek.1956', 'average_named_entity_references': 6.0}, {'affiliation.person_id': 'JaroslavaPokornaJermanova.1970', 'average_named_entity_references': 5.787781350482315}, {'affiliation.person_id': 'JanaHanzlikova.1966', 'average_named_entity_references': 5.5}, {'affiliation.person_id': 'RobertKralicek.1977', 'average_named_entity_references': 5.0}, {'affiliation.person_id': 'MartinStropnicky.1956', 'average_named_entity_references': 4.1875}, {'affiliation.person_id': 'MartinKolovratnik.1975', 'average_named_entity_references': 3.57847533632287}, {'affiliation.person_id': 'MilanBrazdil.1962', 'average_named_entity_references': 3.3548387096774195}, {'affiliation.person_id': 'RomanaFischerova.1969', 'average_named_entity_references': 3.0}, {'affiliation.person_id': 'JaroslavBzoch.1983', 'average_named_entity_references': 3.0}, {'affiliation.person_id': 'JanVolny.1959', 'average_named_entity_references': 2.1560283687943262}, {'affiliation.person_id': 'JiriBlaha.1961', 'average_named_entity_references': 2.0}, {'affiliation.person_id': 'HelenaValkova.1951', 'average_named_entity_references': 1.3804347826086958}, {'affiliation.person_id': 'RadkaMaxova.1968', 'average_named_entity_references': 1.0}, {'affiliation.person_id': 'MatejFichtner.1984', 'average_named_entity_references': 0.5588235294117647}, {'affiliation.person_id': 'PatrikNacher.1974', 'average_named_entity_references': 0.5}, {'affiliation.person_id': 'OndrejBabka.1994', 'average_named_entity_references': 0.0}, {'affiliation.person_id': 'DavidKasal.1969', 'average_named_entity_references': 0.0}] +Running time 21.772705078125 ms + +--------------------------------+---------------------------------+ | affiliation.person_id | average_named_entity_references | +--------------------------------+---------------------------------+ diff --git a/test/API/examples/expected/average_sentences_most_talkative_result.txt b/test/API/examples/expected/average_sentences_most_talkative_result.txt index 765ef9a..daf8c9b 100644 --- a/test/API/examples/expected/average_sentences_most_talkative_result.txt +++ b/test/API/examples/expected/average_sentences_most_talkative_result.txt @@ -1,5 +1,7 @@ [{'affiliation.role': 'member', 'average_sentence_count': 10.937954642704321}, {'affiliation.role': 'head', 'average_sentence_count': 11.042723631508679}, {'affiliation.role': 'deputyHead', 'average_sentence_count': 8.285714285714286}] +Running time 13.108154296875 ms + +------------------+------------------------+ | affiliation.role | average_sentence_count | +------------------+------------------------+ diff --git a/test/API/examples/expected/average_tokens_by_position_result.txt b/test/API/examples/expected/average_tokens_by_position_result.txt index 0f6ec07..4ad8800 100644 --- a/test/API/examples/expected/average_tokens_by_position_result.txt +++ b/test/API/examples/expected/average_tokens_by_position_result.txt @@ -1,5 +1,7 @@ [{'speech.role': 'guest', 'average_tokens': 1077.8934426229507}, {'speech.role': 'regular', 'average_tokens': 496.90713671539123}, {'speech.role': 'chair', 'average_tokens': 143.19426456984274}] +Running time 21.019287109375 ms + +-------------+--------------------+ | speech.role | average_tokens | +-------------+--------------------+ diff --git a/test/API/examples/expected/average_words_per_minute_of_fastest_speaker_depending_on_time_result.txt b/test/API/examples/expected/average_words_per_minute_of_fastest_speaker_depending_on_time_result.txt index 44df0ce..9c670c9 100644 --- a/test/API/examples/expected/average_words_per_minute_of_fastest_speaker_depending_on_time_result.txt +++ b/test/API/examples/expected/average_words_per_minute_of_fastest_speaker_depending_on_time_result.txt @@ -1,5 +1,7 @@ [{'speech.earliest_timestamp': '12:48:00', 'average_wpm': 161.34031413612567}] +Running time 10.3564453125 ms + +---------------------------+--------------------+ | speech.earliest_timestamp | average_wpm | +---------------------------+--------------------+ diff --git a/test/API/examples/expected/fastest_speaking_speakers_result.txt b/test/API/examples/expected/fastest_speaking_speakers_result.txt index ef4348c..b9204c5 100644 --- a/test/API/examples/expected/fastest_speaking_speakers_result.txt +++ b/test/API/examples/expected/fastest_speaking_speakers_result.txt @@ -1,5 +1,7 @@ [{'speech.person_id': 'BronislavSchwarz.1966', 'average_wpm': 161.34031413612567}, {'speech.person_id': 'LukasKolarik.1984', 'average_wpm': 155.80850204389782}, {'speech.person_id': 'OndrejVesely.1976', 'average_wpm': 151.81583647549118}, {'speech.person_id': 'PavelBlazek.1969', 'average_wpm': 149.77964855666076}, {'speech.person_id': 'MilanChovanec.1970', 'average_wpm': 149.25437760129654}, {'speech.person_id': 'MarianJurecka.1981', 'average_wpm': 147.04994388205515}, {'speech.person_id': 'RobertPlaga.1978', 'average_wpm': 145.44581783271332}, {'speech.person_id': 'MarcelChladek', 'average_wpm': 145.00501169395255}, {'speech.person_id': 'MiloslavJanulik.1962', 'average_wpm': 143.10080192959902}, {'speech.person_id': 'MartinKolovratnik.1975', 'average_wpm': 142.27168366868392}] +Running time 9.710693359375 ms + +------------------------+--------------------+ | speech.person_id | average_wpm | +------------------------+--------------------+ diff --git a/test/API/examples/expected/gender_average_tokens_result.txt b/test/API/examples/expected/gender_average_tokens_result.txt index a4a854d..61d8435 100644 --- a/test/API/examples/expected/gender_average_tokens_result.txt +++ b/test/API/examples/expected/gender_average_tokens_result.txt @@ -1,5 +1,7 @@ [{'person.sex': '', 'average_tokens': 1335.3333333333333}, {'person.sex': 'M', 'average_tokens': 325.23359818388195}, {'person.sex': 'F', 'average_tokens': 245.54014029618082}] +Running time 9.655517578125 ms + +------------+--------------------+ | person.sex | average_tokens | +------------+--------------------+ diff --git a/test/API/examples/expected/gender_total_speeches_result.txt b/test/API/examples/expected/gender_total_speeches_result.txt index 1e68170..fb4e409 100644 --- a/test/API/examples/expected/gender_total_speeches_result.txt +++ b/test/API/examples/expected/gender_total_speeches_result.txt @@ -1,5 +1,7 @@ [{'person.sex': '', 'total_speeches': 3}, {'person.sex': 'M', 'total_speeches': 4405}, {'person.sex': 'F', 'total_speeches': 1283}] +Running time 12.240478515625 ms + +------------+----------------+ | person.sex | total_speeches | +------------+----------------+ diff --git a/test/API/examples/expected/most_speeches_male_result.txt b/test/API/examples/expected/most_speeches_male_result.txt index a6160e6..72bdae8 100644 --- a/test/API/examples/expected/most_speeches_male_result.txt +++ b/test/API/examples/expected/most_speeches_male_result.txt @@ -1,5 +1,7 @@ [{'person.person_id': 'RadekVondracek.1973', 'total_speeches': 769}, {'person.person_id': 'JanHamacek.1978', 'total_speeches': 587}, {'person.person_id': 'TomioOkamura.1972', 'total_speeches': 303}, {'person.person_id': 'JanBartosek.1971', 'total_speeches': 287}, {'person.person_id': 'VojtechFilip.1955', 'total_speeches': 262}, {'person.person_id': 'MiroslavKalousek.1960', 'total_speeches': 160}, {'person.person_id': 'ZbynekStanjura.1964', 'total_speeches': 127}, {'person.person_id': 'PetrFiala.1964', 'total_speeches': 126}, {'person.person_id': 'JanSkopecek.1980', 'total_speeches': 119}, {'person.person_id': 'VojtechPikal.1987', 'total_speeches': 89}] +Running time 10.80078125 ms + +-----------------------+----------------+ | person.person_id | total_speeches | +-----------------------+----------------+ diff --git a/test/API/examples/expected/most_talkative_regulars_result.txt b/test/API/examples/expected/most_talkative_regulars_result.txt index edd0720..e6d8e28 100644 --- a/test/API/examples/expected/most_talkative_regulars_result.txt +++ b/test/API/examples/expected/most_talkative_regulars_result.txt @@ -1,5 +1,7 @@ [{'persName.forename': 'Josef', 'persName.surname': 'Bělica', 'total_tokens': 307}, {'persName.forename': 'Alena', 'persName.surname': 'Gajdůšková', 'total_tokens': 65}, {'persName.forename': 'Antonín', 'persName.surname': 'Seďa', 'total_tokens': 117}, {'persName.forename': 'Věra', 'persName.surname': 'Adámková', 'total_tokens': 7310}, {'persName.forename': 'Vít', 'persName.surname': 'Vomáčka', 'total_tokens': 29}, {'persName.forename': 'Stanislav', 'persName.surname': 'Juránek', 'total_tokens': 89}, {'persName.forename': 'Robert', 'persName.surname': 'Stržínek', 'total_tokens': 653}, {'persName.forename': 'Petr', 'persName.surname': 'Třešňák', 'total_tokens': 227}, {'persName.forename': 'Jakub', 'persName.surname': 'Michálek', 'total_tokens': 11491}, {'persName.forename': 'Vladimíra', 'persName.surname': 'Lesenská', 'total_tokens': 1003}] +Running time 10.566650390625 ms + +-------------------+------------------+--------------+ | persName.forename | persName.surname | total_tokens | +-------------------+------------------+--------------+ diff --git a/test/API/examples/expected/politician_comparisonCS_result.txt b/test/API/examples/expected/politician_comparisonCS_result.txt index 50c60c7..8e508f4 100644 --- a/test/API/examples/expected/politician_comparisonCS_result.txt +++ b/test/API/examples/expected/politician_comparisonCS_result.txt @@ -1,5 +1,7 @@ [{'person.person_id': 'AdamKalous.1979', 'persName.forename': 'Adam', 'persName.surname': 'Kalous', 'total_speeches': 0}, {'person.person_id': 'AdamRykala.1986', 'persName.forename': 'Adam', 'persName.surname': 'Rykala', 'total_speeches': 0}] +Running time 8.216552734375 ms + +------------------+-------------------+------------------+----------------+ | person.person_id | persName.forename | persName.surname | total_speeches | +------------------+-------------------+------------------+----------------+ diff --git a/test/API/examples/expected/speech_count_parties_result.txt b/test/API/examples/expected/speech_count_parties_result.txt index 89fc43b..8645213 100644 --- a/test/API/examples/expected/speech_count_parties_result.txt +++ b/test/API/examples/expected/speech_count_parties_result.txt @@ -1,5 +1,7 @@ [{'organisation.name': 'Poslanecký klub Úsvit - Národní Koalice', 'total_speeches': 105}, {'organisation.name': 'Úsvit přímé demokracie Tomia Okamury', 'total_speeches': 114}, {'organisation.name': 'Poslanecký klub České pirátské strany', 'total_speeches': 294}, {'organisation.name': 'Poslanecký klub Komunistické strany Čech a Moravy', 'total_speeches': 468}, {'organisation.name': 'Svoboda a prima demokracie - Tomio Okamura', 'total_speeches': 29}, {'organisation.name': 'Křesťanská a demokratická unie - Československá strana lidová', 'total_speeches': 253}, {'organisation.name': 'Česká strana sociálně demokratická', 'total_speeches': 735}, {'organisation.name': 'Poslanecký klub Starostové a nezávislí', 'total_speeches': 293}, {'organisation.name': 'Poslanecký klub TOP 09 a Starostové', 'total_speeches': 415}, {'organisation.name': 'Poslanecký klub Svoboda a přímá demokracie', 'total_speeches': 161}, {'organisation.name': 'Česká pirátská strana', 'total_speeches': 227}, {'organisation.name': 'Poslanecký klub Občanské demokratické strany', 'total_speeches': 550}, {'organisation.name': 'Poslanecký klub TOP 09', 'total_speeches': 197}, {'organisation.name': 'Občanská demokratická strana', 'total_speeches': 367}, {'organisation.name': 'Poslanecký klub ANO 2011', 'total_speeches': 1101}, {'organisation.name': 'TOP 09', 'total_speeches': 392}, {'organisation.name': 'Poslanecký klub České strany sociálně demokratické', 'total_speeches': 1362}, {'organisation.name': 'Poslanecký klub KDU-ČSL', 'total_speeches': 353}, {'organisation.name': 'Starostove a nezavisli', 'total_speeches': 45}, {'organisation.name': 'ANO2011', 'total_speeches': 25}, {'organisation.name': 'Komunistická strana Čech a Moravy', 'total_speeches': 399}] +Running time 15.931396484375 ms + +---------------------------------------------------------------+----------------+ | organisation.name | total_speeches | +---------------------------------------------------------------+----------------+ diff --git a/test/API/examples/expected/total_duration_of_speeches_given_by_ANO_members_ms_result.txt b/test/API/examples/expected/total_duration_of_speeches_given_by_ANO_members_ms_result.txt index fbd46c9..9188308 100644 --- a/test/API/examples/expected/total_duration_of_speeches_given_by_ANO_members_ms_result.txt +++ b/test/API/examples/expected/total_duration_of_speeches_given_by_ANO_members_ms_result.txt @@ -1,5 +1,7 @@ [{'affiliation.person_id': 'RadekVondracek.1973', 'total_duration_ms': 291840000.0}, {'affiliation.person_id': 'JaroslavaPokornaJermanova.1970', 'total_duration_ms': 137331790.0}, {'affiliation.person_id': 'AndrejBabis.1954', 'total_duration_ms': 95323344.0}, {'affiliation.person_id': 'JaroslavFaltynek.1962', 'total_duration_ms': 62572336.0}, {'affiliation.person_id': 'JanaMrackovaVildumetzova.1973', 'total_duration_ms': 39024576.0}, {'affiliation.person_id': 'AlenaSchillerova.1964', 'total_duration_ms': 27244690.0}, {'affiliation.person_id': 'KarelHavlicek.1969', 'total_duration_ms': 15647360.0}, {'affiliation.person_id': 'AdamVojtech.1986', 'total_duration_ms': 13979280.0}, {'affiliation.person_id': 'MartinKolovratnik.1975', 'total_duration_ms': 11743220.0}, {'affiliation.person_id': 'RichardBrabec.1966', 'total_duration_ms': 10657070.0}, {'affiliation.person_id': 'KlaraDostalova.1971', 'total_duration_ms': 8251750.0}, {'affiliation.person_id': 'HelenaValkova.1951', 'total_duration_ms': 4230210.0}, {'affiliation.person_id': 'JanVolny.1959', 'total_duration_ms': 3914380.0}, {'affiliation.person_id': 'JosefKott.1970', 'total_duration_ms': 3703800.0}, {'affiliation.person_id': 'DanTok.1959', 'total_duration_ms': 3655100.0}, {'affiliation.person_id': 'MartinStropnicky.1956', 'total_duration_ms': 3646530.0}, {'affiliation.person_id': 'VeraJourova.1964', 'total_duration_ms': 3494370.0}, {'affiliation.person_id': 'ZdenekSoukup.1952', 'total_duration_ms': 3380260.0}, {'affiliation.person_id': 'BronislavSchwarz.1966', 'total_duration_ms': 3342500.0}, {'affiliation.person_id': 'MarekNovak.1976', 'total_duration_ms': 3037740.0}, {'affiliation.person_id': 'JiriZlatuska.1957', 'total_duration_ms': 2756800.0}, {'affiliation.person_id': 'JiriBlaha.1961', 'total_duration_ms': 2298300.0}, {'affiliation.person_id': 'PatrikNacher.1974', 'total_duration_ms': 1891340.0}, {'affiliation.person_id': 'RobertPelikan.1979', 'total_duration_ms': 1476220.0}, {'affiliation.person_id': 'RadkaMaxova.1968', 'total_duration_ms': 1434500.0}, {'affiliation.person_id': 'MilanBrazdil.1962', 'total_duration_ms': 1387340.0}, {'affiliation.person_id': 'LubomirMetnar.1967', 'total_duration_ms': 1017200.0}, {'affiliation.person_id': 'MatejFichtner.1984', 'total_duration_ms': 917380.0}, {'affiliation.person_id': 'JosefHajek.1956', 'total_duration_ms': 893160.0}, {'affiliation.person_id': 'MiloslavJanulik.1962', 'total_duration_ms': 788900.0}, {'affiliation.person_id': 'RomanKubicek.1963', 'total_duration_ms': 732260.0}, {'affiliation.person_id': 'BerenikaPestova.1971', 'total_duration_ms': 478290.0}, {'affiliation.person_id': 'RobertKralicek.1977', 'total_duration_ms': 414070.0}, {'affiliation.person_id': 'PetrVrana.1975', 'total_duration_ms': 244040.0}, {'affiliation.person_id': 'DavidKasal.1969', 'total_duration_ms': 150220.0}, {'affiliation.person_id': 'OndrejBabka.1994', 'total_duration_ms': 108290.0}, {'affiliation.person_id': 'IvoVondrak.1959', 'total_duration_ms': 18300.0}, {'affiliation.person_id': 'JanaHanzlikova.1966', 'total_duration_ms': 0.0}, {'affiliation.person_id': 'JaroslavBzoch.1983', 'total_duration_ms': 0.0}] +Running time 27.9990234375 ms + +--------------------------------+-------------------+ | affiliation.person_id | total_duration_ms | +--------------------------------+-------------------+ diff --git a/test/API/examples/expected/total_sentences_female_result.txt b/test/API/examples/expected/total_sentences_female_result.txt index d472399..3de5923 100644 --- a/test/API/examples/expected/total_sentences_female_result.txt +++ b/test/API/examples/expected/total_sentences_female_result.txt @@ -1,5 +1,7 @@ [{'person.sex': 'F', 'total_sentences': 18642}] +Running time 7.949951171875 ms + +------------+-----------------+ | person.sex | total_sentences | +------------+-----------------+ diff --git a/test/API/examples/expected/total_speeches_by_organisation_roles_result.txt b/test/API/examples/expected/total_speeches_by_organisation_roles_result.txt index 1dd41f7..08b351e 100644 --- a/test/API/examples/expected/total_speeches_by_organisation_roles_result.txt +++ b/test/API/examples/expected/total_speeches_by_organisation_roles_result.txt @@ -1,5 +1,7 @@ [{'organisation.role': 'interparliamentaryFriendshipGroup', 'COUNT(speech.id) as total_speeches': 17013}, {'organisation.role': 'committee', 'COUNT(speech.id) as total_speeches': 9380}, {'organisation.role': 'parliament', 'COUNT(speech.id) as total_speeches': 6220}, {'organisation.role': 'parliamentaryGroup', 'COUNT(speech.id) as total_speeches': 5299}, {'organisation.role': 'subcommittee', 'COUNT(speech.id) as total_speeches': 4803}, {'organisation.role': 'politicalParty', 'COUNT(speech.id) as total_speeches': 2586}, {'organisation.role': 'commission', 'COUNT(speech.id) as total_speeches': 1890}, {'organisation.role': 'delegation', 'COUNT(speech.id) as total_speeches': 1452}, {'organisation.role': 'government', 'COUNT(speech.id) as total_speeches': 383}, {'organisation.role': 'supervisoryBoard', 'COUNT(speech.id) as total_speeches': 201}, {'organisation.role': 'boardOfDirectors', 'COUNT(speech.id) as total_speeches': 14}, {'organisation.role': 'republic', 'COUNT(speech.id) as total_speeches': 4}] +Running time 32.56396484375 ms + +-----------------------------------+------------------------------------+ | organisation.role | COUNT(speech.id) as total_speeches | +-----------------------------------+------------------------------------+ diff --git a/test/API/examples/expected/total_speeches_male_time_frame_result.txt b/test/API/examples/expected/total_speeches_male_time_frame_result.txt index 7554776..eeddeed 100644 --- a/test/API/examples/expected/total_speeches_male_time_frame_result.txt +++ b/test/API/examples/expected/total_speeches_male_time_frame_result.txt @@ -1,5 +1,7 @@ [{'person.sex': 'M', 'total_speeches': 285}] +Running time 5.8994140625 ms + +------------+----------------+ | person.sex | total_speeches | +------------+----------------+ diff --git a/test/API/tester.py b/test/API/tester.py index ac29918..666b0df 100644 --- a/test/API/tester.py +++ b/test/API/tester.py @@ -3,6 +3,7 @@ import difflib import argparse import os +import re args_parser = argparse.ArgumentParser() args_parser.add_argument("--source_dir", type=str, default="examples/inputs/", @@ -32,10 +33,19 @@ def main(args): f1 = open(args.expected, 'r') expected = f1.read().strip() - if (actual == expected): + + expected = [line for line in expected.splitlines() if not "Running time" in line] + actual = [line for line in actual.splitlines() if not "Running time" in line] + correct = True + + for el, al in zip(expected, actual): + if el != al: + correct = False + + if (correct): print(f"Query {args.specific}: PASSED!") else: - diff = difflib.unified_diff(expected.splitlines(), actual.splitlines(), + diff = difflib.unified_diff(expected, actual, fromfile='expected', tofile='actual', lineterm='') print(f"Query {args.specific}: FAILED!") print("------------------------------") @@ -44,6 +54,7 @@ def main(args): print("------------------------------") else: print("---TESTING ALL QUERIES AT ONCE---") + client_process = subprocess.run([my_venv, client, f"--query_source={args.source_dir}", f"--dir={args.target_dir}"], capture_output=True, text=True) @@ -56,10 +67,19 @@ def main(args): expected = f2.read().strip() f1.close() f2.close() - if (actual == expected): + + expected = [line for line in expected.splitlines() if not "Running time" in line] + actual = [line for line in actual.splitlines() if not "Running time" in line] + correct = True + for el, al in zip(expected, actual): + if el != al: + correct = False + + if (correct): print(f"Query: {result[:]} PASSED!") else: - diff = difflib.unified_diff(expected.splitlines(), actual.splitlines(), + + diff = difflib.unified_diff(expected, actual, fromfile='expected', tofile='actual', lineterm='') print(f"Query: {result} FAILED!") print("-----------------------") @@ -68,7 +88,6 @@ def main(args): print("-----------------------") - finally: server_process.terminate() server_process.wait()