<commit_before>import classNames from "classnames"
import React from "react"
import { FormattedMessage, FormattedDate, FormattedNumber } from 'react-intl';

import * as AppPropTypes from "../app-prop-types"


const Scale = React.createClass({
  propTypes: {
    parameter: AppPropTypes.parameter.isRequired,
  },
  render() {
    const {brackets} = this.props.parameter
    return (
      <table className="table table-bordered table-hover table-striped">
        <thead>
          <tr>
            <th><FormattedMessage id="date"/></th>
            <th><FormattedMessage id="bracket"/></th>
            <th><FormattedMessage id="marginalRate"/></th>
          </tr>
        </thead>
        <tbody>
          {
            Object.keys(brackets).sort().reverse().map((startDate, bracketIndex) => {
              const bracket = brackets[startDate]
              const thresholds = Object.keys(bracket).sort((a,b) => Number(a) - Number(b))

              return thresholds.map((threshold, thresholdIndex) => {
                const isFirstBracket = thresholdIndex === 0
                const hasNextThreshold = thresholds[thresholdIndex + 1]
                const nextThreshold = hasNextThreshold && Number(hasNextThreshold)  // '0' is truthy while Number('0') is falsy
                const marginalRate = bracket[threshold];
                threshold = parseFloat(threshold)

                return (
                  <tr
                    className={classNames({"first-bracket": isFirstBracket})}
                    key={`${bracketIndex}-${thresholdIndex}`}
                  >
                    {
                      isFirstBracket && (
                        <td rowSpan={Object.keys(bracket).length}>
                          <FormattedMessage id="fromDate"
                            values={{
                              startDate: <FormattedDate value={startDate} />
                            }}
                          />
                        </td>
                      )
                    }
                    <td>
                      <FormattedMessage id={hasNextThreshold ? 'betweenValues' : 'overValue'}
                        values={{
                          startValue: <samp>{threshold}</samp>,
                          stopValue: <samp>{nextThreshold}</samp>,
                        }}
                      />
                    </td>
                    <td>
                      <samp><FormattedNumber value={marginalRate} style="percent" maximumFractionDigits={3}/></samp>
                    </td>
                  </tr>
                )
              })
            })
          }
        </tbody>
      </table>
    )
  }
})


export default Scale<commit_msg>Localise scale thresholds<commit_after>import classNames from "classnames"
import React from "react"
import { FormattedMessage, FormattedDate, FormattedNumber } from 'react-intl';

import * as AppPropTypes from "../app-prop-types"


const Scale = React.createClass({
  propTypes: {
    parameter: AppPropTypes.parameter.isRequired,
  },
  render() {
    const {brackets} = this.props.parameter
    return (
      <table className="table table-bordered table-hover table-striped">
        <thead>
          <tr>
            <th><FormattedMessage id="date"/></th>
            <th><FormattedMessage id="bracket"/></th>
            <th><FormattedMessage id="marginalRate"/></th>
          </tr>
        </thead>
        <tbody>
          {
            Object.keys(brackets).sort().reverse().map((startDate, bracketIndex) => {
              const bracket = brackets[startDate]
              const thresholds = Object.keys(bracket).sort((a,b) => Number(a) - Number(b))

              return thresholds.map((threshold, thresholdIndex) => {
                const isFirstBracket = thresholdIndex === 0
                const hasNextThreshold = thresholds[thresholdIndex + 1]
                const nextThreshold = hasNextThreshold && Number(hasNextThreshold)  // '0' is truthy while Number('0') is falsy
                const marginalRate = bracket[threshold];
                threshold = parseFloat(threshold)

                return (
                  <tr
                    className={classNames({"first-bracket": isFirstBracket})}
                    key={`${bracketIndex}-${thresholdIndex}`}
                  >
                    {
                      isFirstBracket && (
                        <td rowSpan={Object.keys(bracket).length}>
                          <FormattedMessage id="fromDate"
                            values={{
                              startDate: <FormattedDate value={startDate} />
                            }}
                          />
                        </td>
                      )
                    }
                    <td>
                      <FormattedMessage id={hasNextThreshold ? 'betweenValues' : 'overValue'}
                        values={{
                          startValue: <samp><FormattedNumber value={threshold}/></samp>,
                          stopValue: hasNextThreshold && <samp><FormattedNumber value={nextThreshold}/></samp>,
                        }}
                      />
                    </td>
                    <td>
                      <samp><FormattedNumber value={marginalRate} style="percent" maximumFractionDigits={3}/></samp>
                    </td>
                  </tr>
                )
              })
            })
          }
        </tbody>
      </table>
    )
  }
})


export default Scale
{'fraction_non_alphanumeric': 0.11557971014492753, 'fraction_numerical': 0.0018115942028985507, 'mean_word_length': 1.3483623989791578, 'pattern_counts': {'":': 2, '<': 75, '<?xml version=': 0, '>': 81, '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': '1172392', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1297, 'n_words': 246}