ovos-date-parser 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. ovos-date-parser-0.0.1/PKG-INFO +154 -0
  2. ovos-date-parser-0.0.1/README.md +135 -0
  3. ovos-date-parser-0.0.1/ovos_date_parser/__init__.py +600 -0
  4. ovos-date-parser-0.0.1/ovos_date_parser/dates_az.py +840 -0
  5. ovos-date-parser-0.0.1/ovos_date_parser/dates_ca.py +1300 -0
  6. ovos-date-parser-0.0.1/ovos_date_parser/dates_cs.py +1187 -0
  7. ovos-date-parser-0.0.1/ovos_date_parser/dates_da.py +783 -0
  8. ovos-date-parser-0.0.1/ovos_date_parser/dates_de.py +817 -0
  9. ovos-date-parser-0.0.1/ovos_date_parser/dates_en.py +1190 -0
  10. ovos-date-parser-0.0.1/ovos_date_parser/dates_es.py +965 -0
  11. ovos-date-parser-0.0.1/ovos_date_parser/dates_eu.py +927 -0
  12. ovos-date-parser-0.0.1/ovos_date_parser/dates_fa.py +280 -0
  13. ovos-date-parser-0.0.1/ovos_date_parser/dates_fr.py +674 -0
  14. ovos-date-parser-0.0.1/ovos_date_parser/dates_hu.py +80 -0
  15. ovos-date-parser-0.0.1/ovos_date_parser/dates_it.py +793 -0
  16. ovos-date-parser-0.0.1/ovos_date_parser/dates_nl.py +943 -0
  17. ovos-date-parser-0.0.1/ovos_date_parser/dates_pl.py +1075 -0
  18. ovos-date-parser-0.0.1/ovos_date_parser/dates_pt.py +990 -0
  19. ovos-date-parser-0.0.1/ovos_date_parser/dates_ru.py +1252 -0
  20. ovos-date-parser-0.0.1/ovos_date_parser/dates_sl.py +89 -0
  21. ovos-date-parser-0.0.1/ovos_date_parser/dates_sv.py +799 -0
  22. ovos-date-parser-0.0.1/ovos_date_parser/dates_uk.py +1464 -0
  23. ovos-date-parser-0.0.1/ovos_date_parser/version.py +6 -0
  24. ovos-date-parser-0.0.1/ovos_date_parser.egg-info/PKG-INFO +154 -0
  25. ovos-date-parser-0.0.1/ovos_date_parser.egg-info/SOURCES.txt +28 -0
  26. ovos-date-parser-0.0.1/ovos_date_parser.egg-info/dependency_links.txt +1 -0
  27. ovos-date-parser-0.0.1/ovos_date_parser.egg-info/requires.txt +3 -0
  28. ovos-date-parser-0.0.1/ovos_date_parser.egg-info/top_level.txt +1 -0
  29. ovos-date-parser-0.0.1/setup.cfg +4 -0
  30. ovos-date-parser-0.0.1/setup.py +81 -0
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.1
2
+ Name: ovos-date-parser
3
+ Version: 0.0.1
4
+ Summary: OpenVoiceOS's multilingual text parsing and formatting library
5
+ Home-page: https://github.com/OpenVoiceOS/ovos-date-parser
6
+ Author: Mycroft AI / OVOS
7
+ Author-email: jarbasai@mailfence.com
8
+ License: Apache2.0
9
+ Description: # ovos-date-parser
10
+
11
+ `ovos-date-parser` is a comprehensive library for multilingual date and time parsing, extraction, and formatting,
12
+ designed to handle a range of human-readable date, time, and duration expressions.
13
+
14
+ ## Features
15
+
16
+ - **Date and Time Extraction**: Extract specific dates and times from natural language phrases in various languages.
17
+ - **Duration Parsing**: Parse phrases that indicate a span of time, such as "two hours and fifteen minutes."
18
+ - **Friendly Time Formatting**: Format time for human-friendly output, supporting both 12-hour and 24-hour formats.
19
+ - **Relative Time Descriptions**: Generate relative descriptions (e.g., "tomorrow," "in three days") for given dates.
20
+ - **Multilingual Support**: Includes extraction and formatting methods for multiple languages, such as English, Spanish,
21
+ French, German, and more.
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ pip install ovos-date-parser
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ### Date and Time Extraction
32
+
33
+ Extract specific dates and times from a phrase. This function identifies date-related terms in natural language and
34
+ returns both the datetime object and any remaining text.
35
+
36
+ ```python
37
+ from ovos_date_parser import extract_datetime
38
+
39
+ result = extract_datetime("Meet me next Friday at 3pm", lang="en")
40
+ print(result) # (datetime object, "at 3pm")
41
+ ```
42
+
43
+ ### Duration Extraction
44
+
45
+ Identify duration phrases in text and convert them into a `timedelta` object. This can parse common human-friendly
46
+ duration expressions like "30 minutes" or "two and a half hours."
47
+
48
+ ```python
49
+ from ovos_date_parser import extract_duration
50
+
51
+ duration, remainder = extract_duration("It will take about 2 hours and 30 minutes", lang="en")
52
+ print(duration) # timedelta object
53
+ print(remainder) # "about"
54
+ ```
55
+
56
+ ### Formatting Time
57
+
58
+ Generate a natural-sounding time format suitable for voice or display in different languages, allowing customization for
59
+ speech or written text.
60
+
61
+ ```python
62
+ from ovos_date_parser import nice_time
63
+ from datetime import datetime
64
+
65
+ dt = datetime.now()
66
+ formatted_time = nice_time(dt, lang="en", speech=True, use_24hour=False)
67
+ print(formatted_time) # "three o'clock"
68
+ ```
69
+
70
+ ### Relative Time Descriptions
71
+
72
+ Create relative phrases for describing dates and times in relation to the current moment or a reference datetime.
73
+
74
+ ```python
75
+ from ovos_date_parser import nice_relative_time
76
+ from datetime import datetime, timedelta
77
+
78
+ relative_time = nice_relative_time(datetime.now() + timedelta(days=1), datetime.now(), lang="en")
79
+ print(relative_time) # "tomorrow"
80
+ ```
81
+
82
+ ### Languages Supported
83
+
84
+ `ovos-date-parser` supports a wide array of languages, each with its own set of methods for handling natural language
85
+ time expressions.
86
+
87
+ Parse
88
+
89
+ | Language | `extract_duration` | `extract_datetime` |
90
+ |----------|--------------------|--------------------|
91
+ | az | ✅ | ✅ |
92
+ | ca | ❌ | ✅ |
93
+ | cs | ✅ | ✅ |
94
+ | da | ❌ | ✅ |
95
+ | de | ✅ | ✅ |
96
+ | en | ✅ | ✅ |
97
+ | es | ✅ | ✅ |
98
+ | eu | ❌ | ✅ |
99
+ | fa | ✅ | ✅ |
100
+ | fr | ❌ | ✅ |
101
+ | hu | ❌ | ❌ |
102
+ | it | ❌ | ✅ |
103
+ | nl | ✅ | ✅ |
104
+ | pl | ✅ | ✅ |
105
+ | pt | ✅ | ✅ |
106
+ | ru | ✅ | ✅ |
107
+ | sv | ✅ | ✅ |
108
+ | uk | ✅ | ✅ |
109
+
110
+ Format
111
+
112
+ | Language | `nice_date`<br>`nice_date_time`<br>`nice_day` <br>`nice_weekday` <br>`nice_month` <br>`nice_year` <br>`get_date_strings` | `nice_time` | `nice_relative_time` | `nice_duration` |
113
+ |----------|--------------------------------------------------------------------------------------------------------------------------|-------------|----------------------|-----------------|
114
+ | az | ✅ | ✅ | ❌ | ✅ |
115
+ | ca | ✅ | ✅ | ❌ | ❌ |
116
+ | cs | ✅ | ✅ | ❌ | ❌ |
117
+ | da | ✅ | ✅ | ❌ | ❌ |
118
+ | de | ✅ | ✅ | ❌ | ❌ |
119
+ | en | ✅ | ✅ | ❌ | ❌ |
120
+ | es | ❌ | ✅ | ❌ | ❌ |
121
+ | eu | ✅ | ✅ | ✅ | ❌ |
122
+ | fa | ✅ | ✅ | ❌ | ❌ |
123
+ | fr | ✅ | ✅ | ❌ | ❌ |
124
+ | hu | ✅ | ✅ | ❌ | ❌ |
125
+ | it | ✅ | ✅ | ❌ | ❌ |
126
+ | nl | ✅ | ✅ | ❌ | ❌ |
127
+ | pl | ✅ | ✅ | ❌ | ✅ |
128
+ | pt | ❌ | ✅ | ❌ | ❌ |
129
+ | ru | ✅ | ✅ | ❌ | ✅ |
130
+ | sv | ✅ | ✅ | ❌ | ❌ |
131
+ | sl | ✅ | ❌ | ❌ | ❌ |
132
+ | uk | ✅ | ✅ | ❌ | ✅ |
133
+
134
+ ## Related Projects
135
+
136
+ - [ovos-number-parser](https://github.com/OpenVoiceOS/ovos-number-parser) - for handling numbers
137
+ - [ovos-lang-parser](https://github.com/OVOSHatchery/ovos-lang-parser) - for handling languages
138
+ - [ovos-color-parser](https://github.com/OVOSHatchery/ovos-color-parser) - for handling colors
139
+
140
+
141
+ ## License
142
+
143
+ This project is licensed under the Apache 2.0 License
144
+ Platform: UNKNOWN
145
+ Classifier: Development Status :: 4 - Beta
146
+ Classifier: Intended Audience :: Developers
147
+ Classifier: Topic :: Text Processing :: Linguistic
148
+ Classifier: License :: OSI Approved :: Apache Software License
149
+ Classifier: Programming Language :: Python :: 3.6
150
+ Classifier: Programming Language :: Python :: 3.7
151
+ Classifier: Programming Language :: Python :: 3.8
152
+ Classifier: Programming Language :: Python :: 3.9
153
+ Obsoletes: ovos_date_parser
154
+ Description-Content-Type: text/markdown
@@ -0,0 +1,135 @@
1
+ # ovos-date-parser
2
+
3
+ `ovos-date-parser` is a comprehensive library for multilingual date and time parsing, extraction, and formatting,
4
+ designed to handle a range of human-readable date, time, and duration expressions.
5
+
6
+ ## Features
7
+
8
+ - **Date and Time Extraction**: Extract specific dates and times from natural language phrases in various languages.
9
+ - **Duration Parsing**: Parse phrases that indicate a span of time, such as "two hours and fifteen minutes."
10
+ - **Friendly Time Formatting**: Format time for human-friendly output, supporting both 12-hour and 24-hour formats.
11
+ - **Relative Time Descriptions**: Generate relative descriptions (e.g., "tomorrow," "in three days") for given dates.
12
+ - **Multilingual Support**: Includes extraction and formatting methods for multiple languages, such as English, Spanish,
13
+ French, German, and more.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install ovos-date-parser
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ### Date and Time Extraction
24
+
25
+ Extract specific dates and times from a phrase. This function identifies date-related terms in natural language and
26
+ returns both the datetime object and any remaining text.
27
+
28
+ ```python
29
+ from ovos_date_parser import extract_datetime
30
+
31
+ result = extract_datetime("Meet me next Friday at 3pm", lang="en")
32
+ print(result) # (datetime object, "at 3pm")
33
+ ```
34
+
35
+ ### Duration Extraction
36
+
37
+ Identify duration phrases in text and convert them into a `timedelta` object. This can parse common human-friendly
38
+ duration expressions like "30 minutes" or "two and a half hours."
39
+
40
+ ```python
41
+ from ovos_date_parser import extract_duration
42
+
43
+ duration, remainder = extract_duration("It will take about 2 hours and 30 minutes", lang="en")
44
+ print(duration) # timedelta object
45
+ print(remainder) # "about"
46
+ ```
47
+
48
+ ### Formatting Time
49
+
50
+ Generate a natural-sounding time format suitable for voice or display in different languages, allowing customization for
51
+ speech or written text.
52
+
53
+ ```python
54
+ from ovos_date_parser import nice_time
55
+ from datetime import datetime
56
+
57
+ dt = datetime.now()
58
+ formatted_time = nice_time(dt, lang="en", speech=True, use_24hour=False)
59
+ print(formatted_time) # "three o'clock"
60
+ ```
61
+
62
+ ### Relative Time Descriptions
63
+
64
+ Create relative phrases for describing dates and times in relation to the current moment or a reference datetime.
65
+
66
+ ```python
67
+ from ovos_date_parser import nice_relative_time
68
+ from datetime import datetime, timedelta
69
+
70
+ relative_time = nice_relative_time(datetime.now() + timedelta(days=1), datetime.now(), lang="en")
71
+ print(relative_time) # "tomorrow"
72
+ ```
73
+
74
+ ### Languages Supported
75
+
76
+ `ovos-date-parser` supports a wide array of languages, each with its own set of methods for handling natural language
77
+ time expressions.
78
+
79
+ Parse
80
+
81
+ | Language | `extract_duration` | `extract_datetime` |
82
+ |----------|--------------------|--------------------|
83
+ | az | ✅ | ✅ |
84
+ | ca | ❌ | ✅ |
85
+ | cs | ✅ | ✅ |
86
+ | da | ❌ | ✅ |
87
+ | de | ✅ | ✅ |
88
+ | en | ✅ | ✅ |
89
+ | es | ✅ | ✅ |
90
+ | eu | ❌ | ✅ |
91
+ | fa | ✅ | ✅ |
92
+ | fr | ❌ | ✅ |
93
+ | hu | ❌ | ❌ |
94
+ | it | ❌ | ✅ |
95
+ | nl | ✅ | ✅ |
96
+ | pl | ✅ | ✅ |
97
+ | pt | ✅ | ✅ |
98
+ | ru | ✅ | ✅ |
99
+ | sv | ✅ | ✅ |
100
+ | uk | ✅ | ✅ |
101
+
102
+ Format
103
+
104
+ | Language | `nice_date`<br>`nice_date_time`<br>`nice_day` <br>`nice_weekday` <br>`nice_month` <br>`nice_year` <br>`get_date_strings` | `nice_time` | `nice_relative_time` | `nice_duration` |
105
+ |----------|--------------------------------------------------------------------------------------------------------------------------|-------------|----------------------|-----------------|
106
+ | az | ✅ | ✅ | ❌ | ✅ |
107
+ | ca | ✅ | ✅ | ❌ | ❌ |
108
+ | cs | ✅ | ✅ | ❌ | ❌ |
109
+ | da | ✅ | ✅ | ❌ | ❌ |
110
+ | de | ✅ | ✅ | ❌ | ❌ |
111
+ | en | ✅ | ✅ | ❌ | ❌ |
112
+ | es | ❌ | ✅ | ❌ | ❌ |
113
+ | eu | ✅ | ✅ | ✅ | ❌ |
114
+ | fa | ✅ | ✅ | ❌ | ❌ |
115
+ | fr | ✅ | ✅ | ❌ | ❌ |
116
+ | hu | ✅ | ✅ | ❌ | ❌ |
117
+ | it | ✅ | ✅ | ❌ | ❌ |
118
+ | nl | ✅ | ✅ | ❌ | ❌ |
119
+ | pl | ✅ | ✅ | ❌ | ✅ |
120
+ | pt | ❌ | ✅ | ❌ | ❌ |
121
+ | ru | ✅ | ✅ | ❌ | ✅ |
122
+ | sv | ✅ | ✅ | ❌ | ❌ |
123
+ | sl | ✅ | ❌ | ❌ | ❌ |
124
+ | uk | ✅ | ✅ | ❌ | ✅ |
125
+
126
+ ## Related Projects
127
+
128
+ - [ovos-number-parser](https://github.com/OpenVoiceOS/ovos-number-parser) - for handling numbers
129
+ - [ovos-lang-parser](https://github.com/OVOSHatchery/ovos-lang-parser) - for handling languages
130
+ - [ovos-color-parser](https://github.com/OVOSHatchery/ovos-color-parser) - for handling colors
131
+
132
+
133
+ ## License
134
+
135
+ This project is licensed under the Apache 2.0 License