Skip to content

Commit

Permalink
- add nearby search by street no
Browse files Browse the repository at this point in the history
  • Loading branch information
nandiheath committed Nov 30, 2018
1 parent 4ffc044 commit d4541f7
Show file tree
Hide file tree
Showing 5 changed files with 476 additions and 77 deletions.
50 changes: 50 additions & 0 deletions nodejs/debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const Promise = require('bluebird');
const request = Promise.promisifyAll(require('request'));

const addressParser = require('../web/src/lib/address-parser');

if (process.argv.length < 2) {
process.exit(1);
}

const address = process.argv[2];
const n = 100;
const URL = 'https://www.als.ogcio.gov.hk/lookup';


request.getAsync(URL, {
headers: {
Accept: 'application/json'
},
qs: {
q: address,
n
},
json: {}
}).then(res => {
return addressParser.searchResult(address, res.body);
}).then( results => {
results.forEach((result, index) => {
if (index < 5) {
console.log("================================================")
console.log(JSON.stringify(result.chi, null ,2));
console.log(`score: ${result.score}`);
for (const match of result.matches) {
console.log(` -----------------------`);
console.log(` key: ${match.matchedKey}`);
console.log(` matched: ${match.matchedWords}`);
console.log(` score: ${addressParser.calculateScoreFromMatches([match])}`);

}
console.log("================================================")
console.log("")
console.log("")
}

})


}).catch(error => {
console.log(error.stack);
})

Loading

0 comments on commit d4541f7

Please sign in to comment.