<commit_before>"use strict";

angular.module('arethusa.core').service('languageSettings', [
  'documentStore',
  function(documentStore) {
    var self = this;

    this.languageSpecifics = {
      'ara' : {
        name: 'Arabic',
        lang: 'ar',
        leftToRight: false,
        font: 'Amiri'
      },
      'grc' : {
        name: 'Greek',
        lang: 'gr',
        leftToRight: true
      }
    };

    this.langNames = arethusaUtil.inject({}, self.languageSpecifics, function(memo, code, obj) {
      memo[obj.lang] = obj.name;
    });

    this.getFor = function(documentName) {
      var document = documentStore.store[documentName];
      if (document === undefined) {
        return undefined;
      }

      var lang = document.json.treebank["_xml:lang"];
      if (lang in this.languageSpecifics) {
        return this.languageSpecifics[lang];
      }

      return undefined;
    };
  }
]);<commit_msg>Refactor languageSettings and add Hebrew<commit_after>"use strict";

angular.module('arethusa.core').service('languageSettings', [
  'documentStore',
  function(documentStore) {
    var self = this;

    this.languageSpecifics = {
      'ara' : {
        name: 'Arabic',
        lang: 'ar',
        leftToRight: false,
        font: 'Amiri'
      },
      'grc' : {
        name: 'Greek',
        lang: 'gr',
        leftToRight: true
      },
      'heb' : {
        name: 'Hebrew',
        lang: 'he',
        leftToRight: false
      }
    };

    this.langNames = arethusaUtil.inject({}, self.languageSpecifics, function(memo, code, obj) {
      memo[obj.lang] = obj.name;
    });

    var settings = {};
    this.setFor = function(documentName, lang) {
      settings[documentName] = self.languageSpecifics[lang];
    };

    this.getFor = function(documentName) {
      var cached = settings[documentName];
      if (cached) {
        return cached;
      } else {
        var document = documentStore.store[documentName];
        if (document === undefined) {
          return undefined;
        }

        var lang = document.json.treebank["_xml:lang"];
        if (lang in self.languageSpecifics) {
          var langObj = self.languageSpecifics[lang];
          self.setFor('treebank', langObj);
          return langObj;
        }

        return undefined;
      }
    };
  }
]);
{'fraction_non_alphanumeric': 0.13569576490924806, 'fraction_numerical': 0.0, 'mean_word_length': 2.1496598639455784, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '356339', 'n_tokens_mistral': 722, 'n_tokens_neox': 695, 'n_words': 139}