<commit_before>from . import tool_labs_utils

sql = tool_labs_utils

def CanonicalPageTitle(raw_input):
	output = raw_input.replace(' ', '_')
	output = output[0].upper() + output[1:]
	return output

def WikipediaQuery(language, sqlquery):
	return sql.WMFReplica().query(language + 'wiki', sqlquery, None)

def GetPageId(language, pagetitle):
	pagetitle = CanonicalPageTitle(pagetitle)
	q = 'select page_id from page where page_namespace = 0 and page_title = "{0}";'.format(pagetitle)
	result = WikipediaQuery(language, q)
	if result == []:
		return None
	else:
		return result[0][0]

def GetCategories(language, pageid):
	q = 'select cl_to from categorylinks where cl_from = {0};'.format(pageid)
	result = WikipediaQuery(language, q)
	if result == []:
		return ''
	else:
		output = ''
		for entry in result[0]:
			output += entry.decode('utf-8').replace('_', ' ') + '\n'
		return output

def GetWikiProjects(language, pagetitle):
	pagetitle = CanonicalPageTitle(pagetitle)
	q = 'select pi_project from projectindex where pi_page = "{0}";'.format('Talk:' + pagetitle)
	result = sql.ToolsDB().query('s52475__wpx', q, None)
	if result == []:
		return ''
	else:
		output = ''
		for entry in result[0]:
			output += entry.replace('_', ' ').replace('Wikipedia:', '')
		return output<commit_msg>Put the [0] in the wrong place<commit_after>from . import tool_labs_utils

sql = tool_labs_utils

def CanonicalPageTitle(raw_input):
	output = raw_input.replace(' ', '_')
	output = output[0].upper() + output[1:]
	return output

def WikipediaQuery(language, sqlquery):
	return sql.WMFReplica().query(language + 'wiki', sqlquery, None)

def GetPageId(language, pagetitle):
	pagetitle = CanonicalPageTitle(pagetitle)
	q = 'select page_id from page where page_namespace = 0 and page_title = "{0}";'.format(pagetitle)
	result = WikipediaQuery(language, q)
	if result == []:
		return None
	else:
		return result[0][0]

def GetCategories(language, pageid):
	q = 'select cl_to from categorylinks where cl_from = {0};'.format(pageid)
	result = WikipediaQuery(language, q)
	if result == []:
		return ''
	else:
		output = ''
		for entry in result:
			output += entry[0].decode('utf-8').replace('_', ' ') + '\n'
		return output

def GetWikiProjects(language, pagetitle):
	pagetitle = CanonicalPageTitle(pagetitle)
	q = 'select pi_project from projectindex where pi_page = "{0}";'.format('Talk:' + pagetitle)
	result = sql.ToolsDB().query('s52475__wpx', q, None)
	if result == []:
		return ''
	else:
		output = ''
		for entry in result:
			output += entry[0].replace('_', ' ').replace('Wikipedia:', '')
		return output
{'fraction_non_alphanumeric': 0.15117624373312766, 'fraction_numerical': 0.012726571538758195, 'mean_word_length': 4.990762124711316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '839232', 'n_tokens_mistral': 931, 'n_tokens_neox': 888, 'n_words': 221}