<commit_before>(function () {
  angular.module('fusionSeedApp.components.document', ['fusionSeedApp.services.config',
      'fusionSeedApp.utils.docs', 'fusionSeedApp.service.signals'
    ])
    .directive('document', documentListItem);

  documentListItem.$inject = [];

  function documentListItem() {
    return {
      templateUrl: 'assets/components/document/document.html',
      scope: true,
      controller: Controller,
      controllerAs: 'dc',
      bindToController: {
        doc: '='
      },
      replace: true
    };
  }

  Controller.$inject = ['$log', '$scope', 'DocsHelper', 'ConfigService', 'SignalsService'];

  function Controller($log, $scope, DocsHelper, ConfigService, SignalsService) {
    var dc = this;
    dc.postSignal = SignalsService.postSignal;

    activate();

    ///////////

    function activate() {
      dc.doc = processDocument(DocsHelper.concatMultivaluedFields(dc.doc));
    }

    function processDocument(doc) {
      //Populate the labels
      var returnDoc = {};

      returnDoc.fieldsToDisplay = DocsHelper.populateFieldLabels(
        DocsHelper.selectFields(doc, ConfigService.getFieldsToDisplay()),
        ConfigService.getFieldLabels()
      );

      returnDoc.lw_head = doc.hasOwnProperty(ConfigService.getFields.get('head')) ?
        doc[ConfigService.getFields.get('head')] : 'Title Field Not Found';

      returnDoc.lw_subhead = doc.hasOwnProperty(ConfigService.getFields.get('subhead')) ?
        doc[ConfigService.getFields.get('subhead')] : null;

      returnDoc.lw_description = doc.hasOwnProperty(ConfigService.getFields.get(
          'description')) ?
        doc[ConfigService.getFields.get('description')] : null;

      returnDoc.lw_image = doc.hasOwnProperty(ConfigService.getFields.get('image')) ?
        doc[ConfigService.getFields.get('image')] : null;

      return returnDoc;
    }

  }
})();
<commit_msg>refactor document.js for legibility and add signals<commit_after>(function () {
  angular.module('fusionSeedApp.components.document', ['fusionSeedApp.services.config',
      'fusionSeedApp.utils.docs', 'fusionSeedApp.service.signals'
    ])
    .directive('document', documentListItem);

  documentListItem.$inject = [];

  function documentListItem() {
    return {
      templateUrl: 'assets/components/document/document.html',
      scope: true,
      controller: Controller,
      controllerAs: 'dc',
      bindToController: {
        doc: '='
      },
      replace: true
    };
  }

  Controller.$inject = ['$log', '$scope', 'DocsHelper', 'ConfigService',
    'SignalsService'
  ];

  function Controller($log, $scope, DocsHelper, ConfigService, SignalsService) {
    var dc = this;
    dc.postSignal = SignalsService.postSignal;

    activate();

    ///////////

    function activate() {
      dc.doc = processDocument(DocsHelper.concatMultivaluedFields(dc.doc));
    }

    function processDocument(doc) {
      //Populate the labels
      var returnDoc = {};

      returnDoc.fieldsToDisplay = DocsHelper.populateFieldLabels(
        DocsHelper.selectFields(doc, ConfigService.getFieldsToDisplay()),
        ConfigService.getFieldLabels()
      );

      returnDoc.lw_head = getField('head', doc) ?
        getField('head', doc) : 'Title Field Not Found';

      returnDoc.lw_subhead = getField('subhead', doc);

      returnDoc.lw_description = getField('description', doc);

      returnDoc.lw_image = getField('image', doc);

      return returnDoc;
    }

    /**
     * Given a field type get the actual field value.
     * @param  {String} fieldType The Field type.
     * @param  {object} doc       The document object
     * @return {String|null}       The field value.
     */
    function getField(fieldType, doc) {
      var fieldName = ConfigService.getFields.get(fieldType);
      if (doc.hasOwnProperty(fieldName)) {
        return doc[fieldName];
      }
      return null;
    }

    function getDocumentId(doc) {
      var documentIdField = ConfigService.config.signalsDocumentId;
      if (doc.hasOwnProperty(documentIdField)) {
        return doc[documentIdField];
      }
      return null;
    }

  }
})();

{'fraction_non_alphanumeric': 0.13160445952496364, 'fraction_numerical': 0.0, 'mean_word_length': 3.046078431372549, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4906060', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1190, 'n_words': 211}