<commit_before>---
layout: null
---
function str_sim (a, b) {
	if (!a || !b || a.length ==0 || b.length ==0 ) {
		return 0.0
	}
	a = a.toUpperCase()
	b = b.toUpperCase()
	if (a.indexOf(b)>=0 || b.indexOf(a)>=0) {
		return 1.0;
	}
	var min = a.length>b.length ? b.length: a.length
	var intersect = 0.0
	for(var i = 0; i < a.length - 1; i++ ){
		for(var j = 0; j < b.length - 1 ; j++ )
			if (a.substr(i,2) == b.substr(j,2))
				intersect +=1
	}
	return intersect / min;
}
$(function(){
	var today = "{{ site.time | date: "%Y%d" }}"
	var feed_url = "{{ site.url }}/feed.json?date=" + today
	
	var args = window.location.search.split('&')
	var query_search = ''
	for (var i = 0; i<args.length; i++) 
		if(args[i].indexOf('q=') >= 0)
			query_search = args[i];
	if( query_search ) {
	  var query = decodeURI(query_search.split('=')[1])
	  $.getJSON(feed_url, function(posts) {
		$.each(posts,function(idx, post) {
			if( str_sim (query, post.title) >= 0.9 ){
				var li='<li class="entry-title"><a href="' + post.url +'">' + post.title+ '</a></li>'
				$('#search-ul').append(li)
			}
		})
		switch($('#search-ul li').size()){
			case 0 : 
                $('#search-results').hide()
                $('#no-search-results').show()
                setTimeout(function(){
                    window.location.href="{{site.url}}/posts.html"
                }, 1500)
			case 1 : 
                $('#no-search-results').hide()
                $('#search-results').show()
                $('#search-ul li a')[0].click();
			default: 
                $('#no-search-results').hide()
                $('#search-results').show()
		}
	})
	}

})<commit_msg>update search.js<commit_after>---
layout: null
---
function str_sim (a, b) {
	if (!a || !b || a.length ==0 || b.length ==0 ) {
		return 0.0
	}
	a = a.toUpperCase()
	b = b.toUpperCase()
	if (a.indexOf(b)>=0 || b.indexOf(a)>=0) {
		return 1.0;
	}
	var min = a.length>b.length ? b.length: a.length
	var intersect = 0.0
	for(var i = 0; i < a.length - 1; i++ ){
		for(var j = 0; j < b.length - 1 ; j++ )
			if (a.substr(i,2) == b.substr(j,2))
				intersect +=1
	}
	return intersect / min;
}
$(function(){
	var today = "{{ site.time | date: "%Y%d" }}"
	var feed_url = "{{ site.url }}/feed.json?date=" + today
	
	var args = window.location.search.split('&')
	var query_search = ''
	for (var i = 0; i<args.length; i++) 
		if(args[i].indexOf('q=') >= 0)
			query_search = args[i];
	if( query_search ) {
	  var query = decodeURI(query_search.split('=')[1])
	  $.getJSON(feed_url, function(posts) {
		$.each(posts,function(idx, post) {
			if( str_sim (query, post.title) >= 0.9 ){
				var li='<li class="entry-title"><a href="' + post.url +'">' + post.title+ '</a></li>'
				$('#search-ul').append(li)
			}
		})
		switch($('#search-ul li').size()){
			case 0 : 
                $('#search-results').hide()
                $('#no-search-results').show()
                setTimeout(function(){
                    window.location.href="{{site.url}}/posts.html"
                }, 1500)
                break;
			case 1 : 
                $('#no-search-results').hide()
                $('#search-results').show()
                $('#search-ul li a')[0].click();
                break;
			default: 
                $('#no-search-results').hide()
                $('#search-results').show()
		}
	})
	}else window.location.href="{{site.url}}/posts.html";

})
{'fraction_non_alphanumeric': 0.2270174401418859, 'fraction_numerical': 0.017144546260715342, 'mean_word_length': 2.256977863330125, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '2927617', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1234, 'n_words': 249}