<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { getType } from '../../utils';
import './DataDictionaryPropertyTable.css';

class DataDictionaryPropertyTable extends React.Component {
  render() {
    const borderModifier = this.props.hasBorder ? ''
      : 'data-dictionary-property-table--without-border';
    return (
      <div className={`data-dictionary-property-table ${borderModifier}`}>
        <table className='data-dictionary-property-table__table'>
          <thead className='data-dictionary-property-table__head'>
            <tr className='data-dictionary-property-table__row'>
              <th
                className='data-dictionary-property-table__data
                data-dictionary-property-table__data--property'
              >
                Property
              </th>
              <th
                className='data-dictionary-property-table__data
                data-dictionary-property-table__data--type'
              >
                Type
              </th>
              <th
                className='data-dictionary-property-table__data
                data-dictionary-property-table__data--required'
              >
                Required
              </th>
              <th
                className='data-dictionary-property-table__data
                data-dictionary-property-table__data--description'
              >
                Description
              </th>
              <th
                className='data-dictionary-property-table__data
                data-dictionary-property-table__data--term'
              >
                Term
              </th>
            </tr>
          </thead>
          <tbody>
            {
              Object.keys(this.props.properties)
                .sort((k1, k2) => {
                  const required1 = this.props.requiredProperties.includes(k1);
                  const required2 = this.props.requiredProperties.includes(k2);
                  if (required1) return -1;
                  if (required2) return 1;
                  return 0;
                })
                .map((propertyKey) => {
                  const property = this.props.properties[propertyKey];
                  const type = getType(property);
                  let rawDescription = 'No Description';
                  if ('description' in property) {
                    rawDescription = property.description;
                  }
                  if ('term' in property) {
                    rawDescription = property.term.description;
                  }
                  const descriptionElements = (
                    <React.Fragment>
                      {
                        rawDescription &&
                      rawDescription.split('\\n').map((desc, i) => (
                        <span key={`${propertyKey}-desc-${i}`}>
                          {desc}
                        </span>
                      ))
                      }
                    </React.Fragment>
                  );
                  const isRequired = this.props.requiredProperties.includes(propertyKey);
                  return (
                    <tr key={propertyKey}>
                      <td className='data-dictionary-property-table__data'>{propertyKey}</td>
                      <td className='data-dictionary-property-table__data'>
                        <ul>
                          {
                            typeof type === 'string' ? (<li>{type}</li>) : type.map(t => (
                              <li key={t}>{t}</li>
                            ))
                          }
                        </ul>
                      </td>
                      <td className='data-dictionary-property-table__data'>
                        { isRequired ? (
                          <span className='data-dictionary-property-table__required'>
                            <i className='g3-icon g3-icon--star data-dictionary-property-table__required-icon' />Required
                          </span>
                        ) : (
                          <span>No</span>
                        )
                        }
                      </td>
                      <td className='data-dictionary-property-table__data'>{descriptionElements}</td>
                      <td className='data-dictionary-property-table__data' />
                    </tr>
                  );
                })
            }

          </tbody>
        </table>
      </div>
    );
  }
}

DataDictionaryPropertyTable.propTypes = {
  properties: PropTypes.object.isRequired,
  requiredProperties: PropTypes.array,
  hasBorder: PropTypes.bool,
};

DataDictionaryPropertyTable.defaultProps = {
  requiredProperties: [],
  hasBorder: true,
};

export default DataDictionaryPropertyTable;<commit_msg>fix(term): add term for dictionary table (#446)<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { getType } from '../../utils';
import './DataDictionaryPropertyTable.css';

class DataDictionaryPropertyTable extends React.Component {
  render() {
    const borderModifier = this.props.hasBorder ? ''
      : 'data-dictionary-property-table--without-border';
    return (
      <div className={`data-dictionary-property-table ${borderModifier}`}>
        <table className='data-dictionary-property-table__table'>
          <thead className='data-dictionary-property-table__head'>
            <tr className='data-dictionary-property-table__row'>
              <th
                className='data-dictionary-property-table__data
                data-dictionary-property-table__data--property'
              >
                Property
              </th>
              <th
                className='data-dictionary-property-table__data
                data-dictionary-property-table__data--type'
              >
                Type
              </th>
              <th
                className='data-dictionary-property-table__data
                data-dictionary-property-table__data--required'
              >
                Required
              </th>
              <th
                className='data-dictionary-property-table__data
                data-dictionary-property-table__data--description'
              >
                Description
              </th>
              <th
                className='data-dictionary-property-table__data
                data-dictionary-property-table__data--term'
              >
                Term
              </th>
            </tr>
          </thead>
          <tbody>
            {
              Object.keys(this.props.properties)
                .sort((k1, k2) => {
                  const required1 = this.props.requiredProperties.includes(k1);
                  const required2 = this.props.requiredProperties.includes(k2);
                  if (required1) return -1;
                  if (required2) return 1;
                  return 0;
                })
                .map((propertyKey) => {
                  const property = this.props.properties[propertyKey];
                  const type = getType(property);
                  let rawDescription = 'No Description';
                  if ('description' in property) {
                    rawDescription = property.description;
                  }
                  let termID = '';
                  let termLink = '';
                  if ('term' in property) {
                    rawDescription = property.term.description;
                    termID = property.term.termDef && property.term.termDef.cde_id;
                    termLink = property.term.termDef && property.term.termDef.term_url;
                  }
                  const descriptionElements = (
                    <React.Fragment>
                      {
                        rawDescription &&
                      rawDescription.split('\\n').map((desc, i) => (
                        <span key={`${propertyKey}-desc-${i}`}>
                          {desc}
                        </span>
                      ))
                      }
                    </React.Fragment>
                  );
                  const isRequired = this.props.requiredProperties.includes(propertyKey);
                  return (
                    <tr key={propertyKey}>
                      <td className='data-dictionary-property-table__data'>{propertyKey}</td>
                      <td className='data-dictionary-property-table__data'>
                        <ul>
                          {
                            typeof type === 'string' ? (<li>{type}</li>) : type.map(t => (
                              <li key={t}>{t}</li>
                            ))
                          }
                        </ul>
                      </td>
                      <td className='data-dictionary-property-table__data'>
                        { isRequired ? (
                          <span className='data-dictionary-property-table__required'>
                            <i className='g3-icon g3-icon--star data-dictionary-property-table__required-icon' />Required
                          </span>
                        ) : (
                          <span>No</span>
                        )
                        }
                      </td>
                      <td className='data-dictionary-property-table__data'>{descriptionElements}</td>
                      <td className='data-dictionary-property-table__data'>
                        <a href={termLink}>{termID}</a>
                      </td>
                    </tr>
                  );
                })
            }

          </tbody>
        </table>
      </div>
    );
  }
}

DataDictionaryPropertyTable.propTypes = {
  properties: PropTypes.object.isRequired,
  requiredProperties: PropTypes.array,
  hasBorder: PropTypes.bool,
};

DataDictionaryPropertyTable.defaultProps = {
  requiredProperties: [],
  hasBorder: true,
};

export default DataDictionaryPropertyTable;
{'fraction_non_alphanumeric': 0.1042957042957043, 'fraction_numerical': 0.002897102897102897, 'mean_word_length': 1.1659454781479879, 'pattern_counts': {'":': 0, '<': 98, '<?xml version=': 0, '>': 106, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4229130', 'n_tokens_mistral': 2369, 'n_tokens_neox': 2199, 'n_words': 356}