<commit_before>import React, {Component, PropTypes} from 'react';
import styles from './Preview.css';

export default class PreviewController extends Component {
    constructor(props) {
        super(props);
        this.renderTable = this.renderTable.bind(this);
    }

    renderTable(table) {
        const tableHeaders = table.get('columnnames').map(
            column => <th>{column}</th>
        );
        const renderCell = cell => <td>{cell}</td>;
        const tableRows = table.get('rows').map(
            row => <tr>{row.map(renderCell)}</tr>
        );
        return (
            <table>
                <thead>{tableHeaders}</thead>
                <tbody>{tableRows}</tbody>
            </table>
        );
    }

    render() {
        const tables = this.props.ipc.get('tables');

        if (!tables) {
            return null;
        }

        const renderedTables = tables.map(
            tableName => {
                if (this.props.ipc.has(tableName)) {
                    return (
                        <div>
                            <div className={styles.tableHeader}>{tableName}</div>
                            {this.renderTable(this.props.ipc.get(tableName))}
                        </div>
                    );
                }
            }
        );

        return (
            <div>
                {renderedTables}
            </div>
        );
    }

}
<commit_msg>:wrench: rewrite to support new format of table preview data<commit_after>import React, {Component, PropTypes} from 'react';
import styles from './Preview.css';

export default class PreviewController extends Component {
    constructor(props) {
        super(props);
        this.renderTable = this.renderTable.bind(this);
    }

    renderTable(table) {
        const tableHeaders = table.get('columnnames').map(
            column => <th>{column}</th>
        );
        const renderCell = cell => <td>{cell}</td>;
        const tableRows = table.get('rows').map(
            row => <tr>{row.map(renderCell)}</tr>
        );
        return (
            <table>
                <thead>{tableHeaders}</thead>
                <tbody>{tableRows}</tbody>
            </table>
        );
    }

    render() {
        const tables = this.props.ipc.get('tables');

        if (!tables) {
            return null;
        }

        const renderedTables = tables.map(
            table => {
                const tableName = table.keySeq().first();

                return (
                    <div>
                        <div className={styles.tableHeader}>{tableName}</div>
                        {this.renderTable(table.get(tableName))}
                    </div>
                );
            }
        );

        return (
            <div>
                {renderedTables}
            </div>
        );
    }

}

{'fraction_non_alphanumeric': 0.1306338028169014, 'fraction_numerical': 0.0, 'mean_word_length': 1.3518211920529801, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 47, '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': '1084850', 'n_tokens_mistral': 760, 'n_tokens_neox': 724, 'n_words': 138}