<commit_before>// secondary request for annotations

var xml2js = require('xml2js');
var annoLib = require('./annotateLib'), annotations = require('../../lib/annotations'), sites = require('../sites.js'), utils = require('../utils.js');

var name = 'addRequest';

//process({ uri: 'http://www.ncbi.nlm.nih.gov/pubmed/11139488'});

// wait for annotation requests
annoLib.requestAnnotate(process);

function process(combo) {
  var uri = combo.uri;

  var founds = sites.findMatch(uri);

// an additional request exists
  founds.forEach(function(found) {
    if (found.addRequest) {
      GLOBAL.info(name, uri, found.addRequest);
      found.addRequest.forEach(function(areq) {
        var processor = sites.processors[areq.processor];
        var loc = processor.getURI(uri);
        // local name
        var name = areq.name;
        // retrieve contents and process
        utils.retrieve(loc, function(err, resp) {
          if (err) {
            GLOBAL.err(name, err);
          } else {
            if (processor.type === 'XML') {
              processXML(name, uri, processor, resp);
            }
          }
        });
      });
    }
  });
}

// process retrieved content as XML
function processXML(name, uri, processor, resp) {
  var parser = new xml2js.Parser();

  parser.parseString(resp, function (err, xml) {
    if (err) {
      GLOBAL.error(name, err);
      return;
    } else {
      processor.getAnnotations(name, uri, xml, function(annoRows) {
        annoLib.publishAnnotations(name, uri, annoRows);
      });
    }
  });
}
<commit_msg>error<commit_after>// secondary request for annotations

var xml2js = require('xml2js');
var annoLib = require('./annotateLib'), annotations = require('../../lib/annotations'), sites = require('../sites.js'), utils = require('../utils.js');

var name = 'addRequest';

//process({ uri: 'http://www.ncbi.nlm.nih.gov/pubmed/11139488'});

// wait for annotation requests
annoLib.requestAnnotate(process);

function process(combo) {
  var uri = combo.uri;

  var founds = sites.findMatch(uri);

// an additional request exists
  founds.forEach(function(found) {
    if (found.addRequest) {
      GLOBAL.info(name, uri, found.addRequest);
      found.addRequest.forEach(function(areq) {
        var processor = sites.processors[areq.processor];
        var loc = processor.getURI(uri);
        // local name
        var name = areq.name;
        // retrieve contents and process
        utils.retrieve(loc, function(err, resp) {
          if (err) {
            GLOBAL.error(name, err);
          } else {
            if (processor.type === 'XML') {
              processXML(name, uri, processor, resp);
            }
          }
        });
      });
    }
  });
}

// process retrieved content as XML
function processXML(name, uri, processor, resp) {
  var parser = new xml2js.Parser();

  parser.parseString(resp, function (err, xml) {
    if (err) {
      GLOBAL.error(name, err);
      return;
    } else {
      processor.getAnnotations(name, uri, xml, function(annoRows) {
        annoLib.publishAnnotations(name, uri, annoRows);
      });
    }
  });
}

{'fraction_non_alphanumeric': 0.14890885750962773, 'fraction_numerical': 0.007060333761232349, 'mean_word_length': 2.5300113250283127, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 10}, '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': '4123850', 'n_tokens_mistral': 975, 'n_tokens_neox': 944, 'n_words': 216}