Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leon weather #103

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ packages/**/data/db/*.json
server/src/data/expressions/classifier.json
app/js/main.js
package.json.backup
.python-version
.python-version
Makefile
20 changes: 14 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions packages/leonweather/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 gnouf1

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
56 changes: 56 additions & 0 deletions packages/leonweather/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
![Logo](https://zupimages.net/up/19/23/fn36.png)
# Leon Weather

The Leon Weather Package contains modules related with the weather.

## Features already available

- Ask for the weather and temperatures in any cities in the world

```
User : Can you tell me the weather in Paris ?
Leon : The weather in paris is clear andthe temperature is 28°C.
```

- Ask for the weather and temperatures for 5 days in future with correct conjugation:

```
User : Can you tell me the weather in Paris tomorrow?
Leon : The weather in Paris on 2019-06-06 at 12:00:00 will be rain and the temperature will be 18.4 °C.
```

Default hour is 12:00:00.

- Ask the weather every 3 hours:

```
User :What's the weather in Paris in 3 hours ?
Leon : The weather in Paris on 2019-06-06 at 04:15:08 will be clear and the temperature will be 9.7°C.
```

```
User : What's the weather in paris tomorrow at 09:00 AM?
Leon : The weather in Paris on 2019-06-07 at 09:00:00 will be rain and the temperature will be 15.7°C.
```

- Ask temperatures in Celsuis, Fahrenheit and Kelvin by changing config file:

```json
{
"weather": {
"API_key": "0000",
"Measure":"C", <--- HERE 'C'|'F'|'K'
"options": {}
}
}
```

As you can see on this file you can also change the API_Key, if you want to use default API_Key put `0000` in this field

## Future features

- Average temperature for each day
- Some frills such as wind speed etc...

## Credit
Open Weather API : [Go](https://openweathermap.org/api)
Empty file.
7 changes: 7 additions & 0 deletions packages/leonweather/config/config.sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"weather": {
"API_key": "0000",
"Measure":"C",
"options": {}
}
}
22 changes: 22 additions & 0 deletions packages/leonweather/data/answers/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"weather" :{
"weather_t": [
"The weather in %cit% on <em>%date%</em> at <em>%hour%</em> is <b>%sky%</b> and the temperature is <b>%t%</b>."
],
"weather_f": [
"The weather in %cit% on <em>%date%</em> at <em>%hour%</em> will be <b>%sky%</b> and the temperature will be <b>%t%</b>."
],
"error":[
"Something get wrong in leonweather package."
],
"404_city_not_found":[
"I can't found this city ! Maybe if you add the country code after the name, like this <b>\"london,uk\"</b> it's will work better !"
],
"ezy":[
"Easy, easy, too many people ask weather in this minute, wait 60 seconds please."
],
"test" :[
"City : %cit% %date_ref%."
]
}
}
22 changes: 22 additions & 0 deletions packages/leonweather/data/answers/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"weather" :{
"weather_t": [
"La météo de %cit% le %date% à %hour% est <b>%sky%</b> et la température est de <b>%t%</b>.",
],
"weather_f": [
"La météo de %cit% le %date% à %hour% sera <b>%sky%</b> et la température sera de <b>%t%</b>.",
],
"error":[
"Quelque chose a posé soucis dans le paquet."
],
"404_city_not_found":[
"je ne trouve pas la ville ! Essayez d'ajouter le code du pays derrière de cette façon : <b>\"london,uk\"</b> ça marchera peut être mieux !"
],
"ezy":[
"Doucement, je reçois trop de demande de trop de gens. Je suis limité à 60 par minutes."
],
"town" :[
"City : %cit%."
]
}
}
23 changes: 23 additions & 0 deletions packages/leonweather/data/expressions/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"weather": {
"weather" :{
"expressions":[
"What's the weather in Paris ?",
"Can you tell me the weather in Paris ?",
"What's the weather for tomorrow in Paris ?"
],
"entities": [
{
"type": "trim",
"name": "city",
"conditions": [
{
"type": "after_first",
"from": "in"
}
]
}
]
}
}
}
29 changes: 29 additions & 0 deletions packages/leonweather/data/expressions/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"weather": {
"weather" :{
"expressions":[
"Quelle est la météo à Paris ?",
"Quel temps fait-il à Paris ?",
"Peut-tu me donne la météo de Paris ?"
],
"entities": [
{
"type": "trim",
"name": "city",
"conditions": [
{
"type": "between",
"from": "à",
"to": "?"
},
{
"type": "between",
"from": "de",
"to": "?"
}
]
}
]
}
}
}
43 changes: 43 additions & 0 deletions packages/leonweather/test/weather.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict'

describe('leonweather:weather', async () => {
test('Check the weather today', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('What\'s the weather in Paris ?')

const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])

expect(global.brain.finalOutput.codes).toIncludeSameMembers(['weather_t'])
})

test('Check the weather in future', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('What\'s the weather in Paris tomorrow ?')

const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])

expect(global.brain.finalOutput.codes).toIncludeSameMembers(['weather_f'])
})

test('Error', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('What\'s the weather in Vide0 ?')

const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])

expect(global.brain.finalOutput.codes).toIncludeSameMembers(['error'])
})

test('The city does not exist', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('What\'s the weather in Blublu ?')

const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])

expect(global.brain.finalOutput.codes).toIncludeSameMembers(['404_city_not_found'])
})
})
1 change: 1 addition & 0 deletions packages/leonweather/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.1
Loading