art12345 art12345 - 1 year ago 65
Node.js Question

Extract region name from user query

I am using weather js npm module (weather-js) to find weather of a region.

Everything works fine, I was trying to modify it based on user query.

As per the module, it only accepts region name in search parameter.How do I Modify it so that I can process it based on user input? Where user input can be in any element in query array.

How do I extract region from user query and pass it to


var weather = require('weather-js');
var query = ["Weather of US" ,"Tell weather Of US", "US weather today" ,"What is US weather"],
function weather(query){
weather.find({search: query, degreeType: 'F'}, function(err, result) {
err = 'temperature could not be fetched';
return err;
var temp = result[0].current.temperature;
var fToCel = (temp - 32) * 5 / 9;
return fToCel;

Answer Source

Have you tried NER?

enter image description here You can play with it here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download