Weather Advisor

From UBC Wiki

What is the Problem?

Here in Vancouver, it’s never easy to know what the weather is about to do! Our goal is to make weather forecasts more accessible by allowing one to interface with the forecast through natural language. Through prolog, our project will allow users to ask questions about the weather in plain English. The interface will understand and support a range of natural weather-related questions, such as “is it cold?”, or "will it rain?".

What is the something extra?

The user will be able to ask questions about weather data from any city in the world. This data will be accessed through Weather API, found at www.weatherapi.com. Further, users will be able to ask questions about items related to the weather, such as "will I need an umbrella?".

What did we learn?

We learned how to use a logic-based programming language to build up a database of real-time weather facts. This was done through queries to Weather API, which we then had to parse into a dictionary, and then asserting the various data/facts as predicates which had been previously instantiated.

One challenge we encountered was parsing the API response. We had to search through the prolog documentation to find out how to make HTTP requests and how to parse a JSON response. This was unfamiliar, and allowed us to expand our understanding of the prolog ecosystem. We were able to combine this with the assert/retract statements we learnt in class to build our database.

During the query process, we encountered an issue related to the strictness of city names. The API had a loose matching principle for names, so that obviously wrong queries would still get data for a city that had only a tangentially similar name. We fixed in the query function, and implemented error handling for cases of bad city-name queries. Overall, this experience highlighted the importance of developing robust functions when working with APIs in logic programming languages.

We also learned a lot about grammar, and the various way in which questions can be asked. It was exciting to see how the logic-based framework of Prolog allowed rules to be easily transferred between contexts, and how this was necessary for inputs that are generative/adaptable as language. Sometimes, we found the complexity and ambiguity of the English language to be frustrating. There are many irregularities and exceptions that added complexity to our parsing structure, such as handling the various uses of the word "it". In the future, it would be interesting to further explore the linguistic structure of questions to see if we could further generalize our parsing and responses.

Links to Code

https://github.com/frehlid/WeatherNLP