<commit_before>'use strict';

/**
* Returns a function to retrieve the current learning rate.
*
* @param {string} type - string denoting the learning rate to use. Can be `constant`, `pegasos` or `basic`.
* @param {PositiveNumber} eta0 - constant learning rate
* @param {NonNegativeNumber} lambda - regularization parameter
* @throws {Error} first argument must be `basic`, `constant` or `pegasos`
* @returns {Function} getEta function
*/
function closure( type, eta0, lambda ) {
	var ret;
	var _it;

	_it = 1;

	switch ( type ) {
	case 'basic':
		// Default case: 'basic'
		ret = function getEta() {
			var eta = 1000.0 / ( _it + 1000.0 );
			_it += 1;
			return eta;
		};
	break;
	case 'constant':
		ret = function getEta() {
			_it += 1;
			return eta0;
		};
	break;
	case 'pegasos':
		ret = function getEta() {
			var eta = 1.0 / ( lambda * _it );
			_it += 1;
			return eta;
		};
	break;
	default:
		throw Error( 'invalid input value. `learningRate` must be either `basic`, `constant` or `pegasos`. Value: `' + type + '`' );
	}

	return ret;
} // end FUNCTION closure()


// EXPORTS //

module.exports = closure;<commit_msg>Refactor and fix lint errors<commit_after>'use strict';

// MODULES //

var constantFunction = require( '@stdlib/utils/constant-function' );


// FUNCTIONS //

/**
* Returns a function to retrieve a learning rate.
*
* @private
* @returns {Function} function to retrieve learning rate
*/
function basic() {
	var i = 1;
	return getEta;

	/**
	* Returns a learning rate.
	*
	* @private
	* @returns {number} learning rate
	*/
	function getEta() {
		var eta = 1000.0 / ( i + 1000.0 );
		i += 1;
		return eta;
	} // end FUNCTION getEta()
} // end FUNCTION basic()

/**
* Returns a function to retrieve a learning rate.
*
* @private
* @param {NonNegativeNumber} lambda - regularization parameter
* @returns {Function} function to retrieve learning rate
*/
function pegasos( lambda ) {
	var i = 1;
	return getEta;

	/**
	* Returns a learning rate.
	*
	* @private
	* @returns {number} learning rate
	*/
	function getEta() {
		var eta = 1.0 / ( lambda * i );
		i += 1;
		return eta;
	} // end FUNCTION getEta()
} // end FUNCTION pegasos()


// MAIN //

/**
* Returns a function to retrieve the current learning rate.
*
* @param {string} type - string denoting the learning rate to use
* @param {PositiveNumber} eta0 - constant learning rate
* @param {NonNegativeNumber} lambda - regularization parameter
* @throws {Error} first argument must be a recognized learning rate
* @returns {Function} function to retrieve current learning rate
*/
function getEta( type, eta0, lambda ) {
	if ( type === 'basic' ) {
		return basic();
	}
	else if ( type === 'constant' ) {
		return constantFunction( eta0 );
	}
	else if ( type === 'pegasos' ) {
		return pegasos( lambda );
	}
	throw Error( 'invalid input value. First argument must be a recognized learning rate. Value: `' + type + '`.' );
} // end FUNCTION getEta()


// EXPORTS //

module.exports = getEta;
{'fraction_non_alphanumeric': 0.13958192852326365, 'fraction_numerical': 0.012811867835468645, 'mean_word_length': 3.2690647482014388, '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': '6746971', 'n_tokens_mistral': 1054, 'n_tokens_neox': 977, 'n_words': 341}