Changeset 31613


Ignore:
Timestamp:
04/20/17 17:55:58 (4 years ago)
Author:
davidb
Message:

Multiple word support in POS search box. Tidy up of anchor for search results

Location:
other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/HTRC_Mashup--Home_files/main.css

    r31601 r31613  
    44}
    55body {
    6     padding-top: 60px;
     6    padding-top: 160px;
    77    padding-bottom: 40px;
    88    background-color: rgba(0, 0, 0, 0);
  • other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.html

    r31571 r31613  
    33<meta http-equiv="content-type" content="text/html; charset=windows-1252">
    44
    5         <title>HTRC Extracted Feature Solr Search</title>
     5<title>HTRC Extracted Feature Solr Search</title>
     6<!--
    67        <link rel="shortcut icon" href="https://analytics.hathitrust.org/assets/images/favicon.ico">
     8-->
    79        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    810
     
    270272-->
    271273
    272                 <div id="search-results-anchor">
    273         </div>
    274274
    275275        <fieldset class="show-hide-lang">
     
    288288
    289289    <hr />
    290     <div id="search-results">
     290    <div id="search-results-area" style="position: relative;">
     291      <div id="search-results-anchor" style="position: absolute; top: -90px;">
     292      </div>
     293
     294      <div id="search-results">     
     295      </div>
    291296    </div>
    292297   
  • other-projects/hathitrust/wcsa/extracted-features-solr/trunk/web-portal/index.js

    r31571 r31613  
    4444{
    4545    $('.search-in-progress').css("cursor","wait");
    46    
    47     store_search_args.start += delta;
     46
     47    var start = parseInt(store_search_args.start)
     48   
     49    store_search_args.start = start + parseInt(delta);
    4850       
    4951    $.ajax({
     
    6466
    6567
    66     var babel_url = "https://babel.hathitrust.org/cgi/pt?id="+id+";view=1up;seq="+0;
     68    var babel_url = "https://babel.hathitrust.org/cgi/pt?id="+id+";view=1up;seq="+1;
    6769
    6870    html_item += '<p ' + css_class + '>';
     
    8688    var page = id_pages[pi];
    8789   
    88     var seqnum = page - 1;
     90    //var seqnum = page - 1;
     91    //var seqnum = page + 1;
     92    var seqnum = page;
    8993    var babel_url = "https://babel.hathitrust.org/cgi/pt?id="+id+";view=1up;seq="+seqnum;
    9094
     
    96100
    97101       
    98         html_item += id + ': <a target="_blank" href="' + babel_url + '">page ' + page + '</a> ';
     102        html_item += id + ': <a target="_blank" href="' + babel_url + '">seq ' + seqnum + '</a> ';
    99103        }
    100104        else {
    101         html_item += ', <a target="_blank" href="' + babel_url + '">page ' + page + '</a> ';
     105        html_item += ', <a target="_blank" href="' + babel_url + '">seq ' + seqnum + '</a> ';
    102106       
    103         //var result_item = '<a target="_blank" href="' + babel_url + '">' + id + ', page ' + page + '</a>';
     107        //var result_item = '<a target="_blank" href="' + babel_url + '">' + id + ', seq ' + seqnum + '</a>';
    104108        //result_item += ' <span style="font-style: italic;" name="'+id+'"><span style="cursor: progress;">Loading ...</span></span>';
    105109        //html_item += '<p ' + css_class + '>'+result_item+'</p>';
     
    109113        html_item += '<p ' + css_class + '>';
    110114        html_item += ' <span style="font-style: italic;" name="'+id+'"><span style="cursor: progress;">Loading ...</span></span><br>';
    111         html_item += '<a target="_blank" href="' + babel_url + '">' + id + ', page ' + page + '</a>';
     115        html_item += '<a target="_blank" href="' + babel_url + '">' + id + ', seq ' + seqnum + '</a>';
    112116        html_item += '</p>';
    113117    }
     
    165169    var id_and_page = doc.id.split(".page-");
    166170    var id = id_and_page[0];
    167     var seqnum = parseInt(id_and_page[1]);
    168     var page = seqnum+1;
     171    var seqnum = parseInt(id_and_page[1]) +1; // fix up ingest error
     172    //var page = seqnum+1;
     173    //var page = seqnum-1;
     174    var page = seqnum;
    169175
    170176    if ((prev_id != null) && (id != prev_id)) {
     
    255261    var id_and_page = doc.id.split(".page-");
    256262    var id = id_and_page[0];
    257     var seqnum = parseInt(id_and_page[1]);
    258     var page = seqnum+1;
     263    var seqnum = parseInt(id_and_page[1]) +1; // fix up ingest error
     264    //var page = seqnum+1;
     265    //var page = seqnum-1;
     266    var page = seqnum;
    259267
    260268    if ((prev_id != null) && (id != prev_id)) {
     
    322330
    323331var group_by_vol_checked = 0;
     332
     333
     334function expand_field_lang_pos(q_text,langs_with_pos,langs_without_pos,search_all_checked)
     335{
     336    var fields = [];
     337    var universal_pos_tags = [ "VERB", "NOUN", "ADJ", "ADV", "ADP", "CONJ", "DET", "NUM", "PRT", "X" ];
     338   
     339    for (var li=0; li<langs_with_pos.length; li++) {
     340    var lang = langs_with_pos[li];
     341    var lang_enabled_id = lang + "-enabled";
     342    var $lang_enabled_cb = $('#'+lang_enabled_id);
     343    if ($lang_enabled_cb.is(':checked')) {
     344        console.log("Extracting POS tags for: " + lang);
     345       
     346        for (var ti=0; ti<universal_pos_tags.length; ti++) {
     347        var tag = universal_pos_tags[ti];
     348        var lang_tag_id = lang+"-"+tag+"-htrctoken-cb";
     349        var $lang_tag_cb = $('#'+lang_tag_id);
     350        if (search_all_checked || ($lang_tag_cb.is(':checked'))) {         
     351            var lang_tag_field = lang+"_"+tag+"_htrctoken";
     352            fields.push(lang_tag_field+":"+q_text);
     353        }
     354        }
     355    }
     356    }
     357
     358    for (var li=0; li<langs_without_pos.length; li++) {
     359    var lang = langs_without_pos[li];
     360    var lang_enabled_id = lang + "-enabled";
     361    var $lang_enabled_cb = $('#'+lang_enabled_id);
     362
     363    if (search_all_checked || ($lang_enabled_cb.is(':checked'))) {
     364        console.log("Adding in non-POS field for: " + lang);
     365        var lang_tag_field = lang+"_htrctoken";
     366        fields.push(lang_tag_field+":"+q_text);     
     367    }
     368    }
     369
     370    var fields_str = fields.join(" OR ");
     371   
     372    return fields_str;
     373}
     374
     375function expand_query_field_and_boolean(query,langs_with_pos,langs_without_pos,search_all_checked)
     376{
     377    // boolean terms
     378    //  => pos and lang field
     379   
     380    var query_terms = query.split(/\s+/);
     381    var query_terms_len = query_terms.length;
     382
     383    var bool_query_term = [];
     384
     385    var i=0;
     386    var prev_bool = "";
     387
     388    for (var i=0; i<query_terms_len; i++) {
     389    var term = query_terms[i];
     390    if (term.match(/^(and|or)$/i)) {
     391        prev_bool = term.toUpperCase();     
     392    }
     393    else {
     394        if (i>0) {
     395        if (prev_bool == "") {
     396            prev_bool = "AND";
     397        }
     398        }
     399       
     400        var expanded_term = expand_field_lang_pos(term,langs_with_pos,langs_without_pos,search_all_checked)
     401       
     402        term = "(" + expanded_term + ")";
     403
     404        if (prev_bool != "") {
     405        bool_query_term.push(prev_bool);
     406        prev_bool = "";
     407        }
     408        bool_query_term.push(term);
     409    }
     410    }
     411
     412    var bool_query = bool_query_term.join(" ");
     413
     414    return bool_query;
     415}
     416
    324417
    325418function stream_submit_action(event)
     
    499592    return;
    500593    }
    501    
     594
     595    arg_q = expand_query_field_and_boolean(q_text,langs_with_pos,langs_without_pos,search_all_checked);
     596
     597    if (arg_q == "") {
     598    $('.search-in-progress').css("cursor","auto");
     599    alert("No languages selected");
     600    return;
     601    }
     602   
     603    /*
    502604    var fields = [];
    503605    var universal_pos_tags = [ "VERB", "NOUN", "ADJ", "ADV", "ADP", "CONJ", "DET", "NUM", "PRT", "X" ];
     
    533635    }
    534636    }
    535 
     637    */
     638
     639    /*
    536640    if (fields.length == 0) {
    537641    $('.search-in-progress').css("cursor","auto");
     
    541645   
    542646    var arg_q = fields.join(" OR ");
    543    
     647    */
    544648   
    545649    // Example search on one of the htrc-full-ef fields is:
Note: See TracChangeset for help on using the changeset viewer.