Browse Source

feat(log): Add full clean context to parser logs

Without the unmodified text input, it's hard to tell what cases is
causing these messages.
add-params-to-parser-logs
Julian Simioni 6 years ago
parent
commit
4e6a4c7a49
No known key found for this signature in database
GPG Key ID: B9EEB0C6EE0910A1
  1. 2
      query/autocomplete.js
  2. 2
      query/search_original.js
  3. 4
      query/text_parser_addressit.js
  4. 8
      sanitizer/_text_addressit.js

2
query/autocomplete.js

@ -127,7 +127,7 @@ function generateQuery( clean ){
// run the address parser
if( clean.parsed_text ){
textParser( clean.parsed_text, vs );
textParser( clean.parsed_text, vs, clean );
}
return {

2
query/search_original.js

@ -130,7 +130,7 @@ function generateQuery( clean ){
// run the address parser
if( clean.parsed_text ){
textParser( clean.parsed_text, vs );
textParser( clean.parsed_text, vs, clean );
}
return {

4
query/text_parser_addressit.js

@ -15,7 +15,7 @@ var adminFields = placeTypes.concat([
**/
// all the address parsing logic
function addParsedVariablesToQueryVariables( parsed_text, vs ){
function addParsedVariablesToQueryVariables( parsed_text, vs, clean ){
// is it a street address?
var isStreetAddress = parsed_text.hasOwnProperty('number') && parsed_text.hasOwnProperty('street');
@ -31,7 +31,7 @@ function addParsedVariablesToQueryVariables( parsed_text, vs ){
// ?
else {
logger.warn( 'chaos monkey asks: what happens now?', {
parsed_text: parsed_text
params: clean
});
}

8
sanitizer/_text_addressit.js

@ -29,7 +29,7 @@ function _sanitize( raw, clean ){
delete clean.parsed_text;
// parse text with query parser
var parsed_text = parse(clean.text);
var parsed_text = parse(clean.text, clean);
if (check.assigned(parsed_text)) {
clean.parsed_text = parsed_text;
}
@ -51,7 +51,7 @@ module.exports = () => ({
// this is the addressit functionality from https://github.com/pelias/text-analyzer/blob/master/src/addressItParser.js
var DELIM = ',';
function parse(query) {
function parse(query, clean) {
var getAdminPartsBySplittingOnDelim = function(queryParts) {
// naive approach - for admin matching during query time
// split 'flatiron, new york, ny' into 'flatiron' and 'new york, ny'
@ -110,12 +110,10 @@ function parse(query) {
// if all we found was regions, ignore it as it is not enough information to make smarter decisions
if (Object.keys(parsed_text).length === 1 && !_.isUndefined(parsed_text.regions)) {
logger.info('Ignoring address parser output, regions only', {
text: query.text,
parsed: parsed_text
params: clean
});
return null;
}
return parsed_text;
}

Loading…
Cancel
Save