# Path: analyzer/dtw_merger.py
# class ScoreMatrix(object):
# class Match(object):
# 	def __init__(self, grid, traceback, distance_function):
# 	def score(self, c1, c2):
# def binary_distance(s1, s2):
# def levenstein_distance(s1, s2):
# def pretty_print_grid(alignment):
# 	def search_indexes(i, j):
# def dtw(template, test, distance_function, logger):
# def calculate_backtrace(traceback):
# def convert_to_script_entities(script):
# def prepare_text(text):
# def map_words_to_entity(entities, extraction_function):
# 	def __init__(self, vertical, horizontal):
# 	def __matches(self):
# 	def format(self):
# def speeches_from_matches(matches):
# def group_matches_by_speech(matches):
# def max_matching_group(groups):
# def filter_valid_matches(matches):
# def vote(alignment, logger):
# def perform(speeches, subtitles, logger, distance_function=binary_distance, verbose=False):
# def run(speeches, subtitles, partial=1, logger=None, verbose=False):
# 
# Path: analyzer/script_entity.py
# class ScriptEntity(Model):
# 	def __init__(self, character, text, type="speech"):
# 		self.character = character
# 		self.type = type
# 		self.original_text = text
# 
# 		self.text = text.rstrip().replace('\n', ' ') if type == 'speech' else text
# 
# 	def __str__(self):
# 		return "type: {}, character: {}, text: \"{}\"".format(self.type, self.character, self.text)
# 
# 	def __repr__(self):
# 		return self.__str__()
# 
# 	@classmethod
# 	def from_dict(cls, data, from_camel=True):
# 		d = Model.from_dict(data, from_camel)
# 		return cls(d.get("character"), d.get("text"), type=d.get("type"))
# 
# 	@classmethod
# 	def from_dicts(cls, data, from_camel=True):
# 		return [cls.from_dict(d) for d in data]
# 
# Path: analyzer/subtitles_parser.py
# class Subtitle(Model):
# 	def __init__(self, t1, t2, text, original_text=None, character=None):
# 		self.t1 = Timestamp(t1) if (type(t1) == int) else t1
# 		self.t2 = Timestamp(t2) if (type(t2) == int) else t2
# 		self.text = text
# 		self.original_text = text if text is not None else original_text
# 		self.character = character
# 
# 	def __str__(self):
# 		return "t1: {}, t2: {}, text: {}, character: {}".format(self.t1, self.t2, self.text, self.character)
# 
# 	def __repr__(self):
# 		return self.__str__()
# 
# 	def as_dict(self, camel=True):
# 		d = Model.as_dict(self)
# 		d["t1"] = self.t1.millis
# 		d["t2"] = self.t2.millis
# 
# 		return d
# 
# 	def to_mongo_dict(self):
# 		d = self.as_dict()
# 		return utils.to_mongo_dict(d)
# 
# 	@classmethod
# 	def from_dict(cls, data, from_camel=True):
# 		d = Model.from_dict(data, from_camel)
# 
# 		return cls(d["t1"], d["t2"], d["text"], d["original_text"], d["character"])
# 
# Path: analyzer/logger.py
# class Logger(object):
# 	def __init__(self, project, verbose=True):
# 		self.project = project
# 		self.verbose = verbose
# 		self.messages = []
# 
# 	def add(self, message, end="\n"):
# 		print(message)
# 		self.messages.append(message)
# 		self.messages.append(end)
# 
# 	def write(self):
# 		formatted_date = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d_%H-%M-%S')
# 		path = self.project.file_path(formatted_date + ".txt")
# 		with open(path, "w") as log:
# 			log.write("".join(self.messages))


import unittest
from analyzer import dtw_merger as dtw
from analyzer.script_entity import ScriptEntity
from analyzer.subtitles_parser import Subtitle
from analyzer.logger import Logger
# -*- coding: utf-8 -*-



class DtwMergerTest(unittest.TestCase):
	"""Some test case"""

	def setUp(self):
		self._sut = dtw.perform
		self._logger = Logger(None)

	def test_1(self):
		subtitles = [

# Path: analyzer/dtw_merger.py
# class ScoreMatrix(object):
# class Match(object):
# 	def __init__(self, grid, traceback, distance_function):
# 	def score(self, c1, c2):
# def binary_distance(s1, s2):
# def levenstein_distance(s1, s2):
# def pretty_print_grid(alignment):
# 	def search_indexes(i, j):
# def dtw(template, test, distance_function, logger):
# def calculate_backtrace(traceback):
# def convert_to_script_entities(script):
# def prepare_text(text):
# def map_words_to_entity(entities, extraction_function):
# 	def __init__(self, vertical, horizontal):
# 	def __matches(self):
# 	def format(self):
# def speeches_from_matches(matches):
# def group_matches_by_speech(matches):
# def max_matching_group(groups):
# def filter_valid_matches(matches):
# def vote(alignment, logger):
# def perform(speeches, subtitles, logger, distance_function=binary_distance, verbose=False):
# def run(speeches, subtitles, partial=1, logger=None, verbose=False):
# 
# Path: analyzer/script_entity.py
# class ScriptEntity(Model):
# 	def __init__(self, character, text, type="speech"):
# 		self.character = character
# 		self.type = type
# 		self.original_text = text
# 
# 		self.text = text.rstrip().replace('\n', ' ') if type == 'speech' else text
# 
# 	def __str__(self):
# 		return "type: {}, character: {}, text: \"{}\"".format(self.type, self.character, self.text)
# 
# 	def __repr__(self):
# 		return self.__str__()
# 
# 	@classmethod
# 	def from_dict(cls, data, from_camel=True):
# 		d = Model.from_dict(data, from_camel)
# 		return cls(d.get("character"), d.get("text"), type=d.get("type"))
# 
# 	@classmethod
# 	def from_dicts(cls, data, from_camel=True):
# 		return [cls.from_dict(d) for d in data]
# 
# Path: analyzer/subtitles_parser.py
# class Subtitle(Model):
# 	def __init__(self, t1, t2, text, original_text=None, character=None):
# 		self.t1 = Timestamp(t1) if (type(t1) == int) else t1
# 		self.t2 = Timestamp(t2) if (type(t2) == int) else t2
# 		self.text = text
# 		self.original_text = text if text is not None else original_text
# 		self.character = character
# 
# 	def __str__(self):
# 		return "t1: {}, t2: {}, text: {}, character: {}".format(self.t1, self.t2, self.text, self.character)
# 
# 	def __repr__(self):
# 		return self.__str__()
# 
# 	def as_dict(self, camel=True):
# 		d = Model.as_dict(self)
# 		d["t1"] = self.t1.millis
# 		d["t2"] = self.t2.millis
# 
# 		return d
# 
# 	def to_mongo_dict(self):
# 		d = self.as_dict()
# 		return utils.to_mongo_dict(d)
# 
# 	@classmethod
# 	def from_dict(cls, data, from_camel=True):
# 		d = Model.from_dict(data, from_camel)
# 
# 		return cls(d["t1"], d["t2"], d["text"], d["original_text"], d["character"])
# 
# Path: analyzer/logger.py
# class Logger(object):
# 	def __init__(self, project, verbose=True):
# 		self.project = project
# 		self.verbose = verbose
# 		self.messages = []
# 
# 	def add(self, message, end="\n"):
# 		print(message)
# 		self.messages.append(message)
# 		self.messages.append(end)
# 
# 	def write(self):
# 		formatted_date = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d_%H-%M-%S')
# 		path = self.project.file_path(formatted_date + ".txt")
# 		with open(path, "w") as log:
# 			log.write("".join(self.messages))


# Path: tests/test_dtw_voting.py
import unittest
from analyzer import dtw_merger as dtw
from analyzer.script_entity import ScriptEntity
from analyzer.subtitles_parser import Subtitle
from analyzer.logger import Logger

# -*- coding: utf-8 -*-



class DtwMergerTest(unittest.TestCase):
	"""Some test case"""

	def setUp(self):
		self._sut = dtw.perform
		self._logger = Logger(None)

	def test_1(self):
		subtitles = [

			Subtitle(0, 0, "You're playing music?"),