# Path: datasets/sts.py
# class STS(object):
#     def __init__(self, train_validation_split=None, test_split=None,
#                  use_defaults=True, subset='sts_small'):
#         if train_validation_split is not None or test_split is not None or \
#                 use_defaults is False:
#             raise NotImplementedError('This Dataset does not implement '
#                   'train_validation_split, test_split or use_defaults as the '
#                   'dataset is big enough and uses dedicated splits from '
#                   'the original datasets')
#         self.dataset_name = 'Semantic Text Similarity - All'
#         self.dataset_description = 'This dataset has been generated by ' \
#                'merging MPD, SICK, Quora, StackExchange and and SemEval ' \
#                'datasets. \n It has 258537 Training sentence pairs, 133102 ' \
#                'Test sentence pairs and 59058 validation sentence pairs.'
#         self.test_split = 'large'
#         self.dataset = subset
#         self.dataset_path = os.path.join(datasets.data_root_directory,
#                                          self.dataset)
#         self.train_path = os.path.join(self.dataset_path, 'train', 'train.txt')
#         self.validation_path = os.path.join(self.dataset_path, 'validation',
#                                             'validation.txt')
#         self.test_path = os.path.join(self.dataset_path, 'test', 'test.txt')
#         self.vocab_path = os.path.join(self.dataset_path, 'vocab.txt')
#         self.metadata_path = os.path.abspath(os.path.join(self.dataset_path,
#                                                'metadata.txt'))
#         self.w2v_path = os.path.join(self.dataset_path, 'w2v.npy')
# 
#         self.w2i, self.i2w = datasets.load_vocabulary(self.vocab_path)
#         self.w2v = datasets.load_w2v(self.w2v_path)
# 
#         self.vocab_size = len(self.w2i)
#         self.train = DataSet(self.train_path, (self.w2i, self.i2w))
#         self.validation = DataSet(self.validation_path, (self.w2i, self.i2w))
#         self.test = DataSet(self.test_path, (self.w2i, self.i2w))
#         self.__refresh(load_w2v=False)
# 
#     def create_vocabulary(self, min_frequency=5, tokenizer='spacy',
#                           downcase=False, max_vocab_size=None,
#                           name='new', load_w2v=True):
#         self.vocab_path, self.w2v_path, self.metadata_path = \
#             datasets.new_vocabulary([self.train_path], self.dataset_path,
#                                     min_frequency, tokenizer=tokenizer, downcase=downcase,
#                                     max_vocab_size=max_vocab_size, name=name)
#         self.__refresh(load_w2v)
# 
#     def __refresh(self, load_w2v):
#         self.w2i, self.i2w = datasets.load_vocabulary(self.vocab_path)
#         self.vocab_size = len(self.w2i)
#         if load_w2v:
#             self.w2v = datasets.preload_w2v(self.w2i)
#             datasets.save_w2v(self.w2v_path, self.w2v)
#         self.train.set_vocab((self.w2i, self.i2w))
#         self.validation.set_vocab((self.w2i, self.i2w))
#         self.test.set_vocab((self.w2i, self.i2w))


import os
from datasets import STS
from nose.tools import assert_equal
from nose.tools import assert_not_equal
from nose.tools import assert_is_instance

def setup_dataset(cl):
    ret = cl()
    ret.train.open()
    ret.validation.open()
    ret.test.open()
    return ret


def teardown_dataset(ds):
    ds.train.close()
    ds.validation.close()
    ds.test.close()


class TestSTS(object):
    @classmethod
    def dataset_class(cl):

# Path: datasets/sts.py
# class STS(object):
#     def __init__(self, train_validation_split=None, test_split=None,
#                  use_defaults=True, subset='sts_small'):
#         if train_validation_split is not None or test_split is not None or \
#                 use_defaults is False:
#             raise NotImplementedError('This Dataset does not implement '
#                   'train_validation_split, test_split or use_defaults as the '
#                   'dataset is big enough and uses dedicated splits from '
#                   'the original datasets')
#         self.dataset_name = 'Semantic Text Similarity - All'
#         self.dataset_description = 'This dataset has been generated by ' \
#                'merging MPD, SICK, Quora, StackExchange and and SemEval ' \
#                'datasets. \n It has 258537 Training sentence pairs, 133102 ' \
#                'Test sentence pairs and 59058 validation sentence pairs.'
#         self.test_split = 'large'
#         self.dataset = subset
#         self.dataset_path = os.path.join(datasets.data_root_directory,
#                                          self.dataset)
#         self.train_path = os.path.join(self.dataset_path, 'train', 'train.txt')
#         self.validation_path = os.path.join(self.dataset_path, 'validation',
#                                             'validation.txt')
#         self.test_path = os.path.join(self.dataset_path, 'test', 'test.txt')
#         self.vocab_path = os.path.join(self.dataset_path, 'vocab.txt')
#         self.metadata_path = os.path.abspath(os.path.join(self.dataset_path,
#                                                'metadata.txt'))
#         self.w2v_path = os.path.join(self.dataset_path, 'w2v.npy')
# 
#         self.w2i, self.i2w = datasets.load_vocabulary(self.vocab_path)
#         self.w2v = datasets.load_w2v(self.w2v_path)
# 
#         self.vocab_size = len(self.w2i)
#         self.train = DataSet(self.train_path, (self.w2i, self.i2w))
#         self.validation = DataSet(self.validation_path, (self.w2i, self.i2w))
#         self.test = DataSet(self.test_path, (self.w2i, self.i2w))
#         self.__refresh(load_w2v=False)
# 
#     def create_vocabulary(self, min_frequency=5, tokenizer='spacy',
#                           downcase=False, max_vocab_size=None,
#                           name='new', load_w2v=True):
#         self.vocab_path, self.w2v_path, self.metadata_path = \
#             datasets.new_vocabulary([self.train_path], self.dataset_path,
#                                     min_frequency, tokenizer=tokenizer, downcase=downcase,
#                                     max_vocab_size=max_vocab_size, name=name)
#         self.__refresh(load_w2v)
# 
#     def __refresh(self, load_w2v):
#         self.w2i, self.i2w = datasets.load_vocabulary(self.vocab_path)
#         self.vocab_size = len(self.w2i)
#         if load_w2v:
#             self.w2v = datasets.preload_w2v(self.w2i)
#             datasets.save_w2v(self.w2v_path, self.w2v)
#         self.train.set_vocab((self.w2i, self.i2w))
#         self.validation.set_vocab((self.w2i, self.i2w))
#         self.test.set_vocab((self.w2i, self.i2w))


# Path: tests/test_sts_all.py
import os
from datasets import STS
from nose.tools import assert_equal
from nose.tools import assert_not_equal
from nose.tools import assert_is_instance


def setup_dataset(cl):
    ret = cl()
    ret.train.open()
    ret.validation.open()
    ret.test.open()
    return ret


def teardown_dataset(ds):
    ds.train.close()
    ds.validation.close()
    ds.test.close()


class TestSTS(object):
    @classmethod
    def dataset_class(cl):

        return STS