Skip to main content

Natural Language Weather Retriever

Project description

Weather-Retriever

Weather-Retriever is a Python package that allows users to retrieve and format weather information in natural language, specifically tailored for Korean speakers. It leverages data from OpenWeatherMap and incorporates natural language processing (NLP) techniques to extract temporal and location information from user queries. The package presents weather forecasts in a user-friendly format, accommodating Korean-language date expressions and appropriate word forms.

Features

  • Retrieve real-time weather data from OpenWeatherMap.
  • Understand and process natural language queries in Korean.
  • Cache city coordinates for efficient API usage.
  • Format weather forecasts in an easily readable manner.

Building the Package

  1. Prepare for Packaging:
    • Ensure the city coordinate file is saved correctly in '~/.weather-retriever'.
  2. Create a Distribution:
    • Build the package using setuptools:
    # pip install setuptools wheel
    python setup.py sdist bdist_wheel
    
  3. Publish to PyPI:
    • Use twine to upload the package:
    # pip install twine
    python -m twine upload dist/*
    

Installation

You can install WeatherRetriever in two ways:

  1. Install via PyPI:
    # https://pypi.org/project/weather-retriever/0.1.6/
    pip install weather-retriever
    
    • This method allows you to install the package directly from PyPI.
  2. Install from GitHub:
    git clone https://github.com/KimRass/weather-retriever
    cd weather-retriever
    pip install .
    
    • This method is useful if you want to access the latest code or contribute to the project.

Usage

from weather_retriever import WeatherRetriever

# The OpenWeatherMap API key must be provided when initializing `WeatherRetriever`.
owm_api_key = "YOUR_OPENWEATHERMAP_API_KEY"
wr = WeatherRetriever(owm_api_key)

query = "YOUR_QUERY"
# Ensure network access is available to retrieve real-time weather data.
response = wr.query(query)
print(response)
  • The package also includes intelligent caching of city coordinates to minimize redundant API calls.

Query Examples

  • "내일 서울 날씨는 어때?"
  • "사흘 뒤의 상하이 날씨 어때?"
  • "2024년 11월 6일의 런던 날씨는 어떻습니까?"
  • "내일 오전 워싱턴 날씨는?"
  • "내일과 2024년 11월 8일의 부산 날씨는 어떻습니까?"
  • "뉴욕 날씨를 알려주세요. 내일과 모레에 대해서."

File Handling

  • The package saves city coordinate data in '~/.weather-retriever/city_coords.json' to cache information for efficient lookups.
  • The pathlib library is used for managing file and directory operations.

Testing

  • To run the tests, you can use Python's built-in unittest framework or pytest. To execute the tests, simply run:
    pytest
    

License

  • This project is licensed under the Apache License 2.0. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weather-retriever-0.1.6.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

weather_retriever-0.1.6-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file weather-retriever-0.1.6.tar.gz.

File metadata

  • Download URL: weather-retriever-0.1.6.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.13

File hashes

Hashes for weather-retriever-0.1.6.tar.gz
Algorithm Hash digest
SHA256 bfaff5e81fbf6d237f1bbe36a1bac436e95b69ec61332d1e7f15d4f87dd6463f
MD5 8c3a6af754deb3f27b02863f1fdba420
BLAKE2b-256 218f12fe75e56f525f96b53c165ff0ab67d9f7a905a552addb40440828551e80

See more details on using hashes here.

File details

Details for the file weather_retriever-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for weather_retriever-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6d966aa43a818ef0a9683603150bbcc0aebdc650d17d3f1ab8fb00917ba7d238
MD5 0b770e60f5325fe05d8d5a9227baea46
BLAKE2b-256 32228d7be9ea71ccc22205ef3ca0d0d55eeee0a5d409ff6cee8d6a94e62b732c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page