<commit_before>/*!
Name: Reading Time
Dependencies: jQuery
Author: <NAME>
Author URL: http://michaelynch.com
Date Created: August 14, 2013
Date Updated: April 30, 2018
Licensed under the MIT license
*/

;(function($) {

	$.fn.readingTime = function(options) {

		// define default parameters
		const defaults = {
			readingTimeTarget: '.eta',
			readingTimeAsNumber: false,
			wordCountTarget: null,
			wordsPerMinute: 270,
			round: true,
			lang: 'en',
			lessThanAMinuteString: '',
			prependTimeString: '',
			prependWordString: '',
			remotePath: null,
			remoteTarget: null,
			success: function() {},
			error: function() {}
		};

		const plugin = this;
		const el = $(this);

		let wordsPerSecond;
		let lessThanAMinute;
		let minShortForm;

		let totalWords;
		let totalReadingTimeSeconds;

		let readingTimeMinutes;
		let readingTimeSeconds;
		let readingTime;
		let readingTimeObj;

		// merge defaults and options
		plugin.settings = $.extend({}, defaults, options);

		// define vars
		const s = plugin.settings;

		const setTime = function(o) {

			if(o.text !== '') {
				if (s.lang == "zh") {
                	let text = o.text.trim();
                	// step 1: count the number of Chinese characters
					const charArray = text.match(/[\u4e00-\u9fa5]/g);
					let charCount = 0;
					if (charArray != null) {
						charCount = charArray.length;
					}
					// step 2: replace all the Chinese characters with blank
					text = text.replace(/[\u4e00-\u9fa5]/g, " ");
					// step 3:replace newlines with blank
					text = text.replace(/[\r\n]/g, " ");
					// step 4:replace special characters with blank
					text = text.replace(/\W+/g, " ");
					// step 5: count the number of total English words
					const totalEnWords = text.trim().split(/\s+/g).length;
					totalWords = totalEnWords + charCount;
				} else {
					//split text by spaces to define total words
					totalWords = o.text.trim().split(/\s+/g).length;
				}

				//define words per second based on words per minute (s.wordsPerMinute)
				wordsPerSecond = s.wordsPerMinute / 60;

				//define total reading time in seconds<commit_msg>Enhancement: change code style<commit_after>/*!
Name: Reading Time
Dependencies: jQuery
Author: <NAME>
Author URL: http://michaelynch.com
Date Created: August 14, 2013
Date Updated: April 30, 2018
Licensed under the MIT license
*/

;(function($) {

	$.fn.readingTime = function(options) {

		// define default parameters
		const defaults = {
			readingTimeTarget: '.eta',
			readingTimeAsNumber: false,
			wordCountTarget: null,
			wordsPerMinute: 270,
			round: true,
			lang: 'en',
			lessThanAMinuteString: '',
			prependTimeString: '',
			prependWordString: '',
			remotePath: null,
			remoteTarget: null,
			success: function() {},
			error: function() {}
		};

		const plugin = this;
		const el = $(this);

		let wordsPerSecond;
		let lessThanAMinute;
		let minShortForm;

		let totalWords;
		let totalReadingTimeSeconds;

		let readingTimeMinutes;
		let readingTimeSeconds;
		let readingTime;
		let readingTimeObj;

		// merge defaults and options
		plugin.settings = $.extend({}, defaults, options);

		// define vars
		const s = plugin.settings;

		const setTime = function(o) {

			if(o.text !== '') {
				if (s.lang == "zh") {
					let text = o.text.trim();
					// step 1: count the number of Chinese characters
					const charArray = text.match(/[\u4e00-\u9fa5]/g);
					let charCount = 0;
					if (charArray != null) {
						charCount = charArray.length;
					}
					// step 2: replace all the Chinese characters with blank
					text = text.replace(/[\u4e00-\u9fa5]/g, " ");
					// step 3:replace newlines with blank
					text = text.replace(/[\r\n]/g, " ");
					// step 4:replace special characters with blank
					text = text.replace(/\W+/g, " ");
					// step 5: count the number of total English words
					const totalEnWords = text.trim().split(/\s+/g).length;
					totalWords = totalEnWords + charCount;
				} else {
					//split text by spaces to define total words
					totalWords = o.text.trim().split(/\s+/g).length;
				}

				//define words per second based on words per minute (s.wordsPerMinute)
				wordsPerSecond = s.wordsPerMinute / 60;

				//define total reading time in seconds
{'fraction_non_alphanumeric': 0.12833845426613094, 'fraction_numerical': 0.015599149137319782, 'mean_word_length': 2.8683729433272394, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2085391', 'n_tokens_mistral': 1668, 'n_tokens_neox': 1294, 'n_words': 390}