๐Ÿš€ Socket Launch Week ๐Ÿš€ Day 5: Introducing Socket Fix.Learn More โ†’
Socket
Sign inDemoInstall
Socket

weather-retriever

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

weather-retriever

Natural Language Weather Retriever

0.1.13
PyPI
Maintainers
1

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

  • Prepare for Packaging:
    • Ensure the city coordinate file is saved correctly in '~/.weather_retriever'.
  • Create a Distribution:
    • Build the package using setuptools:
    # pip install setuptools wheel
    python setup.py sdist bdist_wheel
    
  • 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:

  • 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.
  • 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.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts