Skip to main content

Better dates, times, math expression and place extractor for Python of Chinese

Project description

Pyswan is a Python library that offers a sensible and human-friendly approach to creating, manipulating, formatting and converting dates, times and timestamps. It implements and updates the datetime type, plugging gaps in functionality and providing an intelligent module API that supports many common creation scenarios. Simply put, it helps you work with dates and times with fewer imports and a lot less code.

Quick Start

Installation

To install Pyswan:

$ pip install -U pyswan

Example Usage

>>> import pyswan
>>> pyswan.digitize(u"梁山一百零八好汉")
'梁山108好汉'
>>> pyswan.digitize("今天是周日")
'今天是周7'
>>> pyswan.parse('十二点三十分', dim=['time', 'number'])
"[{'type': 'time', 'body': '12点30分', 'value': '2022-01-09 12:30:56'}, {'type': 'number', 'start': 0, 'end': 2, 'value': '12'}, {'type': 'number', 'start': 3, 'end': 5, 'value': '30'}]"
>>> pyswan.parse('六加十三除以2再乘八等于多少', dim=['equation'])
"[{'type': 'equation', 'start': 0, 'end': 8, 'value': '6+13/2*8'}]"
>>> pyswan.parse('徐汇区虹漕路461号58号楼5楼', dim=['place'])
"[{'type': 'place', 'province': '上海市', 'city': '市辖区', 'area': '徐汇区', 'code': '310104'}]"

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pyswan-0.4.0-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file pyswan-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pyswan-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.9.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.6

File hashes

Hashes for pyswan-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0850aa4c62290bdfe97f10c87ac96708c4b7368ed96a2a1d2eeed2e832e4182
MD5 55e309bde597202338d8bf26a92b3949
BLAKE2b-256 5287180a3c20a045656edfa43b487453f525a40b54c12557ae1d54b4f97594d9

See more details on using hashes here.

Supported by

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