<commit_before>import React, { PropTypes } from 'react';
import debounce from 'lodash';

class SegmentHud extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            id: props.segment ? props.segment.id : null,
            segment: props.segment ? props.segment.title : '',
            addSegment: props.addSegment,
            updateSegment: props.updateSegment
        };

        this.play = this.play.bind(this);
        this.pause = this.pause.bind(this);
        this.finish = this.finish.bind(this);
        this.setTitle = this.setTitle.bind(this);
    }

    play() {
        console.log('[debug] play');
    }

    pause() {
        console.log('[debug] pause');
    }

    finish() {
        console.log('[debug] finish');
    }

    setTitle(event) {
        const title = event.target.value;
        if (this.state.id) {
            this.state.updateSegment(this.state.id, { title });
        } else {
            this.state.addSegment({ title });
        }
    }

    render() {
        return (
            <div className="segment-hud">
                <input
                    type="text"
                    value={this.state.title}
                    onChange={this.setTitle}
                />
                <div className="segment-hud__main-counter">
                    00:00
                </div>
                <button onClick={this.play}>Play</button>
                <button onClick={this.pause}>Pause</button>
                <button onClick={this.finish}>Finish</button>
            </div>
        );
    }
}

SegmentHud.propTypes = {
    segment: PropTypes.object,
    addSegment: PropTypes.func.isRequired,
    updateSegment: PropTypes.func.isRequired
};

export default SegmentHud;
<commit_msg>change segment state in segmenthud<commit_after>import React, { PropTypes } from 'react';
import debounce from 'lodash';

class SegmentHud extends React.Component {
    constructor(props) {
        super(props);

        console.log('[debug] props.segment', props.segment);

        this.state = {
            segment: props.segment ? props.segment : {},
            addSegment: props.addSegment,
            updateSegment: props.updateSegment
        };

        this.play = this.play.bind(this);
        this.pause = this.pause.bind(this);
        this.finish = this.finish.bind(this);
        this.setTitle = this.setTitle.bind(this);
    }

    play() {
        console.log('[debug] play');
    }

    pause() {
        console.log('[debug] pause');
    }

    finish() {
        console.log('[debug] finish');
    }

    setTitle(event) {
        const title = event.target.value;
        if (this.state.segment.id) {
            this.state.updateSegment(this.state.segment.id, { title });
        } else {
            this.state.addSegment({ title });
        }
    }

    render() {
        return (
            <div className="segment-hud">
                <input
                    type="text"
                    value={this.state.segment.title}
                    onChange={this.setTitle}
                />
                <div className="segment-hud__main-counter">
                    00:00
                </div>
                <button onClick={this.play}>Play</button>
                <button onClick={this.pause}>Pause</button>
                <button onClick={this.finish}>Finish</button>
            </div>
        );
    }
}

SegmentHud.propTypes = {
    segment: PropTypes.object,
    addSegment: PropTypes.func.isRequired,
    updateSegment: PropTypes.func.isRequired
};

export default SegmentHud;

{'fraction_non_alphanumeric': 0.1293007769145394, 'fraction_numerical': 0.0022197558268590455, 'mean_word_length': 1.6963350785340314, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '4326028', 'n_tokens_mistral': 1029, 'n_tokens_neox': 993, 'n_words': 171}