简体   繁体   English

从用户查询中提取区域名称

[英]Extract region name from user query

I am using weather js npm module ( weather-js ) to find weather of a region. 我正在使用天气js npm模块( weather-js )查找某个地区的天气。

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 weather.find 如何从用户查询中提取区域并将其传递给weather.find

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

Have you tried NER? 您尝试过NER吗?

在此处输入图片说明 You can play with it here . 你可以在这里玩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM