-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
56 lines (42 loc) · 1.24 KB
/
functions.js
File metadata and controls
56 lines (42 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var search= require('./tfidf.js')
var date= require('date.js')
function functions(query,classifyed,callback) {
if(classifyed=="alarm"){
return callback(null ,(date(query)))
}
else if(classifyed=="call"){
data=(query.replace('call ', '') );
return callback(null , data)
}
else if (classifyed=="weather") {
weather(function ( err, temperature ){
return callback(null ,temperature)
})
}
else if (classifyed=="location") {
var n = query.split(" ");
return callback(null ,n[n.length - 1])
}
else if(classifyed=="search"){
test=search.search(query)
return callback(null , test)
}
}
function weather(callback) {
var config = {
units: "metric",
apiKey: "7c2ec1abf1b45603d1b372375c27ec86",
debug: process.env.NODE_ENV === 'development'
};
var simpleWeather = require("simple-weather")(config);
simpleWeather["v2.5"].current.byCityName("istanbul").then(function(response) {
console.log("Current Weather of Istanbul is");
console.log("Temperature:", response.main.temp, "Celcius");
return callback(null ,response.main.temp )
}).catch(function(err) {
console.error(err.stack);
});
}
module.exports = {
functions
}