CPSC-312-2021/Crypto Query

From UBC Wiki


Authors: Paul Reid, Daryus Lung, Marina Chun

What is the problem?

Cryptocurrency investments have become increasingly popular as a result of a larger audience paying attention to investment opportunities after the recent events with the GME stock. With the volatile nature of cryptocurrency, we wanted to create an application that allows users to use natural language queries to find different cryptocurrency prices in a currency of their choice at various crypto markets.

What is the something extra?

We used the Prolog HTTP libraries to make calls to the Cryptonator API to fetch real-time prices, volumes, and price changes. We implemented different ways of parsing the API response so our program can answer questions about prices at specific cryptocurrency markets, or tell users which markets have the highest or lowest prices for a given cryptocurrency.

What did we learn from doing this?

Natural Language Processing

Prolog was a very suitable choice for natural language processing using a definite clause grammar. It was relatively simple to parse user input and pass a list of constraints to be evaluated before and after the API call.

Prolog Libraries

We learned to use the Prolog HTTP libraries to make requests to a REST API, and to parse the JSON response into a Prolog dictionary. Prolog made this task fairly straightforward. We also learned how to use Prolog dictionaries to further parse the API response. This was more complicated, and we had to write our own predicates for filtering and sorting the data.

User Interaction

We learned to implement a simple REPL for users to ask our program questions. It was challenging to implement robust user interaction in Prolog. For example, we could not give our users a descriptive error message if their query failed. It was also difficult to format the program's answers in a nice-looking way for the user.

Links to code etc

https://github.com/phreid/cpsc312-crypto