Skip to content

Commit

Permalink
Add examples from Visual Crossing
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Sep 5, 2021
1 parent 827eeb1 commit fac602e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.rst
Expand Up @@ -62,6 +62,9 @@ Usage
python wq.py Particulates in Stuttgart on 2020-09-17
python wq.py hourly temperatures in Potsdam on 2020-09-15
python wq.py maximum temperature in Munich tomorrow
python wq.py Tell me the weather in Tokyo, Japan on the 6th January 1975.
python wq.py What will the weather be in London, England next Wednesday?
python wq.py What was the weather in Washington,DC last 4th July?

# German
python wq.py Sonnenschein auf Helgoland
Expand All @@ -87,8 +90,30 @@ Usage
python wq.py 2020-09-17 को खड़गपुर में धूप


Other implementations
=====================

The article `How to find weather data using NLP (Natural Language Processing)`_
by Andrew Wigmore of `Visual Crossing Corporation`_ describes how to use
`Natural language processing`_ (NLP) to create a sample Java application that
can find weather data using "natural language" text questions. This allows
users to find weather data using queries such as:

- Tell me the weather in Tokyo, Japan on the 6th January 1975.
- What will the weather be in London, England next Wednesday?
- What was the weather in Washington,DC last 4th July?

It is based on `Stanford CoreNLP`_. Find the code example at
`NLPWeatherDataSample.java`_.



.. _Flair: https://pypi.org/project/flair/
.. _How to find weather data using NLP (Natural Language Processing): https://www.visualcrossing.com/resources/documentation/weather-api/how-to-find-weather-data-using-nlp/
.. _Natural language processing: https://en.wikipedia.org/wiki/Natural_language_processing
.. _NLP: https://en.wikipedia.org/wiki/Natural_language_processing
.. _NLPWeatherDataSample.java: https://github.com/visualcrossing/WeatherApi/blob/master/Java/com/visualcrossing/weather/samples/NLPWeatherDataSample.java
.. _spaCy: https://pypi.org/project/spacy/
.. _Stanford CoreNLP: https://stanfordnlp.github.io/CoreNLP/
.. _Visual Crossing Corporation: https://github.com/visualcrossing
.. _Wetterdienst: https://github.com/earthobservations/wetterdienst
30 changes: 30 additions & 0 deletions test_wigmore.py
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# (c) 2020-2021 Andreas Motl <andreas.motl@panodata.org>
# Distributed under the AGPLv3 License. See LICENSE for more info.

from wq import Result, analyze_spacy


def test_english_wigmore_tokyo():
result = analyze_spacy(
"Tell me the weather in Tokyo, Japan on the 6th January 1975."
)
assert result == Result(
where="Tokyo, Japan", when="the 6th January 1975", what="The Weather"
)


def test_english_wigmore_london():
result = analyze_spacy(
"What will the weather be in London, England next Wednesday?"
)
assert result == Result(
where="London, England", when="next Wednesday", what="The Weather"
)


def test_english_wigmore_washington():
result = analyze_spacy("What was the weather in Washington,DC last 4th July?")
assert result == Result(
where="Washington,DC", when="last 4th July", what="The Weather"
)

0 comments on commit fac602e

Please sign in to comment.