Browse Source

feat(libpostal_patch): refactor code to use lodash methods for key checking

libpostal_aus_unit_numbers
Peter Johnson 6 years ago committed by Peter Johnson
parent
commit
c8d7776587
  1. 13
      controller/libpostal.js

13
controller/libpostal.js

@ -128,13 +128,12 @@ function patchBuggyResponses(response){
// replacements to only records with BOTH a matching 'value' and a matching 'label.from'.
if( response.length === 1 ){
let first = response[0];
for( var ii=0; ii<RECAST_LABELS.length; ii++ ){
let recast = RECAST_LABELS[ii];
if( !recast.hasOwnProperty('label') || !recast.label.hasOwnProperty('to') ){ continue; }
if( recast.value !== first.value ){ continue; }
if( recast.label.hasOwnProperty('from') && recast.label.from !== first.label ){ continue; }
response[0].label = recast.label.to;
}
RECAST_LABELS.forEach(recast => {
if( !_.has(recast, 'label') || !_.has(recast.label, 'to') ){ return; }
if( recast.value !== first.value ){ return; }
if( _.has(recast.label, 'from') && recast.label.from !== first.label ){ return; }
first.label = recast.label.to;
});
}
// known bug where the street name is only a directional, in this case we will merge it

Loading…
Cancel
Save