<commit_before>(function (callback){
  if (typeof define === 'function' && define.amd){
    define(['core/AbstractTextWidget', 'jquery'], callback);
  }
  else {
    callback();
  }
}(function (){

/**
 * Widget for advanced search form 
 *
 * @class AdvancedSearchWidget
 * @augments AjaxSolr.AbstractTextWidget
 */
(function ($) {

  AjaxSolr.AdvancedSearchWidget = AjaxSolr.AbstractTextWidget.extend({
    init: function () {
      var self = this;

      if(!!self.limit){
        self.manager.store.get('limit').val(this.limit)
      }

      $(this.target).submit(function(e) {
        var target = this;
        self.search(target);

        return false; 
      });

      // initをオーバーロードするときはselfを返さないとrequireがエラーになる
      return self;
    },
    buildQuery: function (target){
      var self = this;
      /* キーワードのクエリを生成 */
      var keyword = $(target).find("#keyword").val();
      var query_keyword = keyword.match(/^\s*$/) ? "" : "__any__:(" + keyword + ")";

      /* テキストフィールドの値からクエリを生成 */
      var advanced_query = self.createFieldsQuery(target);

      /* 資料種別の絞り込み */
      var media_type_query = self.createMediaTypeQuery(target);

      /* 最終的なクエリの生成 */
      query = $([query_keyword.replace(/(\s|　)+/,"+"), advanced_query, media_type_query]).filter(function (){ return this != ""; }).get().join(" AND ");
      if (query.match(/^\s*$/)){
        query = "*:*"
      }

      return query;
    },
    search: function (target){
      var self = this;
      var query = self.buildQuery(target);

      /* 検索の実行 */
      if (self.set(query)) {
        self.doRequest();
      }

      return false;
    },
    afterRequest: function (){
      $("#home").hide();
      $("#main").show();
      $('body').addClass('searching');

      var keyword = this.manager.store.get('q').value.match(/__any__:([^\s\&]+)/);
      if(keyword != null && keyword.length > 1){
        $("#keyword").val(keyword[1].replace(/\+/g, " "));
      }else{
        $("#keyword").val("");
      }<commit_msg>bug fix: AdvancedSearchWidget#search failures to escape \s (#2)<commit_after>(function (callback){
  if (typeof define === 'function' && define.amd){
    define(['core/AbstractTextWidget', 'jquery'], callback);
  }
  else {
    callback();
  }
}(function (){

/**
 * Widget for advanced search form 
 *
 * @class AdvancedSearchWidget
 * @augments AjaxSolr.AbstractTextWidget
 */
(function ($) {

  AjaxSolr.AdvancedSearchWidget = AjaxSolr.AbstractTextWidget.extend({
    init: function () {
      var self = this;

      if(!!self.limit){
        self.manager.store.get('limit').val(this.limit)
      }

      $(this.target).submit(function(e) {
        var target = this;
        self.search(target);

        return false; 
      });

      // initをオーバーロードするときはselfを返さないとrequireがエラーになる
      return self;
    },
    buildQuery: function (target){
      var self = this;
      /* キーワードのクエリを生成 */
      var keyword = $(target).find("#keyword").val();
      var query_keyword = keyword.match(/^\s*$/) ? "" : "__any__:(" + keyword + ")";

      /* テキストフィールドの値からクエリを生成 */
      var advanced_query = self.createFieldsQuery(target);

      /* 資料種別の絞り込み */
      var media_type_query = self.createMediaTypeQuery(target);

      /* 最終的なクエリの生成 */
      query = $([query_keyword.replace(/(\s|　|(?:AND))+/g,"+"), advanced_query, media_type_query]).filter(function (){ return this != ""; }).get().join(" AND ");
      if (query.match(/^\s*$/)){
        query = "*:*"
      }

      return query;
    },
    search: function (target){
      var self = this;
      var query = self.buildQuery(target);

      /* 検索の実行 */
      if (self.set(query)) {
        self.doRequest();
      }

      return false;
    },
    afterRequest: function (){
      $("#home").hide();
      $("#main").show();
      $('body').addClass('searching');

      var keyword = this.manager.store.get('q').value.match(/__any__:([^\s\&]+)/);
      if(keyword != null && keyword.length > 1){
        $("#keyword").val(keyword[1].replace(/\+/g, " "));
      }else{
        $("#keyword").val("");
      }
{'fraction_non_alphanumeric': 0.1906519065190652, 'fraction_numerical': 0.0012300123001230013, 'mean_word_length': 2.5142610198789974, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1199682', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1361, 'n_words': 226}