<commit_before>const ndjson = require('ndjson')
const request = require('request')
const _ = require('lodash')

request('https://rawgit.com/fergiemcdowall/reuters-21578-json/master/data/fullFileStream/justTen.str')
  .pipe(ndjson.parse())
  .on('data', function(obj) {
    // Swap this with something more robust later (lodash?)
    var text = ''
    for(var key in obj) {
      var value = obj[key];
      if (value.constructor === Array)  {
      // Check if array
        for (let arrayValue of value) {
          //console.log(arrayValue)
          text += (' ' + arrayValue)
        }
      } else {
        //console.log(value)
        text += (' ' + value)
      }
    }
    console.log(text)
    // Do stuff with string:
    // A: Get only words (regex)
    // B: split up into array
    // C: Add to array
    // D: Check if in array from before and update count instead
  })<commit_msg>Counting number of docs processed, fixing issue #12<commit_after>const ndjson = require('ndjson')
const request = require('request')
const _ = require('lodash')

var docCount = 0
request('https://rawgit.com/fergiemcdowall/reuters-21578-json/master/data/fullFileStream/full.str')
//request('https://rawgit.com/fergiemcdowall/reuters-21578-json/master/data/fullFileStream/justTen.str')
  .pipe(ndjson.parse())
  .on('data', function(obj) {
    docCount++
    console.log('Document: #' + docCount)
    var text = ''
    for(var key in obj) {
      var value = obj[key]
      value = _.lowerCase(value)
      text += (' ' + value)
    }
    var textArray = _.words(text, /[^, ]+/g)
    //_.flatMapDeep(obj)
    console.dir(textArray)
    
    
    /*
    ### Do stuff with string:
    *A: Get only words & numbers(regex)
    *B: split up into array
     C: Add to array
     D: Check if in array from before and update count instead
    */
  })
{'fraction_non_alphanumeric': 0.14596949891067537, 'fraction_numerical': 0.00980392156862745, 'mean_word_length': 2.587890625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, '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': '429469', 'n_tokens_mistral': 615, 'n_tokens_neox': 594, 'n_words': 151}