<commit_before>import React from "react";

import {FORMATTERS, formatPlaceName} from "helpers/formatters";

export function childHealth(profile, health) {
  const first = health && health.length > 0 ? health[0] : null;
  const place = formatPlaceName(first, "health", profile.level);
  const items = health.map(
    (row, idx) => `${idx === health.length - 1 ? "and " : ""}${FORMATTERS.shareWhole(row.proportion_of_children)} are severely ${row.condition}`);
  if (first) {
    return <p>Among children in {place}, {items.join(", ")}.</p>;
  }
  else {
    return <p></p>;
  }
}

function formatCategory(cat) {
  if (["urban", "rural"].indexOf(cat) >= 0) {
    return `children in ${cat} areas`;
  }
  else {
    return cat;
  }
}

export function childHealthByMode(profile, healthData, mode = "gender") {<commit_msg>fix health conditions paragraph<commit_after>import React from "react";

import {FORMATTERS, formatPlaceName} from "helpers/formatters";

export function childHealth(profile, health) {
  if (!health) {
    return <p>No data available</p>;
  }
  // filter data to the most recent year
  const maxYear = Math.max(...health.map(x => x.year));
  health = health.filter(x => x.year === maxYear);
  const first = health && health.length > 0 ? health[0] : null;
  const place = formatPlaceName(first, "health", profile.level);
  const items = health.map(
    (row, idx) => `${idx === health.length - 1 ? "and " : ""}${FORMATTERS.shareWhole(row.proportion_of_children)} are severely ${row.condition}`);
  if (first) {
    return <p>Among children in {place}, {items.join(", ")}.</p>;
  }
  else {
    return <p>No data available</p>;
  }
}

function formatCategory(cat) {
  if (["urban", "rural"].indexOf(cat) >= 0) {
    return `children in ${cat} areas`;
  }
  else {
    return cat;
  }
}

export function childHealthByMode(profile, healthData, mode = "gender") {
{'fraction_non_alphanumeric': 0.17066666666666666, 'fraction_numerical': 0.004266666666666667, 'mean_word_length': 4.016042780748663, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, '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': '5267826', 'n_tokens_mistral': 624, 'n_tokens_neox': 615, 'n_words': 166}