Browse Source

changed from `text_parser` to `text_parser_addressit`

this ensures that `clean.parsed_text` is correctly converted to query as expected
pull/666/head
Stephen Hess 9 years ago
parent
commit
484af8c044
  1. 2
      query/autocomplete.js
  2. 2
      query/search_original.js
  3. 0
      query/text_parser_addressit.js
  4. 115
      test/unit/query/search_original.js

2
query/autocomplete.js

@ -1,7 +1,7 @@
var peliasQuery = require('pelias-query'), var peliasQuery = require('pelias-query'),
defaults = require('./autocomplete_defaults'), defaults = require('./autocomplete_defaults'),
textParser = require('./text_parser_autocomplete'), textParser = require('./text_parser_addressit'),
check = require('check-types'); check = require('check-types');
// additional views (these may be merged in to pelias/query at a later date) // additional views (these may be merged in to pelias/query at a later date)

2
query/search_original.js

@ -1,6 +1,6 @@
var peliasQuery = require('pelias-query'), var peliasQuery = require('pelias-query'),
defaults = require('./search_defaults'), defaults = require('./search_defaults'),
textParser = require('./text_parser'), textParser = require('./text_parser_addressit'),
check = require('check-types'); check = require('check-types');
var placeTypes = require('../helper/placeTypes'); var placeTypes = require('../helper/placeTypes');

0
query/text_parser_autocomplete.js → query/text_parser_addressit.js

115
test/unit/query/search_original.js

@ -86,65 +86,62 @@ module.exports.tests.query = function(test, common) {
t.end(); t.end();
}); });
// test('valid query with a full valid address', function(t) { test('valid query with a full valid address', function(t) {
// var query = generate({ text: '123 main st new york ny 10010 US', var query = generate({ text: '123 main st new york ny 10010 US',
// layers: [ 'address', 'venue', 'country', 'region', 'county', 'neighbourhood', 'locality', 'localadmin' ], layers: [ 'address', 'venue', 'country', 'region', 'county', 'neighbourhood', 'locality', 'localadmin' ],
// querySize: 10, querySize: 10,
// parsed_text: { parsed_text: {
// number: '123', number: '123',
// street: 'main st', street: 'main st',
// state: 'NY', state: 'NY',
// country: 'USA', country: 'USA',
// postalcode: '10010' postalcode: '10010',
// } regions: [ 'new york' ]
// }); }
// });
// var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_full_address'); var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_full_address');
// var fs = require('fs');
// fs.writeFileSync('actual.json', JSON.stringify(compiled, null, 2)); t.deepEqual(compiled, expected, 'search_full_address');
// fs.writeFileSync('expected.json', JSON.stringify(expected, null, 2)); t.end();
// });
// t.deepEqual(compiled, expected, 'search_full_address');
// t.end(); test('valid query with partial address', function(t) {
// }); var query = generate({ text: 'soho grand, new york',
// layers: [ 'address', 'venue', 'country', 'region', 'county', 'neighbourhood', 'locality', 'localadmin' ],
// test('valid query with partial address', function(t) { querySize: 10,
// var query = generate({ text: 'soho grand, new york', parsed_text: { name: 'soho grand',
// layers: [ 'address', 'venue', 'country', 'region', 'county', 'neighbourhood', 'locality', 'localadmin' ], state: 'NY',
// querySize: 10, regions: [ 'soho grand' ],
// parsed_text: { name: 'soho grand', admin_parts: 'new york'
// state: 'NY', }
// regions: [ 'soho grand' ], });
// admin_parts: 'new york'
// } var compiled = JSON.parse( JSON.stringify( query ) );
// }); var expected = require('../fixture/search_partial_address');
//
// var compiled = JSON.parse( JSON.stringify( query ) ); t.deepEqual(compiled, expected, 'search_partial_address');
// var expected = require('../fixture/search_partial_address'); t.end();
// });
// t.deepEqual(compiled, expected, 'search_partial_address');
// t.end(); test('valid query with regions in address', function(t) {
// }); var query = generate({ text: '1 water st manhattan ny',
// layers: [ 'address', 'venue', 'country', 'region', 'county', 'neighbourhood', 'locality', 'localadmin' ],
// test('valid query with regions in address', function(t) { querySize: 10,
// var query = generate({ text: '1 water st manhattan ny', parsed_text: { number: '1',
// layers: [ 'address', 'venue', 'country', 'region', 'county', 'neighbourhood', 'locality', 'localadmin' ], street: 'water st',
// querySize: 10, state: 'NY',
// parsed_text: { number: '1', regions: [ 'manhattan' ]
// street: 'water st', },
// state: 'NY', });
// regions: [ 'manhattan' ]
// }, var compiled = JSON.parse( JSON.stringify( query ) );
// }); var expected = require('../fixture/search_regions_address');
//
// var compiled = JSON.parse( JSON.stringify( query ) ); t.deepEqual(compiled, expected, 'search_regions_address');
// var expected = require('../fixture/search_regions_address'); t.end();
// });
// t.deepEqual(compiled, expected, 'search_regions_address');
// t.end();
// });
test('valid boundary.country search', function(t) { test('valid boundary.country search', function(t) {
var query = generate({ var query = generate({

Loading…
Cancel
Save