<commit_before>/**
 * ISARI HCERES Annex 4 Export Routine
 * ====================================
 */
const Handlebars = require('handlebars'),
      mongoose = require('mongoose'),
      async = require('async'),
      helpers = require('./helpers.js'),
      COUNTRIES = require('../../specs/enum.countries.json'),
      keyBy = require('lodash/keyBy');

const COUNTRIES_INDEX = keyBy(COUNTRIES, 'alpha2');

const ObjectId = mongoose.Types.ObjectId;

const {
  parseDate,
  overlap
} = helpers;

/**
 * Handlebars templates.
 */
const TEMPLATES = {
  page: `
    <h1>HCERES - Annexe 4</h1>
    <h2>Sommaire:</h2>
    <ul>
      {{#each tabs}}
        <li>
          <a href="#{{id}}">{{title}}</a>
        </li>
      {{/each}}
    </ul>
    {{#each tabs}}
      {{{html}}}
    {{/each}}
  `,
  groups: `
    <h2 id="{{id}}">{{title}}</h2>
    {{#each groups}}
      <h3>{{title}}</h3>
      <ul>
        {{#each people}}
          {{#each activities}}
            <li><strong>{{../firstName}} {{../name}}</strong>, <em><u>{{description}}</u></em>{{#if startDate}}, {{formatRange .}}{{/if}}</li>
          {{/each}}
        {{/each}}
      </uL>
    {{/each}}
  `,
  tab5: `
    <h2 id="{{id}}">{{title}}</h2>
    <h3>Post-doctorants</h3>
    <ul>
      {{#each postDocs}}
        <li><strong>{{firstName}} {{name}}</strong>{{#if startDate}}, {{formatRange .}}{{/if}}</li>
      {{/each}}
    </ul>
    <h3>Chercheurs accueillis</h3>
    <ul>
      {{#each invited}}
        <li><strong>{{firstName}} {{name}}</strong>{{#if organization}}, {{organization}}{{#if country}} ({{country}}){{/if}}{{/if}}{{#if startDate}}, {{formatRange .}}{{/if}}</li>
      {{/each}}
    </ul>
  `,
  contracts: `
    <h2 id="{{id}}">{{title}}</h2>
    {{#each groups}}
      <h3>{{title}}</h3>
      <ul>
        {{#each projects}}
          <li>
            <strong>{{name}}</strong>
            {{~#if acronym}} ({{acronym}}){{/if~}}
            {{~#if organization}}, {{organization}}{{/if~}}
            {{~#if program}}, {{program}}{{/if~}}
            {{~#if instrument}}, {{instrument}}{{/if~}}
            {{~#if manager}}, {{manager.firstName}} {{manager.name}}{{/if~}}
            {{~#if role}}, {{role}}{{/if~}}
          </li>
        {{/each}}
      </ul>
    {{/each}}
  `,
  indices: `
    <h2 id="{{id}}">{{title}}</h2>
    <h3>Prix</h3>
    <h4>Attribués à des personnes</h4>
    <ul>
      {{#each distinctionPeople}}
        {{#each prices}}
          <li>
            <strong>{{../firstName}} {{../name}}</strong>
            {{~#if title}}, <u>{{title}}</u>{{/if~}}
            {{~#if date}}, {{formatDate date}}{{/if~}}
          </li>
        {{/each}}
      {{/each}}
    </ul>
    <h4>Attribués à des activités</h4>
    <ul>
      {{#each distinctionActivities}}
        {{#each prices}}
          <li>
            <strong>{{../name}}</strong>
            {{~#if title}}, <u>{{title}}</u>{{/if~}}
            {{~#if date}}, {{formatDate date}}{{/if~}}
          </li>
        {{/each}}
      {{/each}}
    </ul>
    <h4>Responsabilités dans des sociétés savantes</h4>
    <ul>
      {{#each savants}}
        {{#each activities}}
          <li>
            <strong>{{../firstName}} {{../name}}</strong>
            {{~#if description}}, <u>{{description}}</u>{{/if~}}
            {{~#if startDate}}, {{formatRange .}}{{/if~}}<commit_msg>Dropping u & em in annex4<commit_after>/**
 * ISARI HCERES Annex 4 Export Routine
 * ====================================
 */
const Handlebars = require('handlebars'),
      mongoose = require('mongoose'),
      async = require('async'),
      helpers = require('./helpers.js'),
      COUNTRIES = require('../../specs/enum.countries.json'),
      keyBy = require('lodash/keyBy');

const COUNTRIES_INDEX = keyBy(COUNTRIES, 'alpha2');

const ObjectId = mongoose.Types.ObjectId;

const {
  parseDate,
  overlap
} = helpers;

/**
 * Handlebars templates.
 */
const TEMPLATES = {
  page: `
    <h1>HCERES - Annexe 4</h1>
    <h2>Sommaire:</h2>
    <ul>
      {{#each tabs}}
        <li>
          <a href="#{{id}}">{{title}}</a>
        </li>
      {{/each}}
    </ul>
    {{#each tabs}}
      {{{html}}}
    {{/each}}
  `,
  groups: `
    <h2 id="{{id}}">{{title}}</h2>
    {{#each groups}}
      <h3>{{title}}</h3>
      <ul>
        {{#each people}}
          {{#each activities}}
            <li><strong>{{../firstName}} {{../name}}</strong>, {{description}}{{#if startDate}}, {{formatRange .}}{{/if}}</li>
          {{/each}}
        {{/each}}
      </uL>
    {{/each}}
  `,
  tab5: `
    <h2 id="{{id}}">{{title}}</h2>
    <h3>Post-doctorants</h3>
    <ul>
      {{#each postDocs}}
        <li><strong>{{firstName}} {{name}}</strong>{{#if startDate}}, {{formatRange .}}{{/if}}</li>
      {{/each}}
    </ul>
    <h3>Chercheurs accueillis</h3>
    <ul>
      {{#each invited}}
        <li><strong>{{firstName}} {{name}}</strong>{{#if organization}}, {{organization}}{{#if country}} ({{country}}){{/if}}{{/if}}{{#if startDate}}, {{formatRange .}}{{/if}}</li>
      {{/each}}
    </ul>
  `,
  contracts: `
    <h2 id="{{id}}">{{title}}</h2>
    {{#each groups}}
      <h3>{{title}}</h3>
      <ul>
        {{#each projects}}
          <li>
            <strong>{{name}}</strong>
            {{~#if acronym}} ({{acronym}}){{/if~}}
            {{~#if organization}}, {{organization}}{{/if~}}
            {{~#if program}}, {{program}}{{/if~}}
            {{~#if instrument}}, {{instrument}}{{/if~}}
            {{~#if manager}}, {{manager.firstName}} {{manager.name}}{{/if~}}
            {{~#if role}}, {{role}}{{/if~}}
          </li>
        {{/each}}
      </ul>
    {{/each}}
  `,
  indices: `
    <h2 id="{{id}}">{{title}}</h2>
    <h3>Prix</h3>
    <h4>Attribués à des personnes</h4>
    <ul>
      {{#each distinctionPeople}}
        {{#each prices}}
          <li>
            <strong>{{../firstName}} {{../name}}</strong>
            {{~#if title}}, {{title}}{{/if~}}
            {{~#if date}}, {{formatDate date}}{{/if~}}
          </li>
        {{/each}}
      {{/each}}
    </ul>
    <h4>Attribués à des activités</h4>
    <ul>
      {{#each distinctionActivities}}
        {{#each prices}}
          <li>
            <strong>{{../name}}</strong>
            {{~#if title}}, {{title}}{{/if~}}
            {{~#if date}}, {{formatDate date}}{{/if~}}
          </li>
        {{/each}}
      {{/each}}
    </ul>
    <h4>Responsabilités dans des sociétés savantes</h4>
    <ul>
      {{#each savants}}
        {{#each activities}}
          <li>
            <strong>{{../firstName}} {{../name}}</strong>
            {{~#if description}}, {{description}}{{/if~}}
            {{~#if startDate}}, {{formatRange .}}{{/if~}}
{'fraction_non_alphanumeric': 0.27396849212303076, 'fraction_numerical': 0.009752438109527382, 'mean_word_length': 2.175797999047165, 'pattern_counts': {'":': 0, '<': 161, '<?xml version=': 0, '>': 161, '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': '2847879', 'n_tokens_mistral': 2420, 'n_tokens_neox': 2328, 'n_words': 417}