<commit_before>import re

class Resolver:

	def run(self, file):
		if self.is_spec(file):
			return self.get_source(file)
		else:
			return self.get_spec(file)

	def is_spec(self, file):
		return file.find('_spec.rb') != -1

	def get_source(self, file):
		# find erb, haml
		match = re.search(r'(.erb|.haml)_spec.rb$', file)
		related = []

		if match:
			ext = match.group(0)
			regex = re.escape(ext)
			ext = re.sub(r'_spec.rb', '', ext)
			file = re.sub(regex, ext, file)
		else:
			# simply sub .rb to _spec.rb
			# e.g. foo.rb -> foo_spec.rb
			file = re.sub(r'\_spec.rb$', '.rb', file)

		if file.find('/spec/lib/') > -1:
			# file in lib
			related.append(re.sub(r'/spec/lib/', '/lib/', file))
		else:
			related.append(re.sub(r'/spec/', '/app/', file, 1))
			related.append(re.sub(r'/spec/', '/', file, 1))

		return related


	def get_spec(self, file):
		# find erb, haml
		match = re.search(r'erb$|haml$', file)
		related = []

		if match:
			ext = match.group(0)
			regex = re.escape(ext) + "$"
			file = re.sub(regex, ext + '_spec.rb', file)
		else:
			file = re.sub(r'\.rb$', '_spec.rb', file)

		if file.find('/lib/') > -1:
			related.append(re.sub(r'/lib/', '/spec/lib/', file))
		elif file.find('/app/') > -1:
			related.append(re.sub(r'/app/', '/spec/', file, 1))
		else:
			related.append('/spec' + file)

		return related<commit_msg>Add slim support to resolver.py<commit_after>import re

class Resolver:

	def run(self, file):
		if self.is_spec(file):
			return self.get_source(file)
		else:
			return self.get_spec(file)

	def is_spec(self, file):
		return file.find('_spec.rb') != -1

	def get_source(self, file):
		# find erb, haml
		match = re.search(r'(.erb|.haml|.slim)_spec.rb$', file)
		related = []

		if match:
			ext = match.group(0)
			regex = re.escape(ext)
			ext = re.sub(r'_spec.rb', '', ext)
			file = re.sub(regex, ext, file)
		else:
			# simply sub .rb to _spec.rb
			# e.g. foo.rb -> foo_spec.rb
			file = re.sub(r'\_spec.rb$', '.rb', file)

		if file.find('/spec/lib/') > -1:
			# file in lib
			related.append(re.sub(r'/spec/lib/', '/lib/', file))
		else:
			related.append(re.sub(r'/spec/', '/app/', file, 1))
			related.append(re.sub(r'/spec/', '/', file, 1))

		return related


	def get_spec(self, file):
		# find erb, haml
		match = re.search(r'erb$|haml$|slim$', file)
		related = []

		if match:
			ext = match.group(0)
			regex = re.escape(ext) + "$"
			file = re.sub(regex, ext + '_spec.rb', file)
		else:
			file = re.sub(r'\.rb$', '_spec.rb', file)

		if file.find('/lib/') > -1:
			related.append(re.sub(r'/lib/', '/spec/lib/', file))
		elif file.find('/app/') > -1:
			related.append(re.sub(r'/app/', '/spec/', file, 1))
		else:
			related.append('/spec' + file)

		return related
{'fraction_non_alphanumeric': 0.21235380116959066, 'fraction_numerical': 0.006578947368421052, 'mean_word_length': 2.915593705293276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5642364', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1123, 'n_words': 241}