<commit_before>//Global Vars
var HN_Global = {};
HN_Global.result        = '';
HN_Global.discussions      = [];
HN_Global.submissions   = [];
HN_Global.user_url      = '<a href="http://news.ycombinator.com/user?id=';
HN_Global.item_url      = '<a href="http://news.ycombinator.com/item?id=';

function ddg_spice_hacker_news(res) {

  var snippet = [];
  var terms   = res["request"]["q"];
  var limit = (res["request"]["limit"] < res["hits"]) ? res["request"]["limit"] : res["hits"];

  //At least 1 result
  if (res["hits"] > 0) {
        
    HN_Global.discussions = getDiscussions(res,limit);
    HN_Global.submissions = getSubmissions(res,limit);

    //Display first 3 stories results
    //and search for Top Comments and 3 more stories to display
    snippet[0] = '';
    snippet[1] = '';
    snippet[2] = '';
    var c0 = 0;
    var c1 = 0;
    var c2 = 0;
    var i  = 0;


    //Get top stories
    while (i < HN_Global.submissions.length) {
      
      HN_Global.result = HN_Global.submissions[i];

      if (c0 < 3) {
        snippet[0] += submission(HN_Global.submissions, i);
        c0++;
      }

      if (c0 === 3 && c2 < 3 && i > 2) {
        snippet[2] += submission(HN_Global.submissions, i);
        c2++;
      }

      if (c0 === 3 && c2 === 3) break;

      i++;
    }
    
    while (i < HN_Global.discussions.length) {

      HN_Global.result = HN_Global.discussions[i];

      if (c1 < 3) {
        snippet[1] += discussion(HN_Global.submissions, i); 
        c1++;
      }

      if (c1 === 3) break;
      i++;
    }
    
    //Check in case only comments returned
    if (c0 === 0){
      i = 0;

      while (i < limit) {
        HN_Global.result = res["results"][i]["item"];
        snippet[0] = (HN_Global.result["type"] === "submission") ? submission(res, i) : discussion(res, i);
        if (c0 === 3) break;
        c0++;
      }
    }

    //Populate items array
    items = [];
    
    for (var i = 0; i < 3; i++) {
      if (snippet[i]) {
        
        items[i] = [];
                
        switch(i){
          case 0: 
                items[i]['a'] = snippet[0];
                items[i]['u'] = 'http://www.hnsearch.com/search#request/all&q=' + encodeURIComponent(res["request"]["q"]);
                break;
          case 1:
                items[i]['a'] = '</br>' + snippet[1];
                items[i]['u'] = 'http://www.hnsearch.com/search#request/comments&q=' + encodeURIComponent(res["request"]["q"]);
                items[i]['t'] = '<b>Top Comments</b>';
                break;
          case 2:
                items[i]['a'] = '</br>' + snippet[2];
                items[i]['u'] = 'http://www.hnsearch.com/search#request/submissions&q=' + encodeURIComponent(res["request"]["q"]);
                items[i]['t'] = '<b>Other Stories</b>';
                break;
        }

        items[i]['h'] = 'Hacker News' + ' (' + terms + ')';
        items[i]['s'] = 'HNSearch'; 
        items[i]['f'] = 1;
      }
    }
    
    nra(items);
  }
}

function discussion (res, i) {
   
  var text = shorten(HN_Global.result["text"], 200);
 
  var div  = d.createElement('div');
  var div2 = d.createElement('div');

  var title = shorten(HN_Global.result["discussion"]["title"]);

  //first line (points, who, link, parent, discussion)
  var out = text<commit_msg>tiny fix, removed bolded links<commit_after>//Global Vars
var HN_Global = {};
HN_Global.result        = '';
HN_Global.discussions   = [];
HN_Global.submissions   = [];
HN_Global.user_url      = '<a href="http://news.ycombinator.com/user?id=';
HN_Global.item_url      = '<a href="http://news.ycombinator.com/item?id=';

function ddg_spice_hacker_news(res) {

  var snippet = [];
  var terms   = res["request"]["q"];
  var limit = (res["request"]["limit"] < res["hits"]) ? res["request"]["limit"] : res["hits"];

  //At least 1 result
  if (res["hits"] > 0) {
        
    HN_Global.discussions = getDiscussions(res,limit);
    HN_Global.submissions = getSubmissions(res,limit);

    //Display first 3 stories results
    //and search for Top Comments and 3 more stories to display
    snippet[0] = '';
    snippet[1] = '';
    snippet[2] = '';
    var c0 = 0;
    var c1 = 0;
    var c2 = 0;
    var i  = 0;


    //Get top stories
    while (i < HN_Global.submissions.length) {
      
      HN_Global.result = HN_Global.submissions[i];

      if (c0 < 3) {
        snippet[0] += submission(HN_Global.submissions, i);
        c0++;
      }

      if (c0 === 3 && c2 < 3 && i > 2) {
        snippet[2] += submission(HN_Global.submissions, i);
        c2++;
      }

      if (c0 === 3 && c2 === 3) break;

      i++;
    }
    
    while (i < HN_Global.discussions.length) {

      HN_Global.result = HN_Global.discussions[i];

      if (c1 < 3) {
        snippet[1] += discussion(HN_Global.submissions, i); 
        c1++;
      }

      if (c1 === 3) break;
      i++;
    }
    
    //Check in case only comments returned
    if (c0 === 0){
      i = 0;

      while (i < limit) {
        HN_Global.result = res["results"][i]["item"];
        snippet[0] = (HN_Global.result["type"] === "submission") ? submission(res, i) : discussion(res, i);
        if (c0 === 3) break;
        c0++;
      }
    }

    //Populate items array
    items = [];
    
    for (var i = 0; i < 3; i++) {
      if (snippet[i]) {
        
        items[i] = [];
                
        switch(i){
          case 0: 
                items[i]['a'] = snippet[0];
                items[i]['u'] = 'http://www.hnsearch.com/search#request/all&q=' + encodeURIComponent(res["request"]["q"]);
                break;
          case 1:
                items[i]['a'] = '</br>' + snippet[1];
                items[i]['u'] = 'http://www.hnsearch.com/search#request/comments&q=' + encodeURIComponent(res["request"]["q"]);
                items[i]['t'] = 'Top Comments';
                break;
          case 2:
                items[i]['a'] = '</br>' + snippet[2];
                items[i]['u'] = 'http://www.hnsearch.com/search#request/submissions&q=' + encodeURIComponent(res["request"]["q"]);
                items[i]['t'] = 'Other Stories';
                break;
        }

        items[i]['h'] = 'Hacker News' + ' (' + terms + ')';
        items[i]['s'] = 'HNSearch'; 
        items[i]['f'] = 1;
      }
    }
    
    nra(items);
  }
}

function discussion (res, i) {
   
  var text = shorten(HN_Global.result["text"], 200);
 
  var div  = d.createElement('div');
  var div2 = d.createElement('div');

  var title = shorten(HN_Global.result["discussion"]["title"]);

  //first line (points, who, link, parent, discussion)
  var out = text
{'fraction_non_alphanumeric': 0.18697097944377267, 'fraction_numerical': 0.016626360338573155, 'mean_word_length': 2.0436982520699174, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '2992810', 'n_tokens_mistral': 2419, 'n_tokens_neox': 2248, 'n_words': 461}