<reponame>wise-east/ParlAI
# <NAME>, July 25th 2021 
# reference: https://parl.ai/docs/tutorial_task.html#quickstart-adding-a-new-dataset

from parlai.core.teachers import register_teacher, DialogTeacher, ParlAIDialogTeacher, ConversationTeacher
from parlai.scripts.display_data import DisplayData
import copy
import os 

def _path(opt, filtered):
    # build the data if it does not exist
    # build(opt): optional 

    # set up path to data (specific to each dataset)
    # dt = opt['datatype'].split(':')[0]
    if opt['datatype'] == "valid": 
        # keep validation dataset consistent 
        return os.path.join(opt['datapath'], f"employee{opt['euid']}_threads_valid.tsv")
    # opt['data_config'] must be one of {threads, augmented_threads, augmented_random, all_random} 
    return os.path.join(opt['datapath'], f"employee{opt['euid']}_{opt['data_config']}_{opt['datatype']}.tsv")


@register_teacher("enron_employee")
class DefaultTeacher(ConversationTeacher):
    def __init__(self, opt, shared=None):
        opt = copy.deepcopy(opt)

        # get datafile
        opt['datapath'] = "/project/jonmay_231/hjcho/PERM/data/enron_finetuning"
        opt['datatype'] = opt['datatype'].split(":")[0]

        opt['label_turns'] = 'secondspeaker'
        opt['conversationteacher_datafile'] = _path(opt, '')

        super().__init__(opt, shared)

# <NAME>, July 25th 2021 
# reference: https://parl.ai/docs/tutorial_task.html#quickstart-adding-a-new-dataset

from parlai.core.teachers import register_teacher, DialogTeacher, ParlAIDialogTeacher, ConversationTeacher
from parlai.scripts.display_data import DisplayData
import copy
import os 

def _path(opt, filtered):
    # build the data if it does not exist
    # build(opt): optional 

    # set up path to data (specific to each dataset)
    # dt = opt['datatype'].split(':')[0]
    if opt['datatype'] == "valid": 
        # keep validation dataset consistent 
        return os.path.join(opt['datapath'], f"employee{opt['euid']}_threads_valid.tsv")
    # opt['data_config'] must be one of {threads, augmented_threads, augmented_random, all_random} 
    return os.path.join(opt['datapath'], f"employee{opt['euid']}_{opt['data_config']}_{opt['datatype']}.tsv")


@register_teacher("enron_employee")
class DefaultTeacher(ConversationTeacher):
    def __init__(self, opt, shared=None):
        opt = copy.deepcopy(opt)

        # get datafile
        opt['datapath'] = "/project/jonmay_231/hjcho/PERM/data/enron_finetuning"
        opt['datatype'] = opt['datatype'].split(":")[0]

        opt['label_turns'] = 'secondspeaker'
        opt['conversationteacher_datafile'] = _path(opt, '')

        super().__init__(opt, shared)
# <NAME>, July 25th 2021 # reference: https://parl.ai/docs/tutorial_task.html#quickstart-adding-a-new-dataset # build the data if it does not exist # build(opt): optional # set up path to data (specific to each dataset) # dt = opt['datatype'].split(':')[0] # keep validation dataset consistent # opt['data_config'] must be one of {threads, augmented_threads, augmented_random, all_random} # get datafile