import pandas as pd


class STSB_Dataset:

    def __init__(self, path):

        with open(path,
                  'r', encoding='utf-8') as d:
            dataset = d.read().splitlines()

        self.data = []
        self.labels = []

        for line in dataset:
            datapoint = line.split('\t')
            score = float(datapoint[4])
            score = score/5

            st1 = datapoint[5]
            st2 = datapoint[6]
            self.data.append([st1, st2])
            self.labels.append(score)

        # Store as a list of dicts, conforming to self.spec()
        self._examples = [{
          'sentence1': dp[0],
          'sentence2': dp[1],
          'label': label,
        } for dp, label in zip(self.data, self.labels)]

        self.as_dataframe = pd.DataFrame.from_dict(self._examples)
