<commit_before>import React, { Component, PropTypes } from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './OpeningBookTable.css';
import {gameFromImmutable} from '../../store/model/gameState.js';
import OpeningBookEntry from '../OpeningBookEntry';

function OpeningBookTable({ clientID, gameID, gameplay, dispatchMakeMove, dispatchSetHighlightSAN}) {

  function clickFunction(san) {
    return () => {
      dispatchMakeMove(clientID, gameID, san);
    }
  }

  function mouseEnterFunction(san) {
    return () => {
      dispatchSetHighlightSAN(clientID, gameID, san);
    }
  }

  function mouseLeaveFunction() {
    return () => {
      dispatchSetHighlightSAN(clientID, gameID, null);
    }
  }

  const gameData = gameplay.getIn([clientID, 'games', gameID]);

  if (gameData) {
    const game = gameFromImmutable(gameData);
    const bookMoves = (game.cursor === 0 ? game.initialBookMoves : game.history[game.cursor - 1].bookMoves);
    if (bookMoves !== null) {
      if (bookMoves.length === 0 ) {
        return <div className={s.outer}>
          <div className={s.message}>
            OUT OF BOOK.
          </div>
        </div>;
      }
      let opening = '';
      let totalGames = 0;
      bookMoves.forEach((e) => {
        totalGames += (e.whiteWins + e.blackWins + e.draws);
        if (e.game) {
          if (e.game.white) {
            opening = e.game.white;
          }
          if (e.game.black) {
            opening += ' / ' + e.game.black;
          }
        }
      });
      const rows =
            bookMoves.map((e, i) => <OpeningBookEntry key = {i}
                                                 san = {e.san}
                                                 whiteWins = {e.whiteWins}
                                                 blackWins = {e.blackWins}
                                                 draws = {e.draws}
                                                 totalGames = {totalGames}
                                                 opening={opening}
                                                 clickFunction = {clickFunction(e.san)}
                                                 mouseEnterFunction={mouseEnterFunction(e.san)}
                                                 mouseLeaveFunction={mouseLeaveFunction()} />);
      return (
        <div className={s.outer}>
            {rows}
        </div><commit_msg>Fixed labeling bug in OpeningBookTable<commit_after>import React, { Component, PropTypes } from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './OpeningBookTable.css';
import {gameFromImmutable} from '../../store/model/gameState.js';
import OpeningBookEntry from '../OpeningBookEntry';

function OpeningBookTable({ clientID, gameID, gameplay, dispatchMakeMove, dispatchSetHighlightSAN}) {

  function clickFunction(san) {
    return () => {
      dispatchMakeMove(clientID, gameID, san);
    }
  }

  function mouseEnterFunction(san) {
    return () => {
      dispatchSetHighlightSAN(clientID, gameID, san);
    }
  }

  function mouseLeaveFunction() {
    return () => {
      dispatchSetHighlightSAN(clientID, gameID, null);
    }
  }

  const gameData = gameplay.getIn([clientID, 'games', gameID]);

  if (gameData) {
    const game = gameFromImmutable(gameData);
    const bookMoves = (game.cursor === 0 ? game.initialBookMoves : game.history[game.cursor - 1].bookMoves);
    if (bookMoves !== null) {
      if (bookMoves.length === 0 ) {
        return <div className={s.outer}>
          <div className={s.message}>
            OUT OF BOOK.
          </div>
        </div>;
      }
      let totalGames = 0;
      bookMoves.forEach((e) => {
        let opening = '';
        totalGames += (e.whiteWins + e.blackWins + e.draws);
        if (e.game) {
          if (e.game.white) {
            opening = e.game.white;
          }
          if (e.game.black) {
            opening += ' / ' + e.game.black;
          }
        }
        e.opening = opening;
      });
      const rows =
            bookMoves.map((e, i) => <OpeningBookEntry key = {i}
                                                 san = {e.san}
                                                 whiteWins = {e.whiteWins}
                                                 blackWins = {e.blackWins}
                                                 draws = {e.draws}
                                                 totalGames = {totalGames}
                                                 opening = {e.opening}
                                                 clickFunction = {clickFunction(e.san)}
                                                 mouseEnterFunction={mouseEnterFunction(e.san)}
                                                 mouseLeaveFunction={mouseLeaveFunction()} />);
      return (
        <div className={s.outer}>
            {rows}
        </div>
{'fraction_non_alphanumeric': 0.11858190709046455, 'fraction_numerical': 0.0016299918500407497, 'mean_word_length': 1.4520479520479521, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4435655', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1264, 'n_words': 260}