Skip to main content

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.8/
    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.

Metadata

Release files for weather-retriever 0.1.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for weather-retriever 0.1.13
File Size Uploaded
weather_retriever-0.1.13.tar.gz 14.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for weather-retriever 0.1.13
File Interpreter ABI Platform
weather_retriever-0.1.13-py3-none-any.whl Python 3 none any Details

Total release size: 30.0 kB

Release files / weather_retriever-0.1.13.tar.gz

Download URL weather_retriever-0.1.13.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
47b99c103563f6793748bb26f857fba75ea58cd68454018050a1f124f54bf618
BLAKE2b-256 checksum
How to use checksums
ec41fa65be8f66989b2c2e1365bc59fa146f361d811d594dd5afc1db65a0ddb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.13

Release files / weather_retriever-0.1.13-py3-none-any.whl

Download URL weather_retriever-0.1.13-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
879c92451efbeb95f204ce5b202aa83ed7a0a2641d9e11b2eb3607f0d01cad4f
BLAKE2b-256 checksum
How to use checksums
561c3dd8ca1245e24e08a7156df99237d8363fd250c50b2089abf0552e2a8339
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.1.13 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page