<commit_before>/*!
 * Pattern Finder
 *
 * Copyright (c) 2014 <NAME>, http://dmolsen.com
 * Licensed under the MIT license
 *
 */

var patternFinder = {
	
	data:   [],
	active: false,
	
	init: function() {
		
		for (var patternType in patternPaths) {
			if (patternPaths.hasOwnProperty(patternType)) {
				for (var pattern in patternPaths[patternType]) {
					var obj = {};
					obj.patternPartial = patternType+"-"+pattern;
					obj.patternPath    = patternPaths[patternType][pattern];
					this.data.push(obj);
				}
			}
		}
		
		// instantiate the bloodhound suggestion engine
		var patterns = new Bloodhound({
			datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.patternPartial); },
			queryTokenizer: Bloodhound.tokenizers.whitespace,
			limit: 10,
			local: this.data
		});

		// initialize the bloodhound suggestion engine
		patterns.initialize();

		$('#sg-find .typeahead').typeahead({ highlight: true }, {
			displayKey: 'patternPartial',
			source: patterns.ttAdapter()
		}).on('typeahead:selected', patternFinder.onAutocompleted).on('typeahead:autocompleted', patternFinder.onSelected);
		
	},
	
	passPath: function(item) {
		// update the iframe via the history api handler
		patternFinder.closeFinder();
		var obj = JSON.stringify({ "path": urlHandler.getFileName(item.patternPartial) });
		document.getElementById("sg-viewport").contentWindow.postMessage(obj, urlHandler.targetOrigin);
	},
	
	onSelected: function(e,item) {
		patternFinder.passPath(item);
	},
	
	onAutocompleted: function(e,item) {
		patternFinder.passPath(item);
	},
	
	toggleFinder: function() {<commit_msg>making the search options more flexible<commit_after>/*!
 * Pattern Finder
 *
 * Copyright (c) 2014 <NAME>, http://dmolsen.com
 * Licensed under the MIT license
 *
 */

var patternFinder = {
	
	data:   [],
	active: false,
	
	init: function() {
		
		for (var patternType in patternPaths) {
			if (patternPaths.hasOwnProperty(patternType)) {
				for (var pattern in patternPaths[patternType]) {
					var obj = {};
					obj.patternPartial = patternType+"-"+pattern;
					obj.patternPath    = patternPaths[patternType][pattern];
					this.data.push(obj);
				}
			}
		}
		
		// instantiate the bloodhound suggestion engine
		var patterns = new Bloodhound({
			datumTokenizer: function(d) { return Bloodhound.tokenizers.nonword(d.patternPartial); },
			queryTokenizer: Bloodhound.tokenizers.nonword,
			limit: 10,
			local: this.data
		});

		// initialize the bloodhound suggestion engine
		patterns.initialize();

		$('#sg-find .typeahead').typeahead({ highlight: true }, {
			displayKey: 'patternPartial',
			source: patterns.ttAdapter()
		}).on('typeahead:selected', patternFinder.onAutocompleted).on('typeahead:autocompleted', patternFinder.onSelected);
		
	},
	
	passPath: function(item) {
		// update the iframe via the history api handler
		patternFinder.closeFinder();
		var obj = JSON.stringify({ "path": urlHandler.getFileName(item.patternPartial) });
		document.getElementById("sg-viewport").contentWindow.postMessage(obj, urlHandler.targetOrigin);
	},
	
	onSelected: function(e,item) {
		patternFinder.passPath(item);
	},
	
	onAutocompleted: function(e,item) {
		patternFinder.passPath(item);
	},
	
	toggleFinder: function() {
{'fraction_non_alphanumeric': 0.13423645320197045, 'fraction_numerical': 0.003694581280788177, 'mean_word_length': 4.1900958466453675, 'pattern_counts': {'":': 2, '<': 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': '1995531', 'n_tokens_mistral': 1140, 'n_tokens_neox': 987, 'n_words': 207}