<commit_before>
var through = require('through2'),
    isObject = require('is-object'),
    idOrdinal = 0; // used for addresses lacking an id (to keep them unique)

function hasValidAddress( item ){
  if( !isObject( item ) ) return false;
  if( !isObject( item.address ) ) return false;
  if( 'string' !== typeof item.address.number ) return false;
  if( 'string' !== typeof item.address.street ) return false;
  if( !item.address.number.length ) return false;
  if( !item.address.street.length ) return false;
  return true;
}

module.exports = function(){

  var stream = through.obj( function( item, enc, done ) {

    var isNamedPoi = ( !!item.name && !!item.name.default );

    // create a new record for street addresses
    if( hasValidAddress( item ) ){
      var type = isNamedPoi ? 'poi-address' : 'address';
      var record = {
        id: type + '-' + item.type + '-' + (item.id || ++idOrdinal), // MUST BE UNIQUE!
        name: {
          default: item.address.number + ' ' + item.address.street
        },
        type: item.type,
        center_point: item.center_point,
        alpha3: item.alpha3,
        admin0: item.admin0,
        admin1: item.admin1,
        admin1_abbr: item.admin1_abbr,
        admin2: item.admin2,
        local_admin: item.local_admin,
        locality: item.locality,
        neighborhood: item.neighborhood,
        _meta: item._meta
      };
      this.push( record );<commit_msg>send address records to osmaddress type<commit_after>
var through = require('through2'),
    isObject = require('is-object'),
    idOrdinal = 0; // used for addresses lacking an id (to keep them unique)

function hasValidAddress( item ){
  if( !isObject( item ) ) return false;
  if( !isObject( item.address ) ) return false;
  if( 'string' !== typeof item.address.number ) return false;
  if( 'string' !== typeof item.address.street ) return false;
  if( !item.address.number.length ) return false;
  if( !item.address.street.length ) return false;
  return true;
}

module.exports = function(){

  var stream = through.obj( function( item, enc, done ) {

    var isNamedPoi = ( !!item.name && !!item.name.default );

    // create a new record for street addresses
    if( hasValidAddress( item ) ){
      var type = isNamedPoi ? 'poi-address' : 'address';

      var record = {
        id: type + '-' + item._meta.type + '-' + (item.id || ++idOrdinal), // MUST BE UNIQUE!
        name: {
          default: item.address.number + ' ' + item.address.street
        },
        center_point: item.center_point,
        alpha3: item.alpha3,
        admin0: item.admin0,
        admin1: item.admin1,
        admin1_abbr: item.admin1_abbr,
        admin2: item.admin2,
        local_admin: item.local_admin,
        locality: item.locality,
        neighborhood: item.neighborhood,
        _meta: item._meta
      };

      record._meta.type = 'osmaddress';

      this.push( record );
{'fraction_non_alphanumeric': 0.13324175824175824, 'fraction_numerical': 0.008241758241758242, 'mean_word_length': 2.623134328358209, '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': '6116727', 'n_tokens_mistral': 920, 'n_tokens_neox': 899, 'n_words': 243}