import os
root = os.path.dirname(os.path.abspath(__file__))+'/..'
data_root = f'{root}/MLFD_fd_detection/data/'

METANOME_DATA_PATH = f'{root}/MLFD_fd_detection/backend/WEB-INF/classes/inputData/'


class Dataset:
    def __init__(self, title, fd_path, continuous,
                 column_map, original_separator,
                 missing_value_token, origin, cleaning=False,
                 cols_with_errors=None, dtypes=None):
        self.title = title
        self.figures_path = f'{root}/figures/{title}/'
        self.results_path = f'{root}/figures/results/{title}/'
        self.fd_path = f'{root}/MLFD_fd_detection/results/{fd_path}'
        self.continuous = continuous
        self.column_map = column_map
        self.random_fd_path = f'{self.results_path}random_fds.p'
        self.data_path = f'https://mlfd-data.s3.eu-central-1.amazonaws.com/data/{title}.csv'
        self.dirty_data_path = f'https://mlfd-data.s3.eu-central-1.amazonaws.com/data/{title}_dirty.csv'
        self.splits_path = data_root
        self.original_separator = original_separator
        self.missing_value_token = missing_value_token
        self.dep_optimizer_results_path = f'{root}/figures/results/{title}'
        self.cleaning = cleaning
        self._origin = origin
        self.cols_with_errors=cols_with_errors
        self.dtypes=dtypes


IR = Dataset(title='ir',
            original_separator=',',
            fd_path='',
            continuous=[1, 2, 3, 4],
            column_map={0: "sepal length in cm",
                           1: "sepal width in cm",
                           2: "petal length in cm",
                           3: "petal width in cm",
                           4: "class"},
            missing_value_token='',
            origin='https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data',
            cleaning=True
            )

ABALONE = Dataset(title='abalone',
                  original_separator=',',
                  fd_path='HyFD-1.2-SNAPSHOT.jar2019-08-25T084553_fds',
                  continuous=[2, 3, 4, 5, 6, 7, 8],
                  column_map={0: "Sex",
                              1: "Length",
                              2: "Diameter",
                              3: "Height",
                              4: "Whole weight",
                              5: "Shucked weight",
                              6: "Viscera weight",
                              7: "Shell weight",
                              8: "Rings"},
                  missing_value_token='',
                  origin='https://archive.ics.uci.edu/ml/machine-learning-databases/abalone/abalone.data')

ADULT = Dataset(title='adult',
                fd_path='HyFD-1.2-SNAPSHOT.jar2019-07-06T091216_fds',
                continuous=[1, 3, 11, 12, 13],
                column_map={0: "age",
                            1: "workclass",
                            2: "fnlwgt",
                            3: "education",
                            4: "education-num",
                            5: "marital-status",
                            6: "occupation",
                            7: "relationship",
                            8: "race",
                            9: "sex",
                            10: "capital-gain",
                            11: "capital-loss",
                            12: "hours-per-week",
                            13: "native-country",
                            14: "income-class"},
                original_separator=', ',
                missing_value_token='noValueSetHere123156456',
                origin='https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data')

BALANCESCALE = Dataset(title='balance-scale',
                       original_separator=',',
                       fd_path='HyFD-1.2-SNAPSHOT.jar2019-08-25T084712_fds',
                       continuous=[0],
                       column_map={0: "Class Name",
                                   1: "Left-Weight",
                                   2: "Left-Distance",
                                   3: "Right-Weight",
                                   4: "Right-Distance"},
                       missing_value_token='',
                       origin='https://archive.ics.uci.edu/ml/machine-learning-databases/balance-scale/balance-scale.data')

BREASTCANCER = Dataset(title='breast-cancer',
                       original_separator=',',
                       fd_path='HyFD-1.2-SNAPSHOT.jar2019-08-25T084747_fds',
                       continuous=[1],
                       column_map={0: "Class",
                                   1: "age",
                                   2: "menopause",
                                   3: "tumor-size",
                                   4: "inv-nodes",
                                   5: "node-caps",
                                   6: "deg-malig",
                                   7: "breast",
                                   8: "breast-quad",
                                   9: "irradiation"},
                       missing_value_token='?',
                       origin='https://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer/breast-cancer.data')

BRIDGES = Dataset(title='bridges',
                  original_separator=',',
                  fd_path='HyFD-1.2-SNAPSHOT.jar2019-08-25T090753_fds',
                  continuous=[0],
                  column_map={0: "identify",
                              1: "river",
                              2: "location",
                              3: "erected",
                              4: "purpose",
                              5: "length",
                              6: "lanes",
                              7: "clear-g",
                              8: "t-or-d",
                              9: "material",
                              10: "span",
                              11: "rel-l",
                              12: "type"},
                  missing_value_token='?',
                  origin='https://archive.ics.uci.edu/ml/machine-learning-databases/bridges/bridges.data.version2')

CERVICAL_CANCER = Dataset(title='cervical-cancer',
                          original_separator=',',
                          fd_path='HyFD-1.2-SNAPSHOT.jar2019-08-25T084747_fds',
                          continuous=[0, 1, 2, 3, 8, 10, 12, 25, 26, 27],
                          column_map={0: "age",
                                      1: "number of sexual partners",
                                      2: "age of first sexual intercourse",
                                      3: "smokes",
                                      4: "smokes years",
                                      5: "smokes packs per year",
                                      6: "hormonal contraceptives",
                                      7: "hormonal contraceptives years",
                                      8: "IUD",
                                      9: "IUD years",
                                      10: "STDs",
                                      11: "STDs number",
                                      12: "STDs:condylomatosis",
                                      13: "STDs:cervical condylomatosis",
                                      14: "STDs:vaginal condylomatosis",
                                      15: "STDs:vulvo-perineal condylomatosis",
                                      16: "STDs:syphilis",
                                      17: "STDs:pelvic inflammatory disease",
                                      18: "STDs:genital herpes",
                                      19: "STDs:molluscum contagiosum",
                                      20: "STDs:AIDS",
                                      21: "STDs:HIV",
                                      23: "STDs:Hepatitis B",
                                      24: "STDs:HPV",
                                      25: "STDs: Number of diagnosis",
                                      26: "STDs: Time since first diagnosis",
                                      27: "STDs: Time since last diagnosis",
                                      28: "Dx:Cancer",
                                      29: "Dx:CIN",
                                      30: "Dx:HPV",
                                      31: "Dx",
                                      32: "Hinselmann: target variable",
                                      33: "Schiller: target variable",
                                      34: "Cytology: target variable",
                                      35: "Biopsy: target variable"},
                          missing_value_token='?',
                          origin='https://archive.ics.uci.edu/ml/machine-learning-databases/00383/')

ECHOCARDIOGRAM = Dataset(title='echocardiogram',
                         original_separator=',',
                         fd_path='HyFD-1.2-SNAPSHOT.jar2019-08-25T085015_fds',
                         continuous=[1, 3, 5, 6, 7, 8, 9, 10],
                         column_map={0: "survival",
                                     1: "still-alive",
                                     2: "age-at-heart-attack",
                                     3: "pericardial-effusion",
                                     4: "fractional-shortening",
                                     5: "epss",
                                     6: "lvdd",
                                     7: "wall-motion-score",
                                     8: "wall-motion-index",
                                     9: "mult",
                                     10: "name",
                                     11: "group",
                                     12: "alive-at-1-year"},
                         missing_value_token='?',
                         origin='https://archive.ics.uci.edu/ml/machine-learning-databases/echocardiogram/echocardiogram.data')

HEPATITIS = Dataset(title='hepatitis',
                    original_separator=',',
                    fd_path='HyFD-1.2-SNAPSHOT.jar2019-08-25T090716_fds',
                    continuous=[15, 18],
                    column_map={0: "class",
                                1: "age",
                                2: "sex",
                                3: "steroid",
                                4: "antivirals",
                                5: "fatigues",
                                6: "malaise",
                                7: "anorexia",
                                8: "liver big",
                                9: "liver firm",
                                10: "spleen palpable",
                                11: "spiders",
                                12: "ascites",
                                13: "varices",
                                14: "bilirubin",
                                15: "alk phosphate",
                                16: "sgot",
                                17: "albumin",
                                18: "protime",
                                19: "histology"},
                    missing_value_token='?',
                    origin='https://archive.ics.uci.edu/ml/machine-learning-databases/hepatitis/hepatitis.data')

HORSE = Dataset(title='horse',
                original_separator=' ',
                fd_path='HyFD-1.2-SNAPSHOT.jar2019-08-25T085141_fds',
                continuous=[3, 4, 5, 6, 16, 19, 20, 22],
                column_map={0: "surgery?",
                            1: "age",
                            2: "hospital number",
                            3: "rectal temperature",
                            4: "pulse",
                            5: "respiratory rate",
                            6: "temperature of extermities",
                            7: "peripheral pulse",
                            8: "mucous membranes",
                            9: "capillary refill time",
                            10: "pain",
                            11: "peristalsis",
                            12: "abdominal distension",
                            13: "nasogastric tube",
                            14: "nasogastric reflux",
                            15: "nasogastric refulux PH",
                            16: "rectal examination - feces",
                            17: "abdomen",
                            18: "packed cell volume",
                            19: "total protein",
                            20: "abdominocentesis appearance",
                            21: "abdomcentesis total protein",
                            23: "outcome",
                            24: "type of lesion -- site of lesion",
                            25: "type of lesion -- type",
                            26: "type of lesion -- subtype",
                            27: "type of lesion -- code",
                            28: "cp_data"},
                missing_value_token='?',
                origin='https://archive.ics.uci.edu/ml/machine-learning-databases/horse-colic/horse-colic.data')

IRIS = Dataset(title='iris',
               original_separator=',',
               fd_path='HyFD-1.2-SNAPSHOT.jar2019-08-25T085225_fds',
               continuous=[1, 2, 3, 4],
               column_map={0: "sepal length in cm",
                              1: "sepal width in cm",
                              2: "petal length in cm",
                              3: "petal width in cm",
                              4: "class"},
               missing_value_token='',
               origin='https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data')

LETTER = Dataset(title='letter',
                 original_separator=',',
                 fd_path='HyFD-1.2-SNAPSHOT.jar2019-08-25T085300_fds',
                 continuous=[0],  # this is hard to decide
                 column_map={0: "letter",
                             1: "horizontal position of box",
                             2: "vertical position of box",
                             3: "width of box",
                             4: "height of box",
                             5: "total number of pixels",
                             6: "mean x of on pixels in box",
                             7: "mean y of on pixels in box",
                             8: "mean x variance",
                             9: "mean y variance",
                             10: "mean xy correlation",
                             11: "mean of x*x*y",
                             12: "mean of x*y*y",
                             13: "mean edge count left to right",
                             14: "correlation of x-ege with y",
                             15: "mean edge count bottom to top",
                             16: "correlation of y-ege with x"},
                 missing_value_token='',
                 origin='https://archive.ics.uci.edu/ml/machine-learning-databases/letter-recognition/letter-recognition.data')

NURSERY = Dataset(title='nursery',
                  fd_path='HyFD-1.2-SNAPSHOT.jar2019-07-04T182440_fds',
                  continuous=[],
                  column_map={0: "parent's occupation",
                              1: "child's nursery",
                              2: "form of the family",
                              3: "number of children",
                              4: "housing conditions",
                              5: "financial standing",
                              6: "social conditions",
                              7: "health conditions",
                              8: "class"},
                  original_separator=',',
                  missing_value_token='',
                  origin='https://archive.ics.uci.edu/ml/machine-learning-databases/nursery/nursery.data')

MOVIES = Dataset(title='movies',
                 fd_path='',
                 continuous=[],
                 column_map={0: "Id",
                             1: "Name",
                             2: "Year",
                             3: "Release Date",
                             4: "Director",
                             5: "Creator",
                             6: "Actors",
                             7: "Cast",
                             8: "Language",
                             9: "Country",
                             10: "Duration",
                             11: "RatingValue",
                             12: "RatingCount",
                             13: "ReviewCount",
                             14: "Genre",
                             15: "Filming Locations",
                             16: "Description"},
                 original_separator=',',
                 missing_value_token='',
                 origin='Dataset obtained from Felix Neutatz. The dataset '
                 'contains information on movies that has been scraped from '
                 'different websites. This results in different formats '
                 'for the same fields. The clean version uses the format '
                 'of rottentomatoes.',
                 cleaning=True
                 )


FLIGHTS = Dataset(title='flights',
                  fd_path='',
                  continuous=[],
                  column_map={0: "RowId",
                              1: "Source",
                              2: "Flight",
                              3: "ScheduleDeparture",
                              4: "ActualDeparture",
                              5: "DepartureGate",
                              6: "ScheduleArrival",
                              7: "ActualArrival",
                              8: "ArrivalGate"},
                  original_separator=',',
                  missing_value_token='',
                  origin='Dataset obtained from Felix Neutatz. The dataset '
                  'contains information on flights that has been scraped from '
                  'different sources/websites. This results in different '
                  'formats for the same fields. The clean version uses only '
                  'one format.',
                  cleaning=True
                  )

HOSPITAL_1k = Dataset(title='hospital_1k',
                      fd_path='',
                      continuous=[],
                      cols_with_errors=[0, 2, 3, 4, 5, 7, 12],
                      dtypes={0: "str",
                              1: "str",
                              2: "str",
                              3: "str",
                              4: "str",
                              5: "str",
                              6: "str",
                              7: "str",
                              8: "str",
                              9: "str",
                              10: "str",
                              11: "str",
                              12: "str",
                              13: "str",
                              14: "str",
                              15: "str",
                              16: "str"},
                      column_map={0: "PrNo",
                                  1: "HospitalName",
                                  2: "Address",
                                  3: "City",
                                  4: "State",
                                  5: "Zip",
                                  6: "Countryname",
                                  7: "Phone",
                                  8: "HospitalType",
                                  9: "Hospitalowner",
                                  10: "EmergencyService",
                                  11: "Condition",
                                  12: "MC",
                                  13: "MeasureName",
                                  14: "Score",
                                  15: "Sample",
                                  16: "StateAvg"},
                      original_separator=',',
                      missing_value_token='',
                      origin='Dataset obtained from Felix Neutatz.',
                      cleaning=True
                      )

HOSPITAL_10k = Dataset(title='hospital_10k',
                       fd_path='',
                       continuous=[],
                       cols_with_errors=[0, 2, 3, 4, 5, 7, 12],
                       dtypes={0: "str",
                               1: "str",
                               2: "str",
                               3: "str",
                               4: "str",
                               5: "str",
                               6: "str",
                               7: "str",
                               8: "str",
                               9: "str",
                               10: "str",
                               11: "str",
                               12: "str",
                               13: "str",
                               14: "str",
                               15: "str",
                               16: "str"},
                       column_map={0: "PrNo",
                                   1: "HospitalName",
                                   2: "Address",
                                   3: "City",
                                   4: "State",
                                   5: "Zip",
                                   6: "Countryname",
                                   7: "Phone",
                                   8: "HospitalType",
                                   9: "Hospitalowner",
                                   10: "EmergencyService",
                                   11: "Condition",
                                   12: "MC",
                                   13: "MeasureName",
                                   14: "Score",
                                   15: "Sample",
                                   16: "StateAvg"},
                       original_separator=',',
                       missing_value_token='',
                       origin='Dataset obtained from Felix Neutatz.',
                       cleaning=True
                       )

HOSPITAL_100k = Dataset(title='hospital_100k',
                        fd_path='',
                        continuous=[],
                        cols_with_errors=[0, 2, 3, 4, 5, 7, 12],
                        dtypes={0: "str",
                                1: "str",
                                2: "str",
                                3: "str",
                                4: "str",
                                5: "str",
                                6: "str",
                                7: "str",
                                8: "str",
                                9: "str",
                                10: "str",
                                11: "str",
                                12: "str",
                                13: "str",
                                14: "str",
                                15: "str",
                                16: "str"},
                        column_map={0: "PrNo",
                                    1: "HospitalName",
                                    2: "Address",
                                    3: "City",
                                    4: "State",
                                    5: "Zip",
                                    6: "Countryname",
                                    7: "Phone",
                                    8: "HospitalType",
                                    9: "Hospitalowner",
                                    10: "EmergencyService",
                                    11: "Condition",
                                    12: "MC",
                                    13: "MeasureName",
                                    14: "Score",
                                    15: "Sample",
                                    16: "StateAvg"},
                        original_separator=',',
                        missing_value_token='',
                        origin='Dataset obtained from Felix Neutatz.',
                        cleaning=True
                        )
