<commit_before>/** @jsx React.DOM */
'use strict'
var React = require('react')
var getMovies = require('./getmovies')
var MovieGallery = require('./moviegallery')
var SearchBox = require('./searchbox')
var MovieTable = require('./movietable')
require("../css/pure-forms-table.css")

module.exports = React.createClass({
    displayName: 'MovieUI',
    getInitialState: function(){
        return {
            movies:{
                headings:[],
                table: []
            },
            filtered:{
                headings:[],
                table: []
            },
            featured: []
        };
    },
    componentDidMount: function() {
        getMovies(function(result){
            this.setState({
                movies: {headings: result.headings, table: result.table}, 
                filtered: {headings: result.headings, table: result.table}, 
                featured: result.featured});
        }.bind(this));
    },
    handleSearch: function(searchOptions){
        var self = this;
        var vimeoColumn = this.state.movies.headings.indexOf('vimeo');
        var terms = searchOptions.searchTerm.toLowerCase().split(' ').filter(function(t){return t.length > 1});
        var filteredTable = this.state.movies.table.filter(function(e){
            return (searchOptions.checkBox ? e.cells[vimeoColumn] !== '' : true) && terms.every(function(term){ return e.cells.some(function(c, index){
                    if(c === '') return false;
                    if(index === vimeoColumn) return false;
                    return c.toLowerCase().indexOf(term) >= 0;
                });
            });
        });
        this.setState({
            filtered: {table: filteredTable, headings: this.state.movies.headings},
        });
    },
    render: function(){
        if(this.state.movies.headings.length !== 0){
            return (
                <div className='movie-ui'>
                <MovieGallery movies={this.state.featured} />
                <SearchBox placeholder='<NAME>' onSearch={this.handleSearch} />
                <MovieTable data={this.state.filtered} mainCols={4} />
                </div>
            )
        }else{
            return <div className='movie-ui'></div>
        }
    }
});<commit_msg>Added search with quoted phrase<commit_after>/** @jsx React.DOM */
'use strict'
var React = require('react')
var getMovies = require('./getmovies')
var MovieGallery = require('./moviegallery')
var SearchBox = require('./searchbox')
var MovieTable = require('./movietable')
require("../css/pure-forms-table.css")

module.exports = React.createClass({
    displayName: 'MovieUI',
    getInitialState: function(){
        return {
            movies:{
                headings:[],
                table: []
            },
            filtered:{
                headings:[],
                table: []
            },
            featured: []
        };
    },
    componentDidMount: function() {
        getMovies(function(result){
            this.setState({
                movies: {headings: result.headings, table: result.table}, 
                filtered: {headings: result.headings, table: result.table}, 
                featured: result.featured});
        }.bind(this));
    },
    handleSearch: function(searchOptions){
        var self = this;
        var vimeoColumn = this.state.movies.headings.indexOf('vimeo');
        
        var terms = [];
        var phraseMatcher = /[“”"]([^“”"]+)[““"$]?/g;
        var searchTermStr = searchOptions.searchTerm.toLowerCase();
        var match;
        while(match = phraseMatcher.exec(searchTermStr)){
            terms.push(match[1]);
        }
        if(terms.length > 0){
            searchTermStr = searchTermStr.replace(/[“”"][^“”"]+[“”"$]?/g, '');
        }
        var words = searchTermStr.split(/\s+/).filter(function(t){return t.length > 1});
        terms = terms.concat(words);
        
        var filteredTable = this.state.movies.table.filter(function(e){
            return (searchOptions.checkBox ? e.cells[vimeoColumn] !== '' : true) && terms.every(function(term){ return e.cells.some(function(c, index){
                    if(c === '') return false;
                    if(index === vimeoColumn) return false;
                    return c.toLowerCase().indexOf(term) >= 0;
                });
            });
        });
        this.setState({
            filtered: {table: filteredTable, headings: this.state.movies.headings},
        });
    },
    render: function(){
        if(this.state.movies.headings.length !== 0){
            return (
                <div className='movie-ui'>
                <MovieGallery movies={this.state.featured} />
                <SearchBox placeholder='<NAME>' onSearch={this.handleSearch} />
                <MovieTable data={this.state.filtered} mainCols={4} />
                </div>
            )
        }else{
            return <div className='movie-ui'></div>
        }
    }
});
{'fraction_non_alphanumeric': 0.15288422751109318, 'fraction_numerical': 0.002016942315449778, 'mean_word_length': 1.8598615916955017, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 24, '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': '1264845', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1359, 'n_words': 248}