<commit_before><?php

/**
 * Global database context
 * @var Nin\Database\Context|false
 */
$nf_db_context = false;

/**
 * Creates the database context from the class name given in the configuration.
 * Gets called from nf_begin_internal().
 */
function nf_db_initialize()
{
	global $nf_cfg;
	global $nf_db_context;

	if(isset($nf_cfg['mysql'])) {
		$nf_cfg['db']['class'] = 'MySQL';
		$nf_cfg['db']['options'] = $nf_cfg['mysql'];
	} elseif(isset($nf_cfg['postgres'])) {
		$nf_cfg['db']['class'] = 'Postgres';
		$nf_cfg['db']['options'] = $nf_cfg['postgres'];
	}

	$class_name = $nf_cfg['db']['class'];
	$class_name_internal = 'Nin\\Database\\Contexts\\' . $class_name;

	$options = $nf_cfg['db']['options'];

	if(class_exists($class_name)) {
		$nf_db_context = new $class_name($options);
	} elseif(class_exists($class_name_internal)) {
		$nf_db_context = new $class_name_internal($options);
	} else {
		nf_error(12, $class_name . ', ' . $class_name_internal);
		return;
	}
}

/**
 * Helper function for getting the global database context.
 */
function nf_db_context()<commit_msg>Added SQLite shorthand setting<commit_after><?php

/**
 * Global database context
 * @var Nin\Database\Context|false
 */
$nf_db_context = false;

/**
 * Creates the database context from the class name given in the configuration.
 * Gets called from nf_begin_internal().
 */
function nf_db_initialize()
{
	global $nf_cfg;
	global $nf_db_context;

	if(isset($nf_cfg['mysql'])) {
		$nf_cfg['db']['class'] = 'MySQL';
		$nf_cfg['db']['options'] = $nf_cfg['mysql'];
	} elseif(isset($nf_cfg['postgres'])) {
		$nf_cfg['db']['class'] = 'Postgres';
		$nf_cfg['db']['options'] = $nf_cfg['postgres'];
	} elseif(isset($nf_cfg['sqlite'])) {
		$nf_cfg['db']['class'] = 'SQLite';
		$nf_cfg['db']['options'] = $nf_cfg['sqlite'];
	}

	$class_name = $nf_cfg['db']['class'];
	$class_name_internal = 'Nin\\Database\\Contexts\\' . $class_name;

	$options = $nf_cfg['db']['options'];

	if(class_exists($class_name)) {
		$nf_db_context = new $class_name($options);
	} elseif(class_exists($class_name_internal)) {
		$nf_db_context = new $class_name_internal($options);
	} else {
		nf_error(12, $class_name . ', ' . $class_name_internal);
		return;
	}
}

/**
 * Helper function for getting the global database context.
 */
function nf_db_context()
{'fraction_non_alphanumeric': 0.19618055555555555, 'fraction_numerical': 0.001736111111111111, 'mean_word_length': 5.43854748603352, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6490937', 'n_tokens_mistral': 858, 'n_tokens_neox': 837, 'n_words': 147}