<commit_before><!DOCTYPE html>
<html>
	<head>
        <title>Taxon search by suggestions</title>
		<meta charset="utf-8">
        <link href="vendor/css/ui-lightness/jquery-ui-1.10.3.custom.min.css" rel="stylesheet">
        <script type="text/javascript" src="vendor/jquery-2.0.3.min.js"></script>
        <script type="text/javascript" src="vendor/jquery-ui-1.10.3.custom.min.js"></script>
        <script type="text/javascript">
            ( function( $ ) {
                var proto = $.ui.autocomplete.prototype,
                    initSource = proto._initSource;

                function filter( array, term ) {
                    var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), 'i' );
                    return $.grep( array, function( value ) {
                        return matcher.test( $( '<div>' ).html( value.label || value.value || value ).text() );
                    } );
                }

                $.extend( proto, {
                    _initSource: function() {
                        if ( this.options.html && $.isArray( this.options.source ) ) {
                            this.source = function( request, response ) {
                                response( filter( this.options.source, request.term ) );
                            };
                        }
                        else {
                            initSource.call( this );
                        }
                    },

                    _renderItem: function( ul, item ) {
                        return $( '<li></li>' )
                                .data( 'item.autocomplete', item )
                                .append( $( '<a></a>' )[ this.options.html ? 'html' : 'text' ]( item.label ) )
                                .appendTo( ul );
                    }
                } );
            } )( jQuery );
        </script>
		<script type="text/javascript" charset="utf-8">
            var baseUrl = 'http://trophicgraph.com:8080/findCloseMatchesForTaxon/';

            function filterForCommonName( content, languageCode ) {
                if ( !content.length ) {
                    return '';
                }
                var commonNames = {}, item;
                content = content.split( '|' );

                content.forEach( function( item ) {
                    item = item.trim().split( '@' );
                    if ( item[ 0 ].length ) {
                        if ( item.length > 1 ) {
                            commonNames[ item[ 1 ].trim() ] = item[ 0 ].trim();
                        }
                        else if ( item.length === 1 ) {
                            commonNames[ languageCode ] = item[ 0 ].trim();
                        }
                    }
                } );

                if ( commonNames[ languageCode ] ) {
                    return commonNames[ languageCode ];
                }
                else {
                    return '';
                }
            }

            jQuery( function() {
                $( '#taxon-name' )
                    .autocomplete( {
                        source: function( request, response ) {
                            jQuery.ajax( {
                                url: baseUrl + encodeURIComponent( request.term )
                            } ).done( function( resp ) {
                                var data = resp.data;
                                data = jQuery.grep( data, function( item ) {
                                    return item[ 0 ].toLowerCase().indexOf( request.term ) !== -1;
                                } );
                                response(
                                    jQuery.map( data, function( item ) {
                                        return {
                                            label: '<div class="scientific-name" style="font-style: italic;">' + item[ 0 ] + '</div><div class="common-name" style="font-size: 11px;">' + filterForCommonName( item[ 1 ], 'en' ) + '</div>',
                                            value: item[ 0 ].toLowerCase()<commit_msg>[TASK] Switch order of scientific and common name - biologists need this ;)<commit_after><!DOCTYPE html>
<html>
	<head>
        <title>Taxon search by suggestions</title>
		<meta charset="utf-8">
        <link href="vendor/css/ui-lightness/jquery-ui-1.10.3.custom.min.css" rel="stylesheet">
        <script type="text/javascript" src="vendor/jquery-2.0.3.min.js"></script>
        <script type="text/javascript" src="vendor/jquery-ui-1.10.3.custom.min.js"></script>
        <script type="text/javascript">
            ( function( $ ) {
                var proto = $.ui.autocomplete.prototype,
                    initSource = proto._initSource;

                function filter( array, term ) {
                    var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), 'i' );
                    return $.grep( array, function( value ) {
                        return matcher.test( $( '<div>' ).html( value.label || value.value || value ).text() );
                    } );
                }

                $.extend( proto, {
                    _initSource: function() {
                        if ( this.options.html && $.isArray( this.options.source ) ) {
                            this.source = function( request, response ) {
                                response( filter( this.options.source, request.term ) );
                            };
                        }
                        else {
                            initSource.call( this );
                        }
                    },

                    _renderItem: function( ul, item ) {
                        return $( '<li></li>' )
                                .data( 'item.autocomplete', item )
                                .append( $( '<a></a>' )[ this.options.html ? 'html' : 'text' ]( item.label ) )
                                .appendTo( ul );
                    }
                } );
            } )( jQuery );
        </script>
		<script type="text/javascript" charset="utf-8">
            var baseUrl = 'http://trophicgraph.com:8080/findCloseMatchesForTaxon/';

            function filterForCommonName( content, languageCode ) {
                if ( !content.length ) {
                    return '';
                }
                var commonNames = {}, item;
                content = content.split( '|' );

                content.forEach( function( item ) {
                    item = item.trim().split( '@' );
                    if ( item[ 0 ].length ) {
                        if ( item.length > 1 ) {
                            commonNames[ item[ 1 ].trim() ] = item[ 0 ].trim();
                        }
                        else if ( item.length === 1 ) {
                            commonNames[ languageCode ] = item[ 0 ].trim();
                        }
                    }
                } );

                if ( commonNames[ languageCode ] ) {
                    return commonNames[ languageCode ] + ' ';
                }
                else {
                    return '';
                }
            }

            jQuery( function() {
                $( '#taxon-name' )
                    .autocomplete( {
                        source: function( request, response ) {
                            jQuery.ajax( {
                                url: baseUrl + encodeURIComponent( request.term )
                            } ).done( function( resp ) {
                                var data = resp.data;
                                data = jQuery.grep( data, function( item ) {
                                    return item[ 0 ].toLowerCase().indexOf( request.term ) !== -1;
                                } );
                                response(
                                    jQuery.map( data, function( item ) {
                                        return {
                                            label: '<div><span class="common-name">' + filterForCommonName( item[ 1 ], 'en' ) + '</span><span class="scientific-name" style="font-style: italic;">(' + item[ 0 ] + ')</span></div>',
                                            value: item[ 0 ].toLowerCase()
{'fraction_non_alphanumeric': 0.12551640340218712, 'fraction_numerical': 0.0070473876063183475, 'mean_word_length': 0.9790815099783602, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '756253', 'n_tokens_mistral': 2049, 'n_tokens_neox': 1877, 'n_words': 406}