From 30190c63620074a521640e9391c65ebbd71e1b88 Mon Sep 17 00:00:00 2001 From: emetheni <lenakmeth@gmail.com> Date: Sun, 10 Sep 2023 12:52:01 +0200 Subject: [PATCH] zero-shot models --- .gitignore | 1 + classifier_bare_huggingface.py | 145 +++------- classifier_bare_pytorch.py | 53 +--- get_mappings_all_sets.py | 82 ------ make-mappings.ipynb | 260 ----------------- make_mappings_zero-shot.py | 102 +++++++ mappings/zero-shot/deu_zero-shot.tsv | 164 +++++++++++ mappings/zero-shot/eng_zero-shot.tsv | 164 +++++++++++ mappings/zero-shot/eus_zero-shot.tsv | 164 +++++++++++ mappings/zero-shot/fas_zero-shot.tsv | 164 +++++++++++ mappings/zero-shot/fra_zero-shot.tsv | 164 +++++++++++ mappings/zero-shot/ita_zero-shot.tsv | 164 +++++++++++ mappings/zero-shot/nld_zero-shot.tsv | 164 +++++++++++ mappings/zero-shot/por_zero-shot.tsv | 164 +++++++++++ mappings/zero-shot/rus_zero-shot.tsv | 164 +++++++++++ mappings/zero-shot/spa_zero-shot.tsv | 164 +++++++++++ mappings/zero-shot/tha_zero-shot.tsv | 164 +++++++++++ mappings/zero-shot/tur_zero-shot.tsv | 164 +++++++++++ mappings/zero-shot/zho_zero-shot.tsv | 164 +++++++++++ run_stuff.sh | 33 --- see_results.ipynb | 411 --------------------------- utils.py | 25 +- 22 files changed, 2312 insertions(+), 932 deletions(-) delete mode 100644 get_mappings_all_sets.py delete mode 100644 make-mappings.ipynb create mode 100644 make_mappings_zero-shot.py create mode 100644 mappings/zero-shot/deu_zero-shot.tsv create mode 100644 mappings/zero-shot/eng_zero-shot.tsv create mode 100644 mappings/zero-shot/eus_zero-shot.tsv create mode 100644 mappings/zero-shot/fas_zero-shot.tsv create mode 100644 mappings/zero-shot/fra_zero-shot.tsv create mode 100644 mappings/zero-shot/ita_zero-shot.tsv create mode 100644 mappings/zero-shot/nld_zero-shot.tsv create mode 100644 mappings/zero-shot/por_zero-shot.tsv create mode 100644 mappings/zero-shot/rus_zero-shot.tsv create mode 100644 mappings/zero-shot/spa_zero-shot.tsv create mode 100644 mappings/zero-shot/tha_zero-shot.tsv create mode 100644 mappings/zero-shot/tur_zero-shot.tsv create mode 100644 mappings/zero-shot/zho_zero-shot.tsv delete mode 100644 run_stuff.sh delete mode 100644 see_results.ipynb diff --git a/.gitignore b/.gitignore index c77fc10..69233cd 100644 --- a/.gitignore +++ b/.gitignore @@ -146,4 +146,5 @@ logs/ wandb/ results/ training_output/ +*.sh diff --git a/classifier_bare_huggingface.py b/classifier_bare_huggingface.py index 307b4fc..22c0509 100644 --- a/classifier_bare_huggingface.py +++ b/classifier_bare_huggingface.py @@ -16,16 +16,18 @@ from utils import * device = torch.device("cuda") +print('\n\nwith Language token - eng + Corpus (no framework) \n') + # --------------------------------------------------------------------------------------------------- args = parse_args() now = datetime.now() dt_string = now.strftime("%d.%m.%y-%H:%M:%S") layers_to_freeze = args.freeze_layers.split(";") substitutions_file = 'mappings/substitutions.txt' -# mapping_classes = args.mappings_file[:-4].split('-')[-1] +mapping_classes = args.mappings_file[:-4].split('-')[-1] set_seed(42) -print('Model:', args.transformer_model, dt_string) +print('Model:', args.transformer_model) print('Batch size:', args.batch_size * args.gradient_accumulation_steps) print('Num epochs:', args.num_epochs) @@ -37,7 +39,11 @@ print('Num epochs:', args.num_epochs) mappings, inv_mappings = open_mappings(args.mappings_file) # Open sentences -train_sentences, dev_dict_sentences, test_dict_sentences, framework_labels = open_sentences(args.data_path, mappings) +train_sentences, dev_dict_sentences, test_dict_sentences, _ = open_sentences(args.data_path, mappings) + +print('\nCheck encodings:\n') +print(train_sentences[0]) + # make pandas dataframes file_header = ['text', 'labels'] @@ -53,23 +59,23 @@ eval_df = pd.DataFrame([[' '.join(x[-2]), x[-1]] for x in sents], columns =file_header) -# dev_dict_df = {corpus : pd.DataFrame([[' '.join(x[-2]), x[-1]] -# for x in sents], -# columns = file_header) -# for corpus, sents in dev_dict_sentences.items()} +dev_dict_df = {corpus : pd.DataFrame([[' '.join(x[-2]), x[-1]] + for x in sents], + columns = file_header) + for corpus, sents in dev_dict_sentences.items()} -# test_dict_df = {corpus : pd.DataFrame([[' '.join(x[-2]), x[-1]] -# for x in sents], -# columns = file_header) -# for corpus, sents in test_dict_sentences.items()} +test_dict_df = {corpus : pd.DataFrame([[' '.join(x[-2]), x[-1]] + for x in sents], + columns = file_header) + for corpus, sents in test_dict_sentences.items()} #Make datasets from dataframes train_dataset = datasets.Dataset.from_pandas(train_df) eval_dataset = datasets.Dataset.from_pandas(eval_df) -# dev_dict_dataset = {corpus:datasets.Dataset.from_pandas(dev_df) -# for corpus, dev_df in dev_dict_df.items()} -# test_dict_dataset = {corpus:datasets.Dataset.from_pandas(dev_df) -# for corpus, dev_df in test_dict_df.items()} +dev_dict_dataset = {corpus:datasets.Dataset.from_pandas(dev_df) + for corpus, dev_df in dev_dict_df.items()} +test_dict_dataset = {corpus:datasets.Dataset.from_pandas(dev_df) + for corpus, dev_df in test_dict_df.items()} # get number of labels num_labels = len(set([int(x.strip()) @@ -82,17 +88,17 @@ train_dataset.set_format(type="torch", columns=["input_ids", "attention_mask", " eval_dataset = eval_dataset.map(encode_batch, batched=True) eval_dataset.set_format(type="torch", columns=["input_ids", "attention_mask", "labels"]) -# encoded_dev_dataset = {} -# for corpus in dev_dict_dataset: -# temp = dev_dict_dataset[corpus].map(encode_batch, batched=True) -# temp.set_format(type="torch", columns=["input_ids", "attention_mask", "labels"]) -# encoded_dev_dataset[corpus] = temp +encoded_dev_dataset = {} +for corpus in dev_dict_dataset: + temp = dev_dict_dataset[corpus].map(encode_batch, batched=True) + temp.set_format(type="torch", columns=["input_ids", "attention_mask", "labels"]) + encoded_dev_dataset[corpus] = temp -# encoded_test_dataset = {} -# for corpus in test_dict_dataset: -# temp = test_dict_dataset[corpus].map(encode_batch, batched=True) -# temp.set_format(type="torch", columns=["input_ids", "attention_mask", "labels"]) -# encoded_test_dataset[corpus] = temp +encoded_test_dataset = {} +for corpus in test_dict_dataset: + temp = test_dict_dataset[corpus].map(encode_batch, batched=True) + temp.set_format(type="torch", columns=["input_ids", "attention_mask", "labels"]) + encoded_test_dataset[corpus] = temp # --------------------------------------------------------------------------------------------------- @@ -108,10 +114,11 @@ training_args = TrainingArguments( per_device_eval_batch_size = args.batch_size, gradient_accumulation_steps = args.gradient_accumulation_steps, logging_steps = (len(train_sentences)/(args.batch_size * args.gradient_accumulation_steps)), - output_dir = "./results/models/" + args.transformer_model + '_' + dt_string, + output_dir = "./results/models/" + args.transformer_model, overwrite_output_dir = True, remove_unused_columns = False, warmup_steps = 1000, # number of warmup steps for learning rate +# save_steps = (len(train_sentences)/(args.batch_size * args.gradient_accumulation_steps)) / 1368, save_total_limit = args.num_epochs, load_best_model_at_end = True, weight_decay = 0.01, # strength of weight decay @@ -127,6 +134,8 @@ trainer = Trainer( eval_dataset = eval_dataset ) +# trainer.add_callback(CustomCallback(trainer)) + # Freeze layers in the classifier if desired if args.freeze_layers != '': layers_to_freeze = args.freeze_layers.split(';') @@ -142,82 +151,18 @@ if args.freeze_layers != '': print('Start training...') trainer.train() - -#======================================================== - -# =============== -# Dataset class -# =============== - -class Pytorch_Dataset(torch.utils.data.Dataset): - - def __init__(self, sentences): - - self.labels = [sent[-1] for sent in sentences] - self.texts = [tokenizer(sent[-2], - is_split_into_words=True, - padding='max_length', - max_length = 512, - truncation=True, - return_tensors="pt") - for sent in sentences] - - def classes(self): - return self.labels - - def __len__(self): - return len(self.labels) - - def get_batch_labels(self, idx): - # Fetch a batch of labels - return np.array(self.labels[idx]) - - def get_batch_texts(self, idx): - # Fetch a batch of inputs - return self.texts[idx] - - def __getitem__(self, idx): - - batch_texts = self.get_batch_texts(idx) - batch_y = self.get_batch_labels(idx) - - return batch_texts, batch_y - -# =============== -# Load datasets -# =============== - -# make train/dev datasets -dev_dataset = {corpus: Pytorch_Dataset(s) for corpus, s in dev_dict_sentences.items()} -test_dataset = {corpus: Pytorch_Dataset(s) for corpus, s in test_dict_sentences.items()} - -# Make dasets with batches and dataloader -dev_dict_dataloader = {corpus: DataLoader(dev_data, batch_size) - for corpus, dev_data in dev_dataset.items()} -test_dict_dataloader = {corpus: DataLoader(test_data, batch_size) - for corpus, test_data in test_dataset.items()} - # Dev results print('\nDev results:') -for corpus in dev_dict_dataloader: - dev_labels, dev_results = get_better_predictions(model, - corpus, - dev_dict_dataloader[corpus], - framework_labels[corpus.split('.')[1]] - ) - - - old_results = get_predictions(model, - corpus, - dev_dict_dataloader[corpus]) - - print('new:', print_better_accuracies(dev_labels, dev_results)) +for corpus in encoded_dev_dataset: + print() + dev_results = get_predictions_huggingface(trainer, corpus, + encoded_dev_dataset[corpus]) -# path_results = 'results/dev/' + args.transformer_model + '_' + str(args.num_epochs) -# if not os.path.exists(path_results): -# os.makedirs(path_results) + path_results = 'results/dev/' + args.transformer_model + '_' + str(args.num_epochs) + if not os.path.exists(path_results): + os.makedirs(path_results) # print_results_to_file(corpus, # dev_dict_sentences[corpus], @@ -236,9 +181,9 @@ for corpus in encoded_test_dataset: encoded_test_dataset[corpus]) -# path_results = 'results/test/' + args.transformer_model + '_' + str(args.num_epochs) -# if not os.path.exists(path_results): -# os.makedirs(path_results) + path_results = 'results/test/' + args.transformer_model + '_' + str(args.num_epochs) + if not os.path.exists(path_results): + os.makedirs(path_results) # print_results_to_file(corpus, # test_dict_sentences[corpus], diff --git a/classifier_bare_pytorch.py b/classifier_bare_pytorch.py index d5ee93c..b1ee85a 100644 --- a/classifier_bare_pytorch.py +++ b/classifier_bare_pytorch.py @@ -26,6 +26,7 @@ substitutions_file = 'mappings/substitutions.txt' # mapping_classes = args.mappings_file[:-4].split('-')[-1] # specific_results = open_specific_results('mappings/specific_results.txt')['B'] +print('ZERO-SHOT LANG: '+ args.langs_to_use) set_seed(42) torch.manual_seed(42) @@ -79,6 +80,8 @@ tokenizer = AutoTokenizer.from_pretrained(args.transformer_model) train_sentences, dev_dict_sentences, test_dict_sentences, framework_labels = open_sentences(args.data_path, mappings) + +print(framework_labels, flush=True) # Determine linear size (= number of classes in the sets + 1) num_labels = len(set(sent[-1] for sent in train_sentences)) + 1 @@ -212,13 +215,17 @@ def train(model, # Dev and test results for each corpus. We don't need to save the results. for corpus in dev_dict_dataloader: - dev_results = get_predictions(model, - corpus, - dev_dict_dataloader[corpus]) - better_dev_results = get_better_predictions(model, + dev_results = get_predictions( + model, corpus, - dev_dict_dataloader[corpus], - framework_labels) + dev_dict_dataloader[corpus] + ) + better_dev_results = get_better_predictions( + model, + corpus, + dev_dict_dataloader[corpus], + framework_labels[corpus.split('.')[1]] + ) # path_results = 'results/dev/language_' + mapping_classes + '_' + str(epoch_num+1) # if not os.path.exists(path_results): @@ -244,7 +251,7 @@ def train(model, model, corpus, test_dict_dataloader[corpus], - framework_labels + framework_labels[corpus.split('.')[1]] ) # path_results = 'results/test/language_' + mapping_classes + '_' + str(epoch_num+1) @@ -290,35 +297,3 @@ train(model, ) print('\nTraining Done!') - -# ------- Testing --------- - -# print('Testing...') - - -# for corpus in dev_dict_dataloader: -# dev_labels, dev_results = get_better_predictions(model, -# corpus, -# dev_dict_dataloader[corpus], -# framework_labels[corpus.split('.')[1]] -# ) - - -# old_results = get_predictions(model, -# corpus, -# dev_dict_dataloader[corpus]) - - -# print_results_to_file(corpus, - - -# for corpus in test_dict_dataloader: -# test_results = get_predictions(model, -# corpus, -# test_dict_dataloader[corpus] -# ) -# print_results_to_file(corpus, -# test_dict_sentences[corpus], -# test_results, -# inv_mappings, -# substitutions_file) \ No newline at end of file diff --git a/get_mappings_all_sets.py b/get_mappings_all_sets.py deleted file mode 100644 index 31f4607..0000000 --- a/get_mappings_all_sets.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -import os -from configure import parse_args -from utils import * - -args = parse_args() - -corpora = args.langs_to_use.split(';') - -files = ['data/'+folder+'/'+f for folder in os.listdir('data') - for f in os.listdir('data/' + folder) - if f.endswith('.rels') - if any(x in f for x in corpora)] - -# open substitutions per file -subs = {} -with open(substitutions_file, 'r', encoding='utf-8') as f: - next(f) - for line in f: - l = line.strip().split('\t') - if not l[1] in revert_substitutions: - subs[l[1]] = {} - subs[l[1]][l[0]] = l[2] - - -def read_file(file): - ''' Open the .rels file. ''' - lines = [] - - with open(file, 'r', encoding='utf-8') as f: - next(f) - for line in f: - if not "__" in line: # avoid files with underscores - l = line.strip().split('\t') - if l[11].lower() in replacements: - l[11] = replacements[l[11].lower()] - lines.append([l[3].split(' ') + ['[SEP]'] + l[4].split(' '), - l[9], l[11].lower()]) - return lines - - -train_files = [f for f in files if 'train' in f] -dev_files = [f for f in files if 'dev' in f] -test_files = [f for f in files if 'test' in f] - - -train_sentences = [] -for f in train_files: - temp = read_file(f) - if temp != []: - train_sentences += temp - -dev_sentences = [] -for f in dev_files: - temp = read_file(f) - if temp != []: - dev_sentences += temp - -test_sentences = [] -for f in dev_files: - temp = read_file(f) - if temp != []: - test_sentences += temp - - - -list_labels = list(set( [x[-1] for x in train_sentences] + - [x[-1] for x in dev_sentences] + - [x[-1] for x in test_sentences])) - -dict_labels = dict(enumerate(list_labels)) -inv_labels = {v: str(k) for k, v in dict_labels.items()} - -# add the replacements as well! -for r in replacements: - inv_labels[r] = inv_labels[replacements[r]] - -with open('mappings.tsv', 'w') as f: - for k, v in inv_labels.items(): - f.write(k + '\t' + str(v) + '\n') \ No newline at end of file diff --git a/make-mappings.ipynb b/make-mappings.ipynb deleted file mode 100644 index 28de5ef..0000000 --- a/make-mappings.ipynb +++ /dev/null @@ -1,260 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 44, - "metadata": {}, - "outputs": [], - "source": [ - "import os, io\n", - "import torch\n", - "from transformers import AutoConfig, AutoTokenizer\n", - "import numpy as np\n", - "from sklearn.metrics import accuracy_score" - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": {}, - "outputs": [], - "source": [ - "filename = 'eng.explicit.train.rels'" - ] - }, - { - "cell_type": "code", - "execution_count": 46, - "metadata": {}, - "outputs": [], - "source": [ - "def open_mappings(mappings_file):\n", - " \n", - " ''' Open the mappings file into a dictionary.'''\n", - " \n", - " mappings = {}\n", - " with open(mappings_file, 'r') as f:\n", - " next(f)\n", - " for l in f:\n", - " mappings[l.split('\\t')[0]] = int(l.strip().split('\\t')[-1])\n", - " inv_mappings = {v:k for k, v in mappings.items()}\n", - "\n", - " return mappings, inv_mappings\n", - "\n", - "\n", - "def open_file(filename, mappings_dict, normalize_direction='yes'): \n", - " \n", - " ''' Function to open a .rels file. \n", - " Arguments: \n", - " - filename: the path to a .rels file \n", - " - mappings_dict: a dictionary of mappings of unique labels to integers\n", - " Returns a list of lists, where each list is:\n", - " the line + [two sentences combined with special BERT token, encoded label]\n", - " '''\n", - " \n", - " max_len = 254 # 512 (max bert len) / 2 (2 sents) -2 (special tokens)\n", - " lines = []\n", - " SEP_token = '[SEP]'\n", - "\n", - " with open(filename, 'r', encoding='utf-8') as f:\n", - " next(f)\n", - " for line in f:\n", - " l = line.strip().split('\\t')\n", - " \n", - " if len(l) > 1:\n", - " # chop the sentences to max_len if too long\n", - " sent_1 = l[3].split(' ')\n", - " sent_2 = l[4].split(' ') \n", - " \n", - " if len(sent_1) > max_len:\n", - " sent_1 = sent_1[:max_len]\n", - " if len(sent_2) > max_len:\n", - " sent_2 = sent_2[:max_len]\n", - " \n", - " # flip them if different direction\n", - " if normalize_direction == 'yes':\n", - " if l[9] == '1>2':\n", - " lines.append(l + [sent_1 + [SEP_token] + sent_2, mappings_dict[l[11].lower()]])\n", - " else:\n", - " lines.append(l + [sent_2 + [SEP_token] + sent_1, mappings_dict[l[11].lower()]])\n", - " else:\n", - " lines.append(l + [sent_1 + [SEP_token] + sent_2, mappings[l[11].lower()]])\n", - "\n", - " return lines" - ] - }, - { - "cell_type": "code", - "execution_count": 47, - "metadata": {}, - "outputs": [], - "source": [ - "mappings, inv_mappings = open_mappings('mappings/mappings_substitutions.tsv')" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['expansion.conjunction', 'expansion.level-of-detail', 'expansion.instantiation', 'contingency.cause', 'expansion.substitution', 'comparison.contrast', 'temporal.asynchronous', 'comparison.similarity', 'contingency.condition', 'contingency.purpose', 'expansion.manner', 'temporal.synchronous', 'contingency.negative-condition', 'expansion.exception', 'comparison.concession', 'contingency.condition+speechact', 'contingency.cause+speechact', 'expansion.disjunction', 'contingency.cause+belief']\n" - ] - } - ], - "source": [ - "lines = open_file('imp-exp/' + filename, mappings)\n", - "present_labels = list(set([x[11].lower() for x in lines]))\n", - "print(present_labels)" - ] - }, - { - "cell_type": "code", - "execution_count": 49, - "metadata": {}, - "outputs": [], - "source": [ - "subs = {\"alternation\": \"expansion.alternative\", \n", - " \"alternative\": \"expansion.alternative\", \n", - " \"bg-general\": \"background\", \n", - " \"causation\": \"cause\", \"clarification_question\": \"q_elab\",\n", - " \"conditional\": \"condition\", \"conjunction\": \"expansion.conjunction\",\n", - " \"correction\": \"expansion.correction\", \"disjunction\": \"expansion.disjunction\", \n", - " \"evidence\": \"explanation-evidence\", \"exp-evidence\": \"explanation-evidence\", \n", - " \"goal\": \"purpose-goal\", \"joint-disjunction\": \"expansion.disjunction\",\n", - " \"justify\": \"explanation-justify\", \"list\": \"joint-list\", \n", - " \"mode-manner\": \"manner-means\", \"motivation\": \"explanation-motivation\", \n", - " \"motivation\": \"explanation-motivation\", \"otherwise\": \"adversative\", \n", - " \"repetition\": \"restatement-repetition\", \"restatement\": \"expansion.restatement\", \n", - " \"sequence\": \"joint-sequence\", \"temporal.synchrony\": \"temporal.synchronous\", \n", - " \"textual-organization\": \"organization\", \"unconditional\": \"expansion.disjunction\", \n", - " \"unless\": \"contrast\", \n", - " \"expansion.genexpansion\": \"expansion\", \n", - " \"cause-result\" : 'cause-effect', \n", - " \"qap\": \"question_answer_pair\", \n", - " \"contingency.negative-condition+speechact\": 'contingency', \n", - " \"contingency.negative\" : 'contingency', \n", - " \"expansion.genexpansion\" : 'expansion', \n", - " \"expansion.level\" : 'expansion', \n", - " \"qap.hypophora\": 'hypophora', \n", - " \"findings\" : 'result'\n", - " \n", - " }" - ] - }, - { - "cell_type": "code", - "execution_count": 50, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['expansion.conjunction', 'expansion.level-of-detail', 'expansion.instantiation', 'contingency.cause', 'expansion.substitution', 'comparison.contrast', 'temporal.asynchronous', 'comparison.similarity', 'contingency.condition', 'contingency.purpose']\n" - ] - } - ], - "source": [ - "# correct order\n", - "for l in mappings:\n", - " if l not in present_labels:\n", - " present_labels.append(l)\n", - "print(present_labels[:10])" - ] - }, - { - "cell_type": "code", - "execution_count": 51, - "metadata": {}, - "outputs": [], - "source": [ - "# make substitutions\n", - "\n", - "temp = []\n", - "for l in present_labels:\n", - " if l in subs:\n", - " temp.append(subs[l])\n", - " else:\n", - " temp.append(l)\n", - "\n", - "temp2 = []\n", - "for l in temp:\n", - " if not l in temp2:\n", - " temp2.append(l)" - ] - }, - { - "cell_type": "code", - "execution_count": 52, - "metadata": {}, - "outputs": [], - "source": [ - "new_mappings = dict(enumerate(temp2))\n", - "new_mappings = {v:k for k, v in new_mappings.items()}\n", - "\n", - "for l in present_labels:\n", - " if l not in new_mappings:\n", - " new_mappings[l] = new_mappings[subs[l]]" - ] - }, - { - "cell_type": "code", - "execution_count": 53, - "metadata": {}, - "outputs": [], - "source": [ - "assert len(new_mappings) == len(mappings)" - ] - }, - { - "cell_type": "code", - "execution_count": 54, - "metadata": {}, - "outputs": [], - "source": [ - "with open('imp-exp/mappings_' + filename[:-5].replace('.', '-') + '.tsv', 'w') as f:\n", - " for k, v in new_mappings.items():\n", - " f.write(k + '\\t' + str(v) + '\\n')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.7" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/make_mappings_zero-shot.py b/make_mappings_zero-shot.py new file mode 100644 index 0000000..14b05a6 --- /dev/null +++ b/make_mappings_zero-shot.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python +# coding: utf-8 + +import os +from configure import parse_args +from utils import * + +args = parse_args() + + +# ----------------------------------- +# open substitutions per file +mappings = {} +with open('mappings/mappings_substitutions.tsv', 'r', encoding='utf-8') as f: + next(f) + for line in f: + l = line.strip().split('\t') + mappings[l[0]] = l[1] + + +# find the labels that were changed +inv_mappings = {} +subs = {} +for label, num in mappings.items(): + if not num in inv_mappings: + inv_mappings[num] = label + else: + subs[label] = inv_mappings[num] + + +# ----------------------------------- +# define which language to NOT use with the arguments +not_language = args.langs_to_use + + +corpora = [folder for folder in os.listdir(args.data_path) + if not not_language in folder] + +files = ['/'.join([args.data_path, corpus, f]) + for corpus in corpora + for f in os.listdir(args.data_path + '/' + corpus) + ] + +# open the files +def read_file(file): + ''' Open the relations file. ''' + relations = [] + + with open(file, 'r', encoding='utf-8') as f: + next(f) + for line in f: + try: + l = line.strip().split('\t') + if not l[11].lower() in subs: + relations.append(l[11].lower()) + except IndexError: + pass + return relations + + +rel_files = [f for f in files if any (x in f for x in ['train', 'test', 'dev'])] + +rels = [] +for f in rel_files: + temp = read_file(f) + if temp != []: + rels += temp + +dict_labels = dict(enumerate(list(set(rels)))) +inv_labels = {v:k for k, v in dict_labels.items()} + +leftovers = [] +for sub in subs: + if sub not in inv_labels: + try: + inv_labels[sub] = inv_labels[subs[sub]] + except KeyError: + leftovers.append(sub) + else: + leftovers.append(sub) +for mapping in mappings: + if mapping not in inv_labels: + leftovers.append(mapping) + +counter = len(inv_labels) -1 +for i in leftovers: + counter += 1 + inv_labels[i] = counter + + + +# # save the new labels +print('-'*20) +print(not_language) +print(len(inv_labels)) + + + +with open('mappings/zero-shot/' + not_language + '_zero-shot.tsv', 'w') as f: + f.write('LABEL\tMAPPING\n') + for k, v in inv_labels.items(): + f.write(k + '\t' + str(v) + '\n') \ No newline at end of file diff --git a/mappings/zero-shot/deu_zero-shot.tsv b/mappings/zero-shot/deu_zero-shot.tsv new file mode 100644 index 0000000..29ebc0e --- /dev/null +++ b/mappings/zero-shot/deu_zero-shot.tsv @@ -0,0 +1,164 @@ +LABEL MAPPING +evaluation 0 +comparison.similarity 1 +contingency.goal 2 +interrupted 3 +enablement 4 +mode 5 +temporal.synchronous 6 +expansion.substitution 7 +expansion.exception 8 +contingency.negative-condition+speechact 9 +interpretation-evaluation 10 +restatement-partial 11 +contingency.negative-condition 12 +joint-other 13 +manner-means 14 +temporal 15 +preparation 16 +adversative-antithesis 17 +adversative-concession 18 +expansion.disjunction 19 +comparison.concession+speechact 20 +elab-process_step 21 +restatement-repetition 22 +parenthetical 23 +circumstance 24 +contingency.cause+belief 25 +contingency.purpose 26 +explanation-evidence 27 +organization-preparation 28 +conjunction 29 +cause-effect 30 +interpretation 31 +purpose-attribute 32 +causal-cause 33 +temploc 34 +parallel 35 +joint-sequence 36 +evaluation-comment 37 +progression 38 +comparison.contrast 39 +topic-comment 40 +expansion.restatement 41 +q_elab 42 +antithesis 43 +topic-drift 44 +bg-compare 45 +context-background 46 +organization-phatic 47 +clarification_question 48 +contingency.negative-cause 49 +root 50 +attribution 51 +topic-solutionhood 52 +mode-manner 53 +explanation-justify 54 +organization-heading 55 +attribution-positive 56 +contrast 57 +contingency.cause 58 +contingency.condition 59 +joint 60 +elaboration-attribute 61 +restatement-mn 62 +topic-question 63 +continuation 64 +expansion.manner 65 +causal 66 +organization 67 +bg-goal 68 +narration 69 +contingency-condition 70 +mode-means 71 +elab-addition 72 +adversative 73 +effect 74 +expansion.alternative 75 +nonvolitional-result-e 76 +elab-definition 77 +hypophora 78 +volitional-result 79 +concession 80 +expansion.correction 81 +comparison.degree 82 +comparison.concession 83 +result 84 +expansion.equivalence 85 +elaboration-additional 86 +purpose-goal 87 +elaboration 88 +nonvolitional-cause 89 +exp-reason 90 +explanation-motivation 91 +question_answer_pair 92 +contingency.condition+speechact 93 +conclusion 94 +explanation* 95 +contingency 96 +contingency.negative 97 +attribution-negative 98 +cause 99 +topic 100 +contingency.cause+speechact 101 +comparison 102 +volitional-cause 103 +purpose 104 +flashback 105 +context-circumstance 106 +background 107 +elab-aspect 108 +nonvolitional-cause-e 109 +elab-example 110 +temporal.asynchronous 111 +condition 112 +expansion 113 +adversative-contrast 114 +expansion.instantiation 115 +joint-list 116 +acknowledgement 117 +frame 118 +summary 119 +causal-result 120 +expansion.level-of-detail 121 +means 122 +explanation 123 +elab-enumember 124 +nonvolitional-result 125 +context 126 +e-elaboration 127 +solutionhood 128 +comment 129 +topic-change 130 +expansion.conjunction 29 +alternation 75 +conditional 112 +goal 87 +correction 81 +alternative 75 +disjunction 19 +evidence 27 +justify 54 +list 116 +motivation 91 +restatement 41 +sequence 36 +unless 57 +causation 99 +bg-general 107 +exp-evidence 27 +otherwise 73 +unconditional 19 +joint-disjunction 19 +repetition 22 +temporal.synchrony 6 +textual-organization 67 +cause-result 30 +findings 84 +qap 92 +expansion.level 121 +qap.hypophora 78 +expansion.genexpansion 113 +evaluation-n 160 +reason 161 +evaluation-s 162 diff --git a/mappings/zero-shot/eng_zero-shot.tsv b/mappings/zero-shot/eng_zero-shot.tsv new file mode 100644 index 0000000..42041e9 --- /dev/null +++ b/mappings/zero-shot/eng_zero-shot.tsv @@ -0,0 +1,164 @@ +LABEL MAPPING +adversative-concession 0 +expansion.equivalence 1 +summary 2 +temporal.synchronous 3 +context-background 4 +topic-change 5 +comparison.degree 6 +contingency.cause 7 +explanation-motivation 8 +background 9 +elab-addition 10 +continuation 11 +organization-preparation 12 +preparation 13 +topic-drift 14 +contingency.cause+belief 15 +contingency.goal 16 +reason 17 +attribution-negative 18 +purpose-attribute 19 +elab-enumember 20 +effect 21 +causal-cause 22 +restatement-repetition 23 +purpose-goal 24 +parallel 25 +topic-solutionhood 26 +temporal.asynchronous 27 +expansion.manner 28 +temporal 29 +volitional-result 30 +flashback 31 +evaluation 32 +context-circumstance 33 +expansion.restatement 34 +nonvolitional-result 35 +adversative-contrast 36 +expansion.level-of-detail 37 +narration 38 +adversative-antithesis 39 +mode-means 40 +restatement-mn 41 +interpretation 42 +expansion.exception 43 +expansion.alternative 44 +comment 45 +causal-result 46 +topic-question 47 +expansion 48 +elab-aspect 49 +elaboration 50 +joint-list 51 +evaluation-comment 52 +contingency.cause+speechact 53 +explanation-evidence 54 +elaboration-additional 55 +contingency.purpose 56 +bg-compare 57 +nonvolitional-result-e 58 +result 59 +exp-reason 60 +bg-goal 61 +nonvolitional-cause 62 +progression 63 +contingency.condition 64 +comparison.concession 65 +contingency-condition 66 +contingency.negative 67 +evaluation-n 68 +comparison 69 +contingency.negative-condition 70 +topic-comment 71 +expansion.disjunction 72 +cause 73 +temploc 74 +manner-means 75 +expansion.substitution 76 +joint 77 +elab-process_step 78 +volitional-cause 79 +joint-other 80 +nonvolitional-cause-e 81 +root 82 +mode-manner 83 +concession 84 +explanation-justify 85 +purpose 86 +elaboration-attribute 87 +contrast 88 +cause-effect 89 +conjunction 90 +frame 91 +solutionhood 92 +expansion.instantiation 93 +condition 94 +interrupted 95 +explanation* 96 +evaluation-s 97 +restatement-partial 98 +organization-phatic 99 +circumstance 100 +expansion.correction 101 +parenthetical 102 +antithesis 103 +comparison.similarity 104 +means 105 +e-elaboration 106 +organization-heading 107 +interpretation-evaluation 108 +contingency.negative-condition+speechact 109 +conclusion 110 +contingency.condition+speechact 111 +comparison.contrast 112 +joint-sequence 113 +enablement 114 +attribution-positive 115 +attribution 116 +explanation 117 +comparison.concession+speechact 118 +hypophora 119 +expansion.conjunction 90 +alternation 44 +conditional 94 +goal 24 +correction 101 +alternative 44 +disjunction 72 +evidence 54 +justify 85 +list 51 +motivation 8 +restatement 34 +sequence 113 +unless 88 +causation 73 +bg-general 9 +exp-evidence 54 +unconditional 72 +joint-disjunction 72 +repetition 23 +temporal.synchrony 3 +cause-result 89 +findings 59 +expansion.level 37 +qap.hypophora 119 +expansion.genexpansion 48 +otherwise 163 +textual-organization 164 +qap 165 +contingency.negative-cause 149 +organization 150 +causal 151 +mode 152 +clarification_question 153 +elab-definition 154 +adversative 155 +elab-example 156 +acknowledgement 157 +context 158 +topic 159 +question_answer_pair 160 +contingency 161 +q_elab 162 diff --git a/mappings/zero-shot/eus_zero-shot.tsv b/mappings/zero-shot/eus_zero-shot.tsv new file mode 100644 index 0000000..773bc7a --- /dev/null +++ b/mappings/zero-shot/eus_zero-shot.tsv @@ -0,0 +1,164 @@ +LABEL MAPPING +expansion.level-of-detail 0 +adversative-antithesis 1 +result 2 +temporal.asynchronous 3 +explanation-motivation 4 +attribution 5 +comparison.concession 6 +context-circumstance 7 +frame 8 +clarification_question 9 +condition 10 +interpretation-evaluation 11 +attribution-negative 12 +elab-example 13 +purpose-goal 14 +concession 15 +hypophora 16 +explanation-evidence 17 +contingency.negative 18 +elab-addition 19 +explanation-justify 20 +joint-other 21 +evaluation 22 +solutionhood 23 +restatement-partial 24 +contingency.goal 25 +background 26 +enablement 27 +topic-question 28 +temporal 29 +contingency.cause 30 +causal 31 +effect 32 +elab-enumember 33 +topic-solutionhood 34 +organization 35 +adversative-concession 36 +expansion.manner 37 +expansion.equivalence 38 +comparison.degree 39 +comparison.contrast 40 +interrupted 41 +expansion.instantiation 42 +conclusion 43 +organization-phatic 44 +manner-means 45 +nonvolitional-cause-e 46 +joint-sequence 47 +joint-list 48 +continuation 49 +reason 50 +progression 51 +expansion.disjunction 52 +elaboration 53 +causal-cause 54 +antithesis 55 +explanation 56 +means 57 +elab-aspect 58 +attribution-positive 59 +restatement-repetition 60 +joint 61 +contrast 62 +acknowledgement 63 +expansion.alternative 64 +contingency.cause+speechact 65 +contingency.condition 66 +evaluation-comment 67 +circumstance 68 +volitional-result 69 +question_answer_pair 70 +comparison.similarity 71 +purpose-attribute 72 +expansion.exception 73 +bg-goal 74 +preparation 75 +explanation* 76 +temporal.synchronous 77 +comment 78 +conjunction 79 +contingency 80 +mode-manner 81 +exp-reason 82 +contingency.cause+belief 83 +cause 84 +q_elab 85 +mode 86 +elaboration-attribute 87 +elab-definition 88 +e-elaboration 89 +expansion.correction 90 +parenthetical 91 +flashback 92 +interpretation 93 +comparison 94 +topic-comment 95 +evaluation-n 96 +temploc 97 +cause-effect 98 +adversative-contrast 99 +elab-process_step 100 +elaboration-additional 101 +contingency.condition+speechact 102 +bg-compare 103 +nonvolitional-result 104 +contingency-condition 105 +causal-result 106 +evaluation-s 107 +expansion.restatement 108 +contingency.purpose 109 +topic-change 110 +expansion 111 +context-background 112 +context 113 +topic-drift 114 +nonvolitional-cause 115 +contingency.negative-condition 116 +parallel 117 +topic 118 +organization-preparation 119 +organization-heading 120 +narration 121 +purpose 122 +mode-means 123 +volitional-cause 124 +contingency.negative-condition+speechact 125 +comparison.concession+speechact 126 +adversative 127 +expansion.substitution 128 +contingency.negative-cause 129 +root 130 +summary 131 +nonvolitional-result-e 132 +restatement-mn 133 +expansion.conjunction 79 +alternation 64 +conditional 10 +goal 14 +correction 90 +alternative 64 +disjunction 52 +evidence 17 +justify 20 +list 48 +motivation 4 +restatement 108 +sequence 47 +unless 62 +causation 84 +bg-general 26 +exp-evidence 17 +otherwise 127 +unconditional 52 +joint-disjunction 52 +repetition 60 +temporal.synchrony 77 +textual-organization 35 +cause-result 98 +findings 2 +qap 70 +expansion.level 0 +qap.hypophora 16 +expansion.genexpansion 111 diff --git a/mappings/zero-shot/fas_zero-shot.tsv b/mappings/zero-shot/fas_zero-shot.tsv new file mode 100644 index 0000000..7b936da --- /dev/null +++ b/mappings/zero-shot/fas_zero-shot.tsv @@ -0,0 +1,164 @@ +LABEL MAPPING +interpretation 0 +root 1 +summary 2 +organization 3 +contingency.goal 4 +topic-change 5 +bg-compare 6 +parallel 7 +attribution 8 +contingency.negative-cause 9 +evaluation-comment 10 +topic 11 +frame 12 +joint-other 13 +expansion.correction 14 +volitional-cause 15 +nonvolitional-result 16 +manner-means 17 +conclusion 18 +contingency.purpose 19 +background 20 +purpose-goal 21 +explanation 22 +adversative 23 +result 24 +expansion.disjunction 25 +elaboration-attribute 26 +temporal.synchronous 27 +clarification_question 28 +preparation 29 +causal-cause 30 +acknowledgement 31 +nonvolitional-cause-e 32 +nonvolitional-result-e 33 +comparison.concession 34 +parenthetical 35 +flashback 36 +elab-process_step 37 +contingency.negative 38 +contingency.cause 39 +elab-addition 40 +bg-goal 41 +purpose-attribute 42 +explanation-evidence 43 +context 44 +elaboration 45 +nonvolitional-cause 46 +elab-example 47 +mode 48 +antithesis 49 +q_elab 50 +expansion.equivalence 51 +contingency.cause+belief 52 +attribution-positive 53 +contingency.condition 54 +adversative-antithesis 55 +contingency.condition+speechact 56 +temploc 57 +cause-effect 58 +expansion 59 +organization-heading 60 +restatement-mn 61 +restatement-partial 62 +question_answer_pair 63 +adversative-contrast 64 +reason 65 +explanation-motivation 66 +expansion.exception 67 +topic-comment 68 +mode-means 69 +contingency 70 +contingency.cause+speechact 71 +elab-definition 72 +expansion.manner 73 +elab-enumember 74 +explanation* 75 +organization-phatic 76 +causal 77 +contingency.negative-condition+speechact 78 +effect 79 +purpose 80 +temporal 81 +organization-preparation 82 +topic-question 83 +solutionhood 84 +progression 85 +evaluation-n 86 +attribution-negative 87 +interpretation-evaluation 88 +comparison.degree 89 +condition 90 +e-elaboration 91 +circumstance 92 +comparison 93 +elab-aspect 94 +joint-sequence 95 +context-circumstance 96 +conjunction 97 +contrast 98 +elaboration-additional 99 +expansion.substitution 100 +continuation 101 +concession 102 +context-background 103 +expansion.restatement 104 +joint-list 105 +volitional-result 106 +expansion.level-of-detail 107 +hypophora 108 +evaluation-s 109 +evaluation 110 +causal-result 111 +enablement 112 +expansion.instantiation 113 +temporal.asynchronous 114 +means 115 +contingency.negative-condition 116 +expansion.alternative 117 +comment 118 +narration 119 +adversative-concession 120 +mode-manner 121 +restatement-repetition 122 +exp-reason 123 +comparison.similarity 124 +explanation-justify 125 +cause 126 +comparison.contrast 127 +comparison.concession+speechact 128 +interrupted 129 +joint 130 +contingency-condition 131 +topic-solutionhood 132 +expansion.conjunction 97 +alternation 117 +conditional 90 +goal 21 +correction 14 +alternative 117 +disjunction 25 +evidence 43 +justify 125 +list 105 +motivation 66 +restatement 104 +sequence 95 +unless 98 +causation 126 +bg-general 20 +exp-evidence 43 +otherwise 23 +unconditional 25 +joint-disjunction 25 +repetition 122 +temporal.synchrony 27 +textual-organization 3 +cause-result 58 +findings 24 +qap 63 +expansion.level 107 +qap.hypophora 108 +expansion.genexpansion 59 +topic-drift 162 diff --git a/mappings/zero-shot/fra_zero-shot.tsv b/mappings/zero-shot/fra_zero-shot.tsv new file mode 100644 index 0000000..2b08fee --- /dev/null +++ b/mappings/zero-shot/fra_zero-shot.tsv @@ -0,0 +1,164 @@ +LABEL MAPPING +preparation 0 +expansion.alternative 1 +expansion.substitution 2 +comparison.degree 3 +explanation-motivation 4 +interpretation 5 +adversative-contrast 6 +explanation-justify 7 +contingency.negative-condition+speechact 8 +antithesis 9 +organization-preparation 10 +evaluation-n 11 +attribution-positive 12 +contingency.condition 13 +evaluation-comment 14 +explanation 15 +joint-other 16 +expansion.restatement 17 +acknowledgement 18 +joint-list 19 +elab-addition 20 +elab-enumember 21 +restatement-repetition 22 +summary 23 +restatement-partial 24 +topic-comment 25 +contingency.cause+speechact 26 +means 27 +adversative-concession 28 +comparison.contrast 29 +narration 30 +organization 31 +joint-sequence 32 +contingency.negative-condition 33 +expansion.exception 34 +expansion.equivalence 35 +contingency 36 +temporal.synchronous 37 +attribution-negative 38 +nonvolitional-result-e 39 +explanation-evidence 40 +contingency.negative-cause 41 +topic-drift 42 +adversative 43 +attribution 44 +question_answer_pair 45 +contingency.cause 46 +reason 47 +nonvolitional-result 48 +context-circumstance 49 +contingency-condition 50 +elab-process_step 51 +elaboration 52 +elab-example 53 +context 54 +elab-aspect 55 +expansion.manner 56 +expansion.level-of-detail 57 +cause 58 +context-background 59 +topic-solutionhood 60 +comment 61 +mode-manner 62 +result 63 +mode-means 64 +condition 65 +volitional-cause 66 +circumstance 67 +elab-definition 68 +topic-question 69 +contingency.condition+speechact 70 +cause-effect 71 +conjunction 72 +temporal 73 +expansion.correction 74 +organization-heading 75 +purpose-goal 76 +organization-phatic 77 +nonvolitional-cause-e 78 +e-elaboration 79 +evaluation 80 +causal 81 +comparison.concession+speechact 82 +purpose-attribute 83 +volitional-result 84 +solutionhood 85 +evaluation-s 86 +enablement 87 +contingency.goal 88 +contingency.cause+belief 89 +purpose 90 +manner-means 91 +temporal.asynchronous 92 +expansion 93 +causal-result 94 +elaboration-attribute 95 +comparison.concession 96 +contingency.purpose 97 +contingency.negative 98 +concession 99 +progression 100 +bg-goal 101 +adversative-antithesis 102 +interrupted 103 +background 104 +effect 105 +parallel 106 +mode 107 +q_elab 108 +expansion.disjunction 109 +contrast 110 +nonvolitional-cause 111 +elaboration-additional 112 +comparison 113 +conclusion 114 +exp-reason 115 +interpretation-evaluation 116 +hypophora 117 +topic-change 118 +bg-compare 119 +causal-cause 120 +comparison.similarity 121 +topic 122 +joint 123 +restatement-mn 124 +parenthetical 125 +continuation 126 +root 127 +clarification_question 128 +expansion.instantiation 129 +expansion.conjunction 72 +alternation 1 +conditional 65 +goal 76 +correction 74 +alternative 1 +disjunction 109 +evidence 40 +justify 7 +list 19 +motivation 4 +restatement 17 +sequence 32 +unless 110 +causation 58 +bg-general 104 +exp-evidence 40 +otherwise 43 +unconditional 109 +joint-disjunction 109 +repetition 22 +temporal.synchrony 37 +textual-organization 31 +cause-result 71 +findings 63 +qap 45 +expansion.level 57 +qap.hypophora 117 +expansion.genexpansion 93 +explanation* 159 +flashback 160 +frame 161 +temploc 162 diff --git a/mappings/zero-shot/ita_zero-shot.tsv b/mappings/zero-shot/ita_zero-shot.tsv new file mode 100644 index 0000000..26a4810 --- /dev/null +++ b/mappings/zero-shot/ita_zero-shot.tsv @@ -0,0 +1,164 @@ +LABEL MAPPING +organization-heading 0 +adversative-concession 1 +root 2 +e-elaboration 3 +comparison.degree 4 +elab-definition 5 +comment 6 +causal-cause 7 +concession 8 +q_elab 9 +adversative-antithesis 10 +conjunction 11 +temporal.asynchronous 12 +volitional-cause 13 +summary 14 +attribution-negative 15 +cause 16 +result 17 +explanation-justify 18 +contingency.negative-cause 19 +nonvolitional-cause 20 +contrast 21 +expansion.substitution 22 +effect 23 +contingency.cause+speechact 24 +contingency.negative 25 +contingency.negative-condition+speechact 26 +attribution-positive 27 +temploc 28 +mode 29 +condition 30 +evaluation 31 +preparation 32 +expansion.instantiation 33 +explanation 34 +conclusion 35 +elab-process_step 36 +background 37 +evaluation-s 38 +joint-other 39 +context-circumstance 40 +topic-change 41 +parenthetical 42 +purpose-attribute 43 +topic-question 44 +contingency.cause+belief 45 +topic 46 +mode-means 47 +expansion.manner 48 +comparison.similarity 49 +cause-effect 50 +evaluation-n 51 +circumstance 52 +reason 53 +elab-aspect 54 +nonvolitional-result 55 +hypophora 56 +organization-preparation 57 +joint-list 58 +flashback 59 +elaboration 60 +progression 61 +purpose 62 +contingency.cause 63 +organization-phatic 64 +solutionhood 65 +expansion.level-of-detail 66 +continuation 67 +nonvolitional-result-e 68 +joint 69 +explanation-evidence 70 +restatement-partial 71 +comparison.concession+speechact 72 +contingency 73 +topic-comment 74 +temporal 75 +means 76 +expansion.disjunction 77 +causal 78 +contingency.condition+speechact 79 +contingency.negative-condition 80 +purpose-goal 81 +volitional-result 82 +question_answer_pair 83 +clarification_question 84 +elab-enumember 85 +enablement 86 +topic-drift 87 +explanation* 88 +elaboration-attribute 89 +elab-addition 90 +bg-compare 91 +organization 92 +context-background 93 +adversative 94 +comparison.contrast 95 +context 96 +frame 97 +parallel 98 +expansion 99 +manner-means 100 +comparison 101 +narration 102 +attribution 103 +interpretation 104 +expansion.exception 105 +nonvolitional-cause-e 106 +expansion.equivalence 107 +mode-manner 108 +explanation-motivation 109 +restatement-repetition 110 +contingency-condition 111 +acknowledgement 112 +antithesis 113 +elaboration-additional 114 +topic-solutionhood 115 +exp-reason 116 +contingency.purpose 117 +interpretation-evaluation 118 +causal-result 119 +evaluation-comment 120 +restatement-mn 121 +expansion.correction 122 +comparison.concession 123 +elab-example 124 +temporal.synchronous 125 +bg-goal 126 +contingency.condition 127 +adversative-contrast 128 +joint-sequence 129 +expansion.conjunction 11 +conditional 30 +goal 81 +correction 122 +disjunction 77 +evidence 70 +justify 18 +list 58 +motivation 109 +sequence 129 +unless 21 +causation 16 +bg-general 37 +exp-evidence 70 +otherwise 94 +unconditional 77 +joint-disjunction 77 +repetition 110 +temporal.synchrony 125 +textual-organization 92 +cause-result 50 +findings 17 +qap 83 +expansion.level 66 +qap.hypophora 56 +expansion.genexpansion 99 +alternation 163 +alternative 164 +restatement 165 +expansion.restatement 159 +interrupted 160 +expansion.alternative 161 +contingency.goal 162 diff --git a/mappings/zero-shot/nld_zero-shot.tsv b/mappings/zero-shot/nld_zero-shot.tsv new file mode 100644 index 0000000..b56f301 --- /dev/null +++ b/mappings/zero-shot/nld_zero-shot.tsv @@ -0,0 +1,164 @@ +LABEL MAPPING +interpretation 0 +contrast 1 +contingency.cause+speechact 2 +frame 3 +flashback 4 +expansion.correction 5 +contingency-condition 6 +context-circumstance 7 +contingency 8 +root 9 +evaluation-n 10 +topic-drift 11 +interpretation-evaluation 12 +explanation 13 +explanation* 14 +expansion.instantiation 15 +temporal.asynchronous 16 +causal 17 +causal-result 18 +preparation 19 +result 20 +means 21 +cause-effect 22 +clarification_question 23 +organization 24 +elaboration 25 +interrupted 26 +topic 27 +expansion.equivalence 28 +adversative-concession 29 +topic-question 30 +nonvolitional-cause 31 +acknowledgement 32 +evaluation 33 +attribution-positive 34 +explanation-motivation 35 +continuation 36 +enablement 37 +expansion.disjunction 38 +progression 39 +summary 40 +context-background 41 +concession 42 +contingency.negative-condition+speechact 43 +expansion 44 +bg-goal 45 +parallel 46 +expansion.level-of-detail 47 +contingency.cause 48 +bg-compare 49 +nonvolitional-result 50 +adversative-antithesis 51 +antithesis 52 +condition 53 +restatement-repetition 54 +cause 55 +comparison 56 +evaluation-comment 57 +elab-addition 58 +joint-list 59 +nonvolitional-cause-e 60 +manner-means 61 +narration 62 +adversative 63 +comparison.concession 64 +question_answer_pair 65 +expansion.exception 66 +explanation-evidence 67 +nonvolitional-result-e 68 +topic-solutionhood 69 +temporal 70 +expansion.restatement 71 +circumstance 72 +expansion.substitution 73 +contingency.negative 74 +organization-preparation 75 +adversative-contrast 76 +mode-means 77 +restatement-partial 78 +explanation-justify 79 +volitional-cause 80 +organization-phatic 81 +topic-change 82 +elaboration-attribute 83 +context 84 +contingency.cause+belief 85 +joint 86 +organization-heading 87 +joint-sequence 88 +purpose-goal 89 +conclusion 90 +comparison.similarity 91 +comparison.degree 92 +purpose-attribute 93 +mode 94 +topic-comment 95 +e-elaboration 96 +effect 97 +contingency.negative-cause 98 +expansion.alternative 99 +purpose 100 +mode-manner 101 +hypophora 102 +contingency.condition+speechact 103 +elab-process_step 104 +elaboration-additional 105 +contingency.negative-condition 106 +q_elab 107 +volitional-result 108 +conjunction 109 +reason 110 +comment 111 +parenthetical 112 +comparison.concession+speechact 113 +background 114 +contingency.purpose 115 +temporal.synchronous 116 +exp-reason 117 +attribution-negative 118 +expansion.manner 119 +elab-definition 120 +solutionhood 121 +elab-enumember 122 +evaluation-s 123 +temploc 124 +causal-cause 125 +contingency.goal 126 +elab-example 127 +elab-aspect 128 +attribution 129 +comparison.contrast 130 +contingency.condition 131 +joint-other 132 +expansion.conjunction 109 +alternation 99 +conditional 53 +goal 89 +correction 5 +alternative 99 +disjunction 38 +evidence 67 +justify 79 +list 59 +motivation 35 +restatement 71 +sequence 88 +unless 1 +causation 55 +bg-general 114 +exp-evidence 67 +otherwise 63 +unconditional 38 +joint-disjunction 38 +repetition 54 +temporal.synchrony 116 +textual-organization 24 +cause-result 22 +findings 20 +qap 65 +expansion.level 47 +qap.hypophora 102 +expansion.genexpansion 44 +restatement-mn 162 diff --git a/mappings/zero-shot/por_zero-shot.tsv b/mappings/zero-shot/por_zero-shot.tsv new file mode 100644 index 0000000..577bd59 --- /dev/null +++ b/mappings/zero-shot/por_zero-shot.tsv @@ -0,0 +1,164 @@ +LABEL MAPPING +background 0 +e-elaboration 1 +concession 2 +causal-cause 3 +elaboration-attribute 4 +frame 5 +expansion.manner 6 +contingency.cause+speechact 7 +explanation-motivation 8 +mode 9 +condition 10 +comparison 11 +result 12 +contingency.goal 13 +circumstance 14 +adversative-concession 15 +causal-result 16 +evaluation-s 17 +evaluation-n 18 +conjunction 19 +contingency.negative-condition 20 +exp-reason 21 +joint-other 22 +restatement-partial 23 +purpose-attribute 24 +contingency 25 +contingency.cause+belief 26 +comparison.similarity 27 +reason 28 +preparation 29 +means 30 +conclusion 31 +question_answer_pair 32 +explanation 33 +contingency-condition 34 +topic-question 35 +interpretation-evaluation 36 +expansion.alternative 37 +topic-comment 38 +contingency.condition 39 +adversative 40 +expansion.equivalence 41 +causal 42 +joint-list 43 +antithesis 44 +evaluation-comment 45 +comparison.concession 46 +interrupted 47 +contingency.negative-cause 48 +narration 49 +organization-heading 50 +effect 51 +elaboration-additional 52 +organization-preparation 53 +temploc 54 +acknowledgement 55 +topic-change 56 +temporal.synchronous 57 +comment 58 +elab-example 59 +organization-phatic 60 +solutionhood 61 +adversative-contrast 62 +evaluation 63 +joint 64 +summary 65 +mode-manner 66 +clarification_question 67 +comparison.degree 68 +expansion.instantiation 69 +manner-means 70 +interpretation 71 +topic-solutionhood 72 +restatement-repetition 73 +cause-effect 74 +topic 75 +contingency.condition+speechact 76 +cause 77 +enablement 78 +expansion.substitution 79 +elaboration 80 +contingency.purpose 81 +explanation-justify 82 +purpose 83 +elab-definition 84 +temporal 85 +organization 86 +flashback 87 +context-background 88 +contrast 89 +adversative-antithesis 90 +explanation-evidence 91 +contingency.negative-condition+speechact 92 +expansion.level-of-detail 93 +explanation* 94 +restatement-mn 95 +purpose-goal 96 +expansion.correction 97 +elab-process_step 98 +context-circumstance 99 +bg-compare 100 +expansion 101 +expansion.exception 102 +elab-enumember 103 +joint-sequence 104 +topic-drift 105 +volitional-result 106 +attribution-negative 107 +mode-means 108 +hypophora 109 +comparison.concession+speechact 110 +elab-aspect 111 +bg-goal 112 +temporal.asynchronous 113 +volitional-cause 114 +comparison.contrast 115 +nonvolitional-cause 116 +expansion.restatement 117 +q_elab 118 +contingency.cause 119 +context 120 +nonvolitional-result 121 +root 122 +parallel 123 +progression 124 +attribution-positive 125 +expansion.disjunction 126 +continuation 127 +attribution 128 +elab-addition 129 +expansion.conjunction 19 +alternation 37 +conditional 10 +goal 96 +correction 97 +alternative 37 +disjunction 126 +evidence 91 +justify 82 +list 43 +motivation 8 +restatement 117 +sequence 104 +unless 89 +causation 77 +bg-general 0 +exp-evidence 91 +otherwise 40 +unconditional 126 +joint-disjunction 126 +repetition 73 +temporal.synchrony 57 +textual-organization 86 +cause-result 74 +findings 12 +qap 32 +expansion.level 93 +qap.hypophora 109 +expansion.genexpansion 101 +parenthetical 159 +nonvolitional-result-e 160 +contingency.negative 161 +nonvolitional-cause-e 162 diff --git a/mappings/zero-shot/rus_zero-shot.tsv b/mappings/zero-shot/rus_zero-shot.tsv new file mode 100644 index 0000000..d5e15e5 --- /dev/null +++ b/mappings/zero-shot/rus_zero-shot.tsv @@ -0,0 +1,164 @@ +LABEL MAPPING +concession 0 +topic-question 1 +volitional-cause 2 +restatement-mn 3 +causal-cause 4 +contingency-condition 5 +comment 6 +solutionhood 7 +manner-means 8 +explanation-evidence 9 +expansion.restatement 10 +mode-means 11 +topic-drift 12 +explanation-motivation 13 +adversative-antithesis 14 +mode-manner 15 +comparison.concession 16 +attribution 17 +enablement 18 +causal-result 19 +comparison.concession+speechact 20 +contingency.condition 21 +organization-preparation 22 +volitional-result 23 +nonvolitional-result 24 +expansion.exception 25 +means 26 +joint-other 27 +expansion 28 +expansion.level-of-detail 29 +comparison 30 +elaboration-attribute 31 +contingency.negative-condition 32 +adversative-contrast 33 +continuation 34 +contingency.negative-cause 35 +q_elab 36 +evaluation-s 37 +bg-compare 38 +contingency.purpose 39 +antithesis 40 +joint-sequence 41 +contrast 42 +contingency.cause 43 +expansion.equivalence 44 +reason 45 +expansion.alternative 46 +topic 47 +bg-goal 48 +summary 49 +topic-change 50 +organization 51 +context-circumstance 52 +contingency.goal 53 +exp-reason 54 +expansion.manner 55 +elab-definition 56 +narration 57 +frame 58 +contingency.cause+speechact 59 +interpretation 60 +explanation* 61 +organization-phatic 62 +conclusion 63 +joint 64 +elab-example 65 +adversative 66 +conjunction 67 +cause 68 +attribution-negative 69 +restatement-partial 70 +causal 71 +context 72 +context-background 73 +e-elaboration 74 +elaboration-additional 75 +circumstance 76 +expansion.substitution 77 +nonvolitional-cause 78 +nonvolitional-result-e 79 +organization-heading 80 +mode 81 +explanation-justify 82 +clarification_question 83 +topic-comment 84 +temporal 85 +topic-solutionhood 86 +hypophora 87 +question_answer_pair 88 +elaboration 89 +elab-process_step 90 +contingency 91 +parallel 92 +purpose-attribute 93 +adversative-concession 94 +nonvolitional-cause-e 95 +background 96 +result 97 +root 98 +progression 99 +acknowledgement 100 +contingency.negative 101 +purpose 102 +comparison.similarity 103 +contingency.negative-condition+speechact 104 +preparation 105 +comparison.contrast 106 +temporal.synchronous 107 +contingency.condition+speechact 108 +evaluation 109 +elab-aspect 110 +elab-enumember 111 +temploc 112 +joint-list 113 +contingency.cause+belief 114 +expansion.instantiation 115 +evaluation-comment 116 +evaluation-n 117 +attribution-positive 118 +parenthetical 119 +restatement-repetition 120 +temporal.asynchronous 121 +expansion.disjunction 122 +comparison.degree 123 +explanation 124 +flashback 125 +interrupted 126 +purpose-goal 127 +expansion.correction 128 +elab-addition 129 +condition 130 +expansion.conjunction 67 +alternation 46 +conditional 130 +goal 127 +correction 128 +alternative 46 +disjunction 122 +evidence 9 +justify 82 +list 113 +motivation 13 +restatement 10 +sequence 41 +unless 42 +causation 68 +bg-general 96 +exp-evidence 9 +otherwise 66 +unconditional 122 +joint-disjunction 122 +repetition 120 +temporal.synchrony 107 +textual-organization 51 +findings 97 +qap 88 +expansion.level 29 +qap.hypophora 87 +expansion.genexpansion 28 +cause-result 163 +effect 160 +cause-effect 161 +interpretation-evaluation 162 diff --git a/mappings/zero-shot/spa_zero-shot.tsv b/mappings/zero-shot/spa_zero-shot.tsv new file mode 100644 index 0000000..0befd24 --- /dev/null +++ b/mappings/zero-shot/spa_zero-shot.tsv @@ -0,0 +1,164 @@ +LABEL MAPPING +mode-means 0 +nonvolitional-result 1 +comparison.contrast 2 +organization-preparation 3 +adversative-concession 4 +expansion.alternative 5 +background 6 +effect 7 +exp-reason 8 +expansion.disjunction 9 +cause-effect 10 +mode-manner 11 +clarification_question 12 +comparison.concession 13 +contingency 14 +contingency.cause 15 +contingency-condition 16 +conclusion 17 +comment 18 +means 19 +q_elab 20 +contingency.cause+belief 21 +evaluation-s 22 +question_answer_pair 23 +nonvolitional-result-e 24 +restatement-partial 25 +organization-phatic 26 +elaboration 27 +e-elaboration 28 +bg-goal 29 +adversative 30 +reason 31 +topic-solutionhood 32 +preparation 33 +hypophora 34 +comparison 35 +contingency.negative-condition+speechact 36 +enablement 37 +restatement-repetition 38 +parenthetical 39 +purpose-goal 40 +evaluation-comment 41 +explanation 42 +contingency.negative-cause 43 +expansion.manner 44 +explanation-justify 45 +conjunction 46 +comparison.degree 47 +expansion.correction 48 +explanation-evidence 49 +antithesis 50 +root 51 +elaboration-attribute 52 +attribution 53 +interpretation-evaluation 54 +adversative-contrast 55 +contingency.condition 56 +joint-other 57 +contingency.negative-condition 58 +evaluation-n 59 +contingency.cause+speechact 60 +circumstance 61 +contingency.condition+speechact 62 +purpose 63 +manner-means 64 +condition 65 +contrast 66 +elab-addition 67 +expansion.instantiation 68 +nonvolitional-cause 69 +joint-list 70 +acknowledgement 71 +nonvolitional-cause-e 72 +causal 73 +purpose-attribute 74 +bg-compare 75 +contingency.goal 76 +concession 77 +temporal 78 +temploc 79 +expansion.exception 80 +parallel 81 +temporal.synchronous 82 +adversative-antithesis 83 +joint-sequence 84 +causal-cause 85 +progression 86 +context-background 87 +solutionhood 88 +elab-definition 89 +elab-process_step 90 +elab-enumember 91 +expansion.level-of-detail 92 +contingency.purpose 93 +narration 94 +topic-comment 95 +continuation 96 +mode 97 +joint 98 +organization-heading 99 +explanation-motivation 100 +frame 101 +comparison.similarity 102 +elaboration-additional 103 +topic-drift 104 +organization 105 +volitional-cause 106 +volitional-result 107 +comparison.concession+speechact 108 +context 109 +elab-example 110 +explanation* 111 +elab-aspect 112 +evaluation 113 +summary 114 +expansion 115 +temporal.asynchronous 116 +result 117 +topic 118 +expansion.restatement 119 +cause 120 +contingency.negative 121 +interrupted 122 +interpretation 123 +restatement-mn 124 +causal-result 125 +attribution-negative 126 +expansion.equivalence 127 +topic-question 128 +flashback 129 +topic-change 130 +expansion.substitution 131 +context-circumstance 132 +attribution-positive 133 +expansion.conjunction 46 +alternation 5 +conditional 65 +goal 40 +correction 48 +alternative 5 +disjunction 9 +evidence 49 +justify 45 +list 70 +motivation 100 +restatement 119 +sequence 84 +unless 66 +causation 120 +bg-general 6 +exp-evidence 49 +otherwise 30 +unconditional 9 +joint-disjunction 9 +repetition 38 +temporal.synchrony 82 +textual-organization 105 +cause-result 10 +findings 117 +qap 23 +expansion.level 92 +qap.hypophora 34 +expansion.genexpansion 115 diff --git a/mappings/zero-shot/tha_zero-shot.tsv b/mappings/zero-shot/tha_zero-shot.tsv new file mode 100644 index 0000000..42819dd --- /dev/null +++ b/mappings/zero-shot/tha_zero-shot.tsv @@ -0,0 +1,164 @@ +LABEL MAPPING +expansion 0 +evaluation 1 +circumstance 2 +condition 3 +temporal 4 +flashback 5 +comparison.concession+speechact 6 +nonvolitional-cause-e 7 +bg-compare 8 +temploc 9 +contingency.goal 10 +context 11 +organization-phatic 12 +restatement-repetition 13 +explanation-motivation 14 +expansion.equivalence 15 +expansion.substitution 16 +contingency.condition+speechact 17 +enablement 18 +joint-other 19 +elab-example 20 +evaluation-n 21 +cause-effect 22 +adversative 23 +elaboration-additional 24 +evaluation-s 25 +mode 26 +volitional-result 27 +purpose 28 +organization 29 +purpose-goal 30 +causal-result 31 +conclusion 32 +contrast 33 +joint-list 34 +conjunction 35 +preparation 36 +contingency.purpose 37 +cause 38 +comment 39 +expansion.correction 40 +causal 41 +manner-means 42 +contingency 43 +background 44 +exp-reason 45 +parallel 46 +temporal.asynchronous 47 +topic-comment 48 +organization-preparation 49 +expansion.restatement 50 +expansion.alternative 51 +antithesis 52 +contingency.cause+belief 53 +contingency.cause 54 +explanation-justify 55 +comparison.similarity 56 +interrupted 57 +e-elaboration 58 +elab-process_step 59 +adversative-concession 60 +nonvolitional-result-e 61 +comparison.degree 62 +topic-question 63 +question_answer_pair 64 +explanation-evidence 65 +mode-means 66 +contingency.cause+speechact 67 +continuation 68 +acknowledgement 69 +solutionhood 70 +elaboration 71 +contingency.negative 72 +joint 73 +explanation* 74 +topic 75 +expansion.disjunction 76 +attribution-positive 77 +result 78 +elab-aspect 79 +interpretation 80 +root 81 +joint-sequence 82 +attribution-negative 83 +bg-goal 84 +q_elab 85 +expansion.exception 86 +context-background 87 +concession 88 +topic-change 89 +elaboration-attribute 90 +contingency.condition 91 +adversative-contrast 92 +comparison 93 +nonvolitional-result 94 +expansion.manner 95 +means 96 +interpretation-evaluation 97 +mode-manner 98 +elab-definition 99 +organization-heading 100 +contingency-condition 101 +elab-addition 102 +comparison.contrast 103 +volitional-cause 104 +attribution 105 +expansion.instantiation 106 +topic-drift 107 +reason 108 +evaluation-comment 109 +expansion.level-of-detail 110 +context-circumstance 111 +contingency.negative-condition 112 +elab-enumember 113 +hypophora 114 +purpose-attribute 115 +restatement-partial 116 +frame 117 +nonvolitional-cause 118 +temporal.synchronous 119 +adversative-antithesis 120 +contingency.negative-cause 121 +restatement-mn 122 +progression 123 +explanation 124 +summary 125 +effect 126 +narration 127 +parenthetical 128 +clarification_question 129 +topic-solutionhood 130 +causal-cause 131 +comparison.concession 132 +expansion.conjunction 35 +alternation 51 +conditional 3 +goal 30 +correction 40 +alternative 51 +disjunction 76 +evidence 65 +justify 55 +list 34 +motivation 14 +restatement 50 +sequence 82 +unless 33 +causation 38 +bg-general 44 +exp-evidence 65 +otherwise 23 +unconditional 76 +joint-disjunction 76 +repetition 13 +temporal.synchrony 119 +textual-organization 29 +cause-result 22 +findings 78 +qap 64 +expansion.level 110 +qap.hypophora 114 +expansion.genexpansion 0 +contingency.negative-condition+speechact 162 diff --git a/mappings/zero-shot/tur_zero-shot.tsv b/mappings/zero-shot/tur_zero-shot.tsv new file mode 100644 index 0000000..277e5c0 --- /dev/null +++ b/mappings/zero-shot/tur_zero-shot.tsv @@ -0,0 +1,164 @@ +LABEL MAPPING +organization-heading 0 +circumstance 1 +antithesis 2 +elab-aspect 3 +elab-addition 4 +restatement-mn 5 +adversative-antithesis 6 +clarification_question 7 +elaboration-attribute 8 +contingency.cause 9 +comparison.concession+speechact 10 +interrupted 11 +enablement 12 +manner-means 13 +flashback 14 +cause 15 +organization 16 +joint 17 +purpose-attribute 18 +elaboration-additional 19 +frame 20 +exp-reason 21 +volitional-cause 22 +adversative-contrast 23 +joint-sequence 24 +elab-example 25 +joint-list 26 +preparation 27 +contingency.negative-cause 28 +topic-drift 29 +nonvolitional-result-e 30 +expansion.exception 31 +expansion.equivalence 32 +contingency-condition 33 +progression 34 +nonvolitional-cause-e 35 +contingency.negative-condition+speechact 36 +attribution-negative 37 +q_elab 38 +reason 39 +mode-means 40 +parallel 41 +background 42 +interpretation 43 +contrast 44 +elab-enumember 45 +bg-compare 46 +temporal.synchronous 47 +acknowledgement 48 +comparison 49 +expansion.manner 50 +cause-effect 51 +parenthetical 52 +topic-comment 53 +temporal 54 +contingency.cause+speechact 55 +purpose 56 +causal-result 57 +conclusion 58 +result 59 +summary 60 +restatement-repetition 61 +e-elaboration 62 +context-background 63 +solutionhood 64 +expansion 65 +temploc 66 +organization-preparation 67 +evaluation-n 68 +expansion.substitution 69 +restatement-partial 70 +topic-question 71 +topic-solutionhood 72 +comparison.contrast 73 +narration 74 +explanation-justify 75 +bg-goal 76 +temporal.asynchronous 77 +comment 78 +context-circumstance 79 +comparison.similarity 80 +topic 81 +explanation-motivation 82 +expansion.restatement 83 +contingency.purpose 84 +nonvolitional-result 85 +context 86 +concession 87 +evaluation-s 88 +condition 89 +topic-change 90 +causal-cause 91 +expansion.level-of-detail 92 +mode-manner 93 +continuation 94 +elab-process_step 95 +purpose-goal 96 +contingency.negative 97 +contingency.cause+belief 98 +contingency.condition 99 +means 100 +contingency.condition+speechact 101 +hypophora 102 +adversative-concession 103 +causal 104 +contingency.negative-condition 105 +explanation-evidence 106 +evaluation 107 +expansion.instantiation 108 +explanation* 109 +comparison.concession 110 +elaboration 111 +volitional-result 112 +conjunction 113 +question_answer_pair 114 +adversative 115 +interpretation-evaluation 116 +attribution-positive 117 +nonvolitional-cause 118 +mode 119 +expansion.alternative 120 +expansion.disjunction 121 +elab-definition 122 +explanation 123 +contingency.goal 124 +organization-phatic 125 +root 126 +evaluation-comment 127 +joint-other 128 +attribution 129 +contingency 130 +effect 131 +expansion.conjunction 113 +alternation 120 +conditional 89 +goal 96 +alternative 120 +disjunction 121 +evidence 106 +justify 75 +list 26 +motivation 82 +restatement 83 +sequence 24 +unless 44 +causation 15 +bg-general 42 +exp-evidence 106 +otherwise 115 +unconditional 121 +joint-disjunction 121 +repetition 61 +temporal.synchrony 47 +textual-organization 16 +cause-result 51 +findings 59 +qap 114 +expansion.level 92 +qap.hypophora 102 +expansion.genexpansion 65 +correction 163 +expansion.correction 161 +comparison.degree 162 diff --git a/mappings/zero-shot/zho_zero-shot.tsv b/mappings/zero-shot/zho_zero-shot.tsv new file mode 100644 index 0000000..3d01617 --- /dev/null +++ b/mappings/zero-shot/zho_zero-shot.tsv @@ -0,0 +1,164 @@ +LABEL MAPPING +elaboration 0 +comparison.concession 1 +expansion.substitution 2 +nonvolitional-result-e 3 +conjunction 4 +contingency.negative 5 +expansion.level-of-detail 6 +nonvolitional-cause 7 +condition 8 +purpose 9 +comparison.concession+speechact 10 +effect 11 +contingency 12 +bg-compare 13 +expansion.alternative 14 +expansion.exception 15 +explanation 16 +temporal 17 +cause 18 +background 19 +q_elab 20 +evaluation-n 21 +solutionhood 22 +summary 23 +joint 24 +comment 25 +evaluation-s 26 +volitional-result 27 +contingency.negative-cause 28 +explanation* 29 +contrast 30 +interpretation 31 +elab-aspect 32 +expansion.manner 33 +result 34 +elab-process_step 35 +comparison.contrast 36 +expansion.correction 37 +means 38 +contingency.goal 39 +question_answer_pair 40 +expansion.instantiation 41 +clarification_question 42 +elab-addition 43 +contingency.purpose 44 +contingency.negative-condition+speechact 45 +temporal.synchronous 46 +organization 47 +causal 48 +comparison 49 +nonvolitional-cause-e 50 +contingency.condition+speechact 51 +nonvolitional-result 52 +contingency.cause 53 +expansion.equivalence 54 +topic-change 55 +concession 56 +parenthetical 57 +topic-drift 58 +topic-comment 59 +parallel 60 +expansion.disjunction 61 +progression 62 +interrupted 63 +elab-example 64 +cause-effect 65 +flashback 66 +hypophora 67 +bg-goal 68 +volitional-cause 69 +temploc 70 +contingency.cause+speechact 71 +restatement-mn 72 +e-elaboration 73 +acknowledgement 74 +interpretation-evaluation 75 +topic 76 +contingency.cause+belief 77 +conclusion 78 +exp-reason 79 +expansion 80 +enablement 81 +elab-definition 82 +attribution 83 +adversative 84 +continuation 85 +evaluation 86 +circumstance 87 +context 88 +mode 89 +comparison.degree 90 +comparison.similarity 91 +contingency.negative-condition 92 +expansion.restatement 93 +manner-means 94 +reason 95 +elab-enumember 96 +temporal.asynchronous 97 +contingency.condition 98 +frame 99 +antithesis 100 +narration 101 +preparation 102 +expansion.conjunction 4 +alternation 14 +conditional 8 +correction 37 +alternative 14 +disjunction 61 +restatement 93 +unless 30 +causation 18 +bg-general 19 +otherwise 84 +unconditional 61 +joint-disjunction 61 +temporal.synchrony 46 +textual-organization 47 +cause-result 65 +findings 34 +qap 40 +expansion.level 6 +qap.hypophora 67 +expansion.genexpansion 80 +goal 163 +evidence 164 +justify 165 +list 166 +motivation 167 +sequence 168 +exp-evidence 169 +repetition 170 +mode-means 132 +root 133 +organization-preparation 134 +topic-solutionhood 135 +organization-phatic 136 +purpose-attribute 137 +context-circumstance 138 +restatement-partial 139 +organization-heading 140 +joint-other 141 +elaboration-additional 142 +mode-manner 143 +joint-sequence 144 +topic-question 145 +elaboration-attribute 146 +explanation-justify 147 +context-background 148 +evaluation-comment 149 +attribution-negative 150 +attribution-positive 151 +restatement-repetition 152 +adversative-contrast 153 +explanation-evidence 154 +adversative-concession 155 +purpose-goal 156 +explanation-motivation 157 +adversative-antithesis 158 +contingency-condition 159 +causal-cause 160 +joint-list 161 +causal-result 162 diff --git a/run_stuff.sh b/run_stuff.sh deleted file mode 100644 index f3462d5..0000000 --- a/run_stuff.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -#SBATCH --job-name=pytorch-models - -#SBATCH --ntasks=1 -#SBATCH --cpus-per-task=4 -#SBATCH --partition=GPUNodes -#SBATCH --gres=gpu:1 - - -# tests tests - -srun singularity exec /logiciels/containerCollections/CUDA10/pytorch.sif python3 classifier_bare_pytorch.py \ - --num_epochs 10 \ - --data_path '/users/melodi/emetheni/clean_data' \ - --mappings_file 'mappings/mappings_substitutions.tsv' - - -# srun singularity exec /logiciels/containerCollections/CUDA10/pytorch.sif python3 classifier_bare_pytorch.py \ -# --num_epochs 10 \ -# --data_path '/users/melodi/emetheni/clean_data' \ -# --mappings_file 'mappings/mappings_substitutions.tsv' \ -# --transformer_model "xlm-roberta-base" \ -# --batch_size 4 \ -# --gradient_accumulation_steps 32 - -# srun singularity exec /logiciels/containerCollections/CUDA10/pytorch.sif python3 classifier_bare_huggingface.py \ -# --batch_size 4 \ -# --gradient_accumulation_steps 32 \ -# --num_epochs 1 \ -# --data_path '/users/melodi/emetheni/clean_data' \ -# --mappings_file 'mappings/mappings_substitutions.tsv' -# --transformer_model "bert-base-multilingual-cased" diff --git a/see_results.ipynb b/see_results.ipynb deleted file mode 100644 index 8d1d5dc..0000000 --- a/see_results.ipynb +++ /dev/null @@ -1,411 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "from sklearn.metrics import accuracy_score\n", - "import os, io\n", - "from collections import OrderedDict, Counter" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "connectives = {\"elaboration\": [\"and\", \"also\", \"besides\", \"further\", \"furthermore\", \"too\", \"moreover\", \"in addition\", \"then\", \"of equal importance\", \"equally important\", \"another\", \"additionally\", \"also\", \"moreover\", \"furthermore\", \"again\", \"further\", \"then\", \"besides\", \"too\", \"similarly\", \"correspondingly\", \"indeed\", \"regarding\"], \n", - "\"time\": [\"next\", \"afterward\", \"finally\", \"later\", \"last\", \"lastly\", \"at last\", \"now\", \"subsequently\", \"then\", \"when\", \"soon\", \"thereafter\", \"after a short time\", \"the next week\", \"a minute later\", \"in the meantime\", \"meanwhile\", \"on the following day\", \"at length\", \"ultimately\", \"presently\"], \n", - "\"sequence\": [\"first\", \"second\", \"third\", \"finally\", \"hence\", \"next\", \"then\", \"from here on\", \"to begin with\", \"last of all\", \"after\", \"before\", \"as soon as\", \"in the end\", \"gradually\", \"when\", \"after\", \"after that\", \"afterwards\", \"next\", \"subsequently\", \"later (on)\", \"followed by\", \"to go on to\", \"finally\", \"another\", \"additionally\", \"finally moreover\", \"also\", \"subsequently\", \"eventually\", \"next\", \"then\"], \n", - "\"example\": [\"for example\", \"to illustrate\", \"for instance\", \"to be specific\", \"such as\", \"moreover\", \"furthermore\", \"just as important\", \"similarly\", \"in the same way\", \"for example\", \"for instance\", \"namely\", \"such as\", \"as follows\", \"as exemplified by\", \"such as\", \"including\", \"especially\", \"particularly\", \"in particular\", \"notably\", \"mainly\"], \n", - "\"result\": [\"as a result\", \"hence\", \"so\", \"accordingly\", \"as a consequence\", \"consequently\", \"thus\", \"since\", \"therefore\", \"for this reason\", \"because of this\", \"therefore\", \"accordingly\", \"as a result of\", \"the result is/results are\", \"the consequence is\", \"resulting from\", \"consequently\", \"it can be seen\", \"evidence illustrates that\", \"because of this\", \"thus\", \"hence\", \"for this reason\", \"owing to x\", \"this suggests that\", \"it follows that\", \"otherwise\", \"in that case\", \"that implies\", \"As a result\", \"therefore\", \"thus\"], \n", - "\"purpose\": [\"for this purpose\", \"with this in mind\", \"for this reason\"], \n", - "\"comparison\": [\"like\", \"in the same manner\", \"as so\", \"similarly\"], \n", - "\"contrast\": [\"but\", \"in contrast\", \"conversely\", \"however\", \"still\", \"nevertheless\", \"nonetheless\", \"yet\", \"and yet\", \"on the other hand\", \"on the contrary\", \"or\", \"in spite of this\", \"actually\", \"in fact\", \"whereas\", \"conversely\", \"in comparison\", \"by contrast\", \"in contrast\", \"contrasting\", \"alternatively\", \"although\", \"otherwise\", \"instead\"], \n", - "\"summary\": [\"in summary\", \"to sum up\", \"to repeat\", \"briefly\", \"in short\", \"finally\", \"on the whole\", \"therefore\", \"as I have said\", \"in conclusion\", \"as seen\", \"in conclusion\", \"therefore\", \"to conclude\", \"on the whole\", \"hence\", \"thus to summarise\", \"altogether\", \"overall\"], \n", - "\"rephrasing\": [\"in other terms\", \"rather\", \"or\", \"better\", \"in view of this\", \"in contrast\"]}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "def parse_data(infile, string_input=False) -> list:\n", - " \"\"\"\n", - " This function is to read a gold or a pred file to obtain the label column for accuracy calculation.\n", - "\n", - " :param infile: shared task .rels file\n", - " :param string_input: If True, files are replaced by strings with file contents (for import inside other scripts)\n", - " :return: a list of labels\n", - " \"\"\"\n", - "\n", - " if not string_input:\n", - " data = io.open(infile, encoding=\"utf-8\").read().strip().replace(\"\\r\", \"\")\n", - " else:\n", - " data = infile.strip()\n", - "\n", - " labels = [line.split(\"\\t\")[-1].lower() \n", - " for i, line in enumerate(data.split(\"\\n\")) if \"\\t\" in line and i>0]\n", - " \n", - " sentences = [(line.split(\"\\t\")[3], line.split(\"\\t\")[4], line.split(\"\\t\")[-3])\n", - " for i, line in enumerate(data.split(\"\\n\")) if \"\\t\" in line and i>0]\n", - " \n", - " return sentences, labels\n", - "\n", - "\n", - "def get_accuracy_score(gold_file, pred_file, string_input=False) -> dict:\n", - "\n", - " _, gold_labels = parse_data(gold_file, string_input)\n", - " _, pred_labels = parse_data(pred_file, string_input)\n", - "\n", - " filename = gold_file.split(os.sep)[-1]\n", - "\n", - " assert len(gold_labels) == len(pred_labels), \"FATAL: different number of labels detected in gold and pred\"\n", - "\n", - " acc = accuracy_score(gold_labels, pred_labels)\n", - "\n", - " score_dict = {\"filename\": filename,\n", - " \"acc_score\": round(acc, 4),\n", - " \"gold_rel_count\": len(gold_labels),\n", - " \"pred_rel_count\": len(pred_labels)}\n", - "\n", - " return score_dict\n", - "\n", - "def separate_right_wrong(gold_file, pred_file, string_input=False):\n", - " \n", - " rights = []\n", - " wrongs = []\n", - " \n", - " gold_sents, gold_labels = parse_data(gold_file, string_input)\n", - " pred_sents, pred_labels = parse_data(pred_file, string_input)\n", - " \n", - " for n in range(len(gold_sents)):\n", - " if gold_labels[n] == pred_labels[n]:\n", - " rights.append([gold_sents[n], gold_labels[n], pred_labels[n]])\n", - " else:\n", - " wrongs.append([gold_sents[n], gold_labels[n], pred_labels[n]])\n", - " \n", - " return rights, wrongs" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "# Print accuracies \n", - "\n", - "model = 'A_15-epochs_frozen-1_2'\n", - "corpus = 'eng.dep.covdtb'\n", - "\n", - "gold_path = '/users/melodi/emetheni/clean_data/'\n", - "results_path = 'results/test/' + model + '/'\n", - "\n", - "corpora = sorted([x[:-4] for x in os.listdir('results/test/' + model) \n", - " if not \"DS\" in x if not 'ipy' in x])\n", - "\n", - "# for corpus in corpora:\n", - "# score = get_accuracy_score(gold_path + corpus + '/' + corpus + '_test.rels', \n", - "# results_path + corpus + '.tsv')\n", - "\n", - "# print(corpus, '\\t', score['acc_score'])" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [], - "source": [ - "# Separate\n", - "\n", - "# model = 'A_15-epochs_frozen-1_2'\n", - "# corpus = 'eng.dep.covdtb'\n", - "\n", - "model = 'A_15-epochs_frozen-1-2-3_3'\n", - "corpus = 'eng.rst.gum'\n", - "\n", - "gold_path = '/users/melodi/emetheni/clean_data/'\n", - "results_path = 'results/test/' + model + '/'\n", - "\n", - "corpora = sorted([x[:-4] for x in os.listdir('results/test/' + model) \n", - " if not \"DS\" in x if not 'ipy' in x])\n", - "\n", - "rights, wrongs = separate_right_wrong(gold_path + corpus + '/' + corpus + '_test.rels', \n", - " results_path + corpus + '.tsv')\n", - "\n", - "rights_count = dict(OrderedDict(Counter([x[-1] for x in rights])))\n", - "wrongs_count = dict(OrderedDict(Counter([x[-1] for x in wrongs])))\n", - "\n", - "# for label in sorted(set(list(rights_count.keys()) + list(wrongs_count.keys())), reverse=False):\n", - "# if label in rights_count:\n", - "# r = rights_count[label]\n", - "# else:\n", - "# r = 0\n", - "# if label in wrongs_count:\n", - "# w = wrongs_count[label]\n", - "# else:\n", - "# w = 0\n", - "# print(label, '\\t', r, '\\t', w)" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "rights 203 / 1657 0.12251056125528063\n", - "wrongs 71 / 918 0.07734204793028322\n" - ] - } - ], - "source": [ - "# Presence of connectives in right/wrong sents\n", - "\n", - "counter = 0\n", - "for sent in rights:\n", - " sentence = (sent[0][0] + ' ' + sent[0][1]).lower()\n", - " if sent[1] in connectives:\n", - " if any(x in sentence for x in connectives[sent[1]]):\n", - "# print(sent)\n", - " counter += 1\n", - "print('rights', counter, '/', len(rights), counter/len(rights))\n", - "\n", - "counter = 0\n", - "for sent in wrongs:\n", - " \n", - " sentence = (sent[0][0] + ' ' + sent[0][1]).lower()\n", - " if sent[1] in connectives:\n", - " if any(x in sentence for x in connectives[sent[1]]):\n", - "# print(sent)\n", - " counter += 1\n", - "print('wrongs', counter, '/', len(wrongs), counter/len(wrongs))" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "rights 1253 / 1657 0.756185878092939\n", - "wrongs 735 / 918 0.8006535947712419\n" - ] - } - ], - "source": [ - "# See direction\n", - "\n", - "counter = 0\n", - "for sent in rights:\n", - " if sent[0][2] == '1<2':\n", - " counter += 1\n", - "print('rights', counter, '/', len(rights), counter/len(rights))\n", - "\n", - "counter = 0\n", - "for sent in wrongs:\n", - " if sent[0][2] == '1<2':\n", - " counter += 1\n", - "print('wrongs', counter, '/', len(wrongs), counter/len(wrongs))" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[[('The prevalence of discrimination across racial groups in contemporary America :',\n", - " 'The current study seeks to build on this research',\n", - " '1>2'),\n", - " 'organization',\n", - " 'organization'],\n", - " [('The prevalence of discrimination across racial groups in contemporary America :',\n", - " 'Results from a nationally representative sample of adults',\n", - " '1<2'),\n", - " 'elaboration',\n", - " 'elaboration'],\n", - " [('Introduction .',\n", - " 'The current study seeks to build on this research',\n", - " '1>2'),\n", - " 'organization',\n", - " 'organization'],\n", - " [('Personal experiences of discrimination and bias have been the focus of much social science research .',\n", - " 'In many respects , researchers already possess a wealth of knowledge',\n", - " '1>2'),\n", - " 'context',\n", - " 'context'],\n", - " [('Personal experiences of discrimination and bias have been the focus of much social science research .',\n", - " '[ 1 - 3 ]',\n", - " '1<2'),\n", - " 'explanation',\n", - " 'explanation'],\n", - " [('Sociologists have explored the adverse consequences of discrimination',\n", - " '[ 3 – 5 ] ;',\n", - " '1<2'),\n", - " 'explanation',\n", - " 'explanation'],\n", - " [('Sociologists have explored the adverse consequences of discrimination',\n", - " 'psychologists have examined the mental processes',\n", - " '1<2'),\n", - " 'joint',\n", - " 'joint'],\n", - " [('psychologists have examined the mental processes',\n", - " 'that underpin conscious and unconscious biases',\n", - " '1<2'),\n", - " 'elaboration',\n", - " 'elaboration'],\n", - " [('psychologists have examined the mental processes', '[ 6 ] ;', '1<2'),\n", - " 'explanation',\n", - " 'explanation'],\n", - " [('Sociologists have explored the adverse consequences of discrimination',\n", - " 'neuroscientists have examined the neurobiological underpinnings of discrimination',\n", - " '1<2'),\n", - " 'joint',\n", - " 'joint']]" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "rights[:10]" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [], - "source": [ - "subs = {\"Attribution\": [\"attribution\", \"attribution-negative\"],\n", - " \"Background\": [\"background\", \"circumstance\"],\n", - " \"Cause\": [\"cause\", \"result\", \"consequence\"],\n", - " \"Comparison\": [\"comparison\", \"preference\", \"analogy\", \"proportion\"],\n", - " \"Condition\": [\"condition\", \"hypothetical\", \"contingency\", \"otherwise\"],\n", - " \"Contrast\": [\"contrast\", \"concession\", \"antithesis\"],\n", - " \"Elaboration\": [\"elaboration-additional\", \"elaboration-general-specific\", \"elaboration-part-whole\", \"elaboration-process-step\", \"elaboration-object-attribute\", \"elaboration-set-member\", \"example\", \"definition\"],\n", - " \"Enablement\": [\"purpose\", \"enablement\"],\n", - " \"Evaluation\": [\"evaluation\", \"interpretation\", \"conclusion\", \"comment\"],\n", - " \"Explanation\": [\"evidence\", \"explanation-argumentative\", \"reason\"],\n", - " \"Joint\": [\"list\", \"disjunction\"],\n", - " \"Manner-Means\": [\"manner\", \"means\"],\n", - " \"Topic-Comment\": [\"problem-solution\", \"question-answer\", \"statement-response\", \"topic-comment\", \"comment-topic\", \"rhetorical-question\"],\n", - " \"Summary\": [\"summary\", \"restatement\"],\n", - " \"Temporal\": [\"temporal-before\", \"temporal-after\", \"temporal-same-time\", \"sequence\", \"inverted-sequence\"],\n", - " \"Topic Change\": [\"topic-shift\", \"topic-drift\"]}" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [], - "source": [ - "rst = [\"bg-general\", \"elab-addition\", \"manner-means\", \"attribution\", \"evaluation\", \"enablement\", \"elab-aspect\", \"joint\", \"temporal\", \"result\", \"bg-goal\", \"progression\", \"contrast\", \"elab-process_step\", \"elab-enumember\", \"comparison\", \"cause\", \"exp-reason\", \"exp-evidence\", \"condition\", \"summary\", \"bg-compare\", \"elab-example\", \"elab-definition\", \"cause-result\", \"findings\"]" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "bg-general \t \n", - "elab-addition \t \n", - "manner-means \t manner-means\n", - "attribution \t attribution\n", - "evaluation \t evaluation\n", - "enablement \t enablement\n", - "elab-aspect \t \n", - "joint \t \n", - "temporal \t \n", - "result \t cause\n", - "bg-goal \t \n", - "progression \t \n", - "contrast \t contrast\n", - "elab-process_step \t \n", - "elab-enumember \t \n", - "comparison \t comparison\n", - "cause \t cause\n", - "exp-reason \t explanation\n", - "exp-evidence \t explanation\n", - "condition \t condition\n", - "summary \t summary\n", - "bg-compare \t \n", - "elab-example \t elaboration\n", - "elab-definition \t elaboration\n", - "cause-result \t cause\n", - "findings \t \n" - ] - } - ], - "source": [ - "for label in rst:\n", - " temp = ''\n", - " for k, v in subs.items():\n", - " if label in v:\n", - " temp = k.lower()\n", - " elif '-' in label:\n", - " for l in label.split('-'):\n", - " if l in v:\n", - " temp = temp = k.lower()\n", - " elif '.' in label:\n", - " for l in label.split('.'):\n", - " if l in v:\n", - " temp = temp = k.lower()\n", - " \n", - " print(label, '\\t', temp)\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.7" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/utils.py b/utils.py index d9cdb3d..3880be6 100644 --- a/utils.py +++ b/utils.py @@ -20,7 +20,14 @@ def open_mappings(mappings_file): next(f) for l in f: mappings[l.split('\t')[0]] = int(l.strip().split('\t')[-1]) - inv_mappings = {v:k for k, v in mappings.items()} + + inv_mappings = {} +# for label, num in mappings.items(): +# if not num in inv_mappings: +# inv_mappings[num] = label +# else: +# subs[label] = inv_mappings[num] + return mappings, inv_mappings @@ -158,7 +165,8 @@ def open_sentences(path_to_corpora, mappings_dict): ''' corpora = [folder for folder in os.listdir(path_to_corpora) - if not any(i in folder for i in ['.md', 'DS_', 'utils', 'ipynb'])] + if not any(i in folder for i in ['.md', 'DS_', 'utils', 'ipynb']) + ] # --------------------- train_sentences = [] @@ -177,7 +185,9 @@ def open_sentences(path_to_corpora, mappings_dict): # open normal files train_file = ['/'.join([path_to_corpora, corpus, x]) for x in os.listdir(path_to_corpora + '/' + corpus) - if 'train' in x and 'rels' in x][0] + if 'train' in x and 'rels' in x + # attention! we block training for some languages if we want HERE + if not args.langs_to_use in x][0] temp = open_file(train_file, mappings_dict) # train_sentences += open_file_with_lang(train_file, mappings_dict) train_sentences += temp @@ -207,7 +217,7 @@ def open_sentences(path_to_corpora, mappings_dict): # test_dict_sentences[corpus] += open_file_with_lang(test_file, mappings_dict) labels = {framework:set(all_labels[framework]) for framework in all_labels} - + return train_sentences, dev_dict_sentences, test_dict_sentences, labels @@ -376,16 +386,17 @@ def get_better_predictions(model, all_preds += [final_probs] all_labels += batch_labels - + # get the top predictions in order to get the acc top_preds = [] for probs in all_preds: top_preds.append(max(zip(probs.values(), probs.keys()))[1]) - test_acc = round(accuracy_score(labels, top_preds), 4) + test_acc = round(accuracy_score(all_labels, top_preds), 4) if print_results: - print('better:', '\t', test_acc) + print('better:', '\t', test_acc, flush='') + return all_labels, all_preds -- GitLab