<commit_before>var React = require('react');
var PropTypes = require('prop-types');
var createReactClass = require('create-react-class');
var classNames = require('classnames');

var Subs = Object.assign(
  require('../../docs/helpers/users.json'),
  require('../../docs/helpers/common.json')
);

var DocumentItem = createReactClass({

  propTypes: {
    documentItem: PropTypes.object.isRequired,
    lightTheme: PropTypes.bool.isRequired,
    langStates: PropTypes.object.isRequired,
    numLangs: PropTypes.number.isRequired,
    fontScale: PropTypes.number.isRequired
  },

  getInitialState: function () {
    return {
      showDocument: true
    }
  },

  langStyle: function (elementType, lang, numLangs) {
    var fontScale = this.props["fontScale"];
    var fontSize;
    switch (elementType) {
      case "h3":
        fontSize = 24;
        break;
      case "h4":
        fontSize = 18;
        break;
      default:
        fontSize = 16;
    }
    var divStyle = {
      fontSize: Math.floor(fontSize * fontScale) + "px"
    };
    if (lang == "cop") {
      divStyle["fontFamily"] = "CSNewAthanasius";
    } else if (lang == "ara") {
      divStyle["textAlign"] = "right";
      //divStyle["fontScale"] = "18px";
    }
    divStyle["width"] = Math.floor(100 / numLangs) + "%";
    return divStyle;
  },

  createDocumentElement: function (doc, elementType, theme, idx) {
    var text = [];

    // substitute helper string for actual content
    if (typeof doc == "string") {
      doc = Subs[doc];
    }

    var numLangs = 0;
    var blackList = [];

    // get number of languages that will actually be displayed in order to properly size divs
    for (var lang in doc) {
      /*
      check for the following:
      - language is not checked in interface
      - value of language key is collection of empty strings
      - value of language key is empty string
      - key is not defined
      */
      if (!this.props.langStates[lang] || (Array.isArray(doc[lang]) && doc[lang].every(function (val) { return val === "" }))
        || (doc[lang] === "" || typeof doc[lang] == "undefined")) {
        blackList.push(lang);
      } else {
        numLangs += 1;
      }
    }

    // order of languages to be displayed
    var langs = ["eng", "cop", "ara"];

    for (var i = 0; i < langs.length; i++) {

      var lang = langs[i];

      // check if language is in blacklist
      if (blackList.indexOf(lang) != -1) {
        continue;
      }

      var langStyle = this.langStyle(elementType, lang, numLangs);<commit_msg>iterate over all languages when forming blacklist<commit_after>var React = require('react');
var PropTypes = require('prop-types');
var createReactClass = require('create-react-class');
var classNames = require('classnames');

var Subs = Object.assign(
  require('../../docs/helpers/users.json'),
  require('../../docs/helpers/common.json')
);

var DocumentItem = createReactClass({

  propTypes: {
    documentItem: PropTypes.object.isRequired,
    lightTheme: PropTypes.bool.isRequired,
    langStates: PropTypes.object.isRequired,
    numLangs: PropTypes.number.isRequired,
    fontScale: PropTypes.number.isRequired
  },

  getInitialState: function () {
    return {
      showDocument: true
    }
  },

  langStyle: function (elementType, lang, numLangs) {
    var fontScale = this.props["fontScale"];
    var fontSize;
    switch (elementType) {
      case "h3":
        fontSize = 24;
        break;
      case "h4":
        fontSize = 18;
        break;
      default:
        fontSize = 16;
    }
    var divStyle = {
      fontSize: Math.floor(fontSize * fontScale) + "px"
    };
    if (lang == "cop") {
      divStyle["fontFamily"] = "CSNewAthanasius";
    } else if (lang == "ara") {
      divStyle["textAlign"] = "right";
      //divStyle["fontScale"] = "18px";
    }
    divStyle["width"] = Math.floor(100 / numLangs) + "%";
    return divStyle;
  },

  createDocumentElement: function (doc, elementType, theme, idx) {
    var text = [];

    // substitute helper string for actual content
    if (typeof doc == "string") {
      doc = Subs[doc];
    }

    var numLangs = 0;
    var blackList = [];

    // order of languages to be displayed
    var langs = ["eng", "cop", "ara"];

    // get number of languages that will actually be displayed in order to properly size divs
    for (var i = 0; i < langs.length; i++) {
      var lang = langs[i];
      /*
      check for the following:
      - language is not checked in interface
      - value of language key is collection of empty strings
      - value of language key is empty string
      - key is not defined
      */
      if (!this.props.langStates[lang] || (Array.isArray(doc[lang]) && doc[lang].every(function (val) { return val === "" }))
        || (doc[lang] === "" || typeof doc[lang] == "undefined")) {
        blackList.push(lang);
      } else {
        numLangs += 1;
      }
    }


    for (var i = 0; i < langs.length; i++) {

      var lang = langs[i];

      // check if language is in blacklist
      if (blackList.indexOf(lang) != -1) {
        continue;
      }

      var langStyle = this.langStyle(elementType, lang, numLangs);
{'fraction_non_alphanumeric': 0.1403135281594736, 'fraction_numerical': 0.006773756531836656, 'mean_word_length': 2.503728813559322, 'pattern_counts': {'":': 4, '<': 6, '<?xml version=': 0, '>': 3, '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': '1539739', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1568, 'n_words': 432}