hafez 0.2.9__tar.gz → 0.4.0__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.
- {hafez-0.2.9/hafez.egg-info → hafez-0.4.0}/PKG-INFO +4 -2
- {hafez-0.2.9 → hafez-0.4.0}/README.md +3 -1
- {hafez-0.2.9 → hafez-0.4.0}/hafez/entry.py +3 -2
- {hafez-0.2.9 → hafez-0.4.0}/hafez/utils/db.py +20 -4
- {hafez-0.2.9 → hafez-0.4.0/hafez.egg-info}/PKG-INFO +4 -2
- {hafez-0.2.9 → hafez-0.4.0}/pyproject.toml +1 -1
- hafez-0.4.0/requirements.txt +4 -0
- hafez-0.2.9/requirements.txt +0 -3
- {hafez-0.2.9 → hafez-0.4.0}/LICENSE +0 -0
- {hafez-0.2.9 → hafez-0.4.0}/MANIFEST.in +0 -0
- {hafez-0.2.9 → hafez-0.4.0}/hafez/__init__.py +0 -0
- {hafez-0.2.9 → hafez-0.4.0}/hafez/data/audio/do_not_delete_me.txt +0 -0
- {hafez-0.2.9 → hafez-0.4.0}/hafez/data/hafez.json +0 -0
- {hafez-0.2.9 → hafez-0.4.0}/hafez/utils/__init__.py +0 -0
- {hafez-0.2.9 → hafez-0.4.0}/hafez/utils/formating.py +0 -0
- {hafez-0.2.9 → hafez-0.4.0}/hafez.egg-info/SOURCES.txt +0 -0
- {hafez-0.2.9 → hafez-0.4.0}/hafez.egg-info/dependency_links.txt +0 -0
- {hafez-0.2.9 → hafez-0.4.0}/hafez.egg-info/top_level.txt +0 -0
- {hafez-0.2.9 → hafez-0.4.0}/setup.cfg +0 -0
- {hafez-0.2.9 → hafez-0.4.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hafez
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.0
|
4
4
|
Summary: Hafez Poems
|
5
5
|
Author-email: Kaveh Bakhtiyari <kbakhtiyari@yahoo.com>
|
6
6
|
Project-URL: Homepage, https://github.com/kavehbc/hafez
|
@@ -65,11 +65,12 @@ It returns the poem in a dictionary format (see Poem Data Structure)
|
|
65
65
|
It returns a random poem in a dictionary format (see Poem Data Structure)
|
66
66
|
|
67
67
|
|
68
|
-
- `hafez.search(qeury: str)` -> `list`
|
68
|
+
- `hafez.search(qeury: str, exact_match: bool = False)` -> `list`
|
69
69
|
<br />
|
70
70
|
It returns a list of poems in a dictionary format (see Poem Data Structure)
|
71
71
|
|
72
72
|
- `query: str`: It is a string to search within the verses of the Divan Hafez
|
73
|
+
- `exact_match: bool': if True, it will search for exact match of the query
|
73
74
|
|
74
75
|
|
75
76
|
- `hafez.download_all_audio(force: boolean = False)` -> `int`
|
@@ -99,6 +100,7 @@ It returns the absolute path of the audio file related to the given `poem`.
|
|
99
100
|
{"id": 1,
|
100
101
|
"poem": [],
|
101
102
|
"interpretation": "",
|
103
|
+
"alt_interpretation": "",
|
102
104
|
"mp3": "https://..."}
|
103
105
|
```
|
104
106
|
|
@@ -50,11 +50,12 @@ It returns the poem in a dictionary format (see Poem Data Structure)
|
|
50
50
|
It returns a random poem in a dictionary format (see Poem Data Structure)
|
51
51
|
|
52
52
|
|
53
|
-
- `hafez.search(qeury: str)` -> `list`
|
53
|
+
- `hafez.search(qeury: str, exact_match: bool = False)` -> `list`
|
54
54
|
<br />
|
55
55
|
It returns a list of poems in a dictionary format (see Poem Data Structure)
|
56
56
|
|
57
57
|
- `query: str`: It is a string to search within the verses of the Divan Hafez
|
58
|
+
- `exact_match: bool': if True, it will search for exact match of the query
|
58
59
|
|
59
60
|
|
60
61
|
- `hafez.download_all_audio(force: boolean = False)` -> `int`
|
@@ -84,6 +85,7 @@ It returns the absolute path of the audio file related to the given `poem`.
|
|
84
85
|
{"id": 1,
|
85
86
|
"poem": [],
|
86
87
|
"interpretation": "",
|
88
|
+
"alt_interpretation": "",
|
87
89
|
"mp3": "https://..."}
|
88
90
|
```
|
89
91
|
|
@@ -103,13 +103,14 @@ def get_poem(poem_id) -> dict:
|
|
103
103
|
return lst_poem[0]
|
104
104
|
|
105
105
|
|
106
|
-
def search(query) -> list:
|
106
|
+
def search(query: str=None, exact_match: bool = False) -> list:
|
107
107
|
"""
|
108
108
|
It searches through the verses of Divan and once a record found, it returns the whole poem.
|
109
109
|
:param query: the string term to query into Divan
|
110
|
+
:param exact_match: if True, it will search for exact match of the query
|
110
111
|
:return: a list of dictionary containing all the poems which have the queried terms
|
111
112
|
"""
|
112
|
-
df = search_data(query)
|
113
|
+
df = search_data(query, exact_match=exact_match)
|
113
114
|
df = filter_columns(df)
|
114
115
|
lst_poem = df_to_dict(df)
|
115
116
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import pandas as pd
|
2
|
+
import numpy as np
|
2
3
|
import pathlib
|
3
4
|
import os
|
4
5
|
import json
|
@@ -27,15 +28,30 @@ def get_data(id: int = None):
|
|
27
28
|
return df
|
28
29
|
|
29
30
|
|
30
|
-
def search_data(query: str = None):
|
31
|
+
def search_data(query: str = None, exact_match: bool = False) -> pd.DataFrame:
|
32
|
+
query = query.strip()
|
31
33
|
|
32
34
|
_, df = get_connection()
|
33
35
|
df['poem_string'] = [','.join(map(str, l)) for l in df['poem']]
|
34
36
|
|
35
37
|
if query is not None and len(query) > 0:
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
if exact_match:
|
39
|
+
lst_query = [query]
|
40
|
+
else:
|
41
|
+
# Split the query into words for searching
|
42
|
+
if " " in query:
|
43
|
+
lst_query = query.split(" ")
|
44
|
+
else:
|
45
|
+
lst_query = [query]
|
46
|
+
|
47
|
+
# AND Logic
|
48
|
+
contains = [df["poem_string"].str.contains(i) for i in lst_query]
|
49
|
+
df = df[np.all(contains, axis=0)]
|
50
|
+
|
51
|
+
# OR Logic
|
52
|
+
# df = df[df["poem_string"].str.contains('|'.join(lst_query))]
|
53
|
+
|
54
|
+
df.drop(columns=["poem_string"], inplace=True, axis=1)
|
39
55
|
return df
|
40
56
|
|
41
57
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hafez
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.0
|
4
4
|
Summary: Hafez Poems
|
5
5
|
Author-email: Kaveh Bakhtiyari <kbakhtiyari@yahoo.com>
|
6
6
|
Project-URL: Homepage, https://github.com/kavehbc/hafez
|
@@ -65,11 +65,12 @@ It returns the poem in a dictionary format (see Poem Data Structure)
|
|
65
65
|
It returns a random poem in a dictionary format (see Poem Data Structure)
|
66
66
|
|
67
67
|
|
68
|
-
- `hafez.search(qeury: str)` -> `list`
|
68
|
+
- `hafez.search(qeury: str, exact_match: bool = False)` -> `list`
|
69
69
|
<br />
|
70
70
|
It returns a list of poems in a dictionary format (see Poem Data Structure)
|
71
71
|
|
72
72
|
- `query: str`: It is a string to search within the verses of the Divan Hafez
|
73
|
+
- `exact_match: bool': if True, it will search for exact match of the query
|
73
74
|
|
74
75
|
|
75
76
|
- `hafez.download_all_audio(force: boolean = False)` -> `int`
|
@@ -99,6 +100,7 @@ It returns the absolute path of the audio file related to the given `poem`.
|
|
99
100
|
{"id": 1,
|
100
101
|
"poem": [],
|
101
102
|
"interpretation": "",
|
103
|
+
"alt_interpretation": "",
|
102
104
|
"mp3": "https://..."}
|
103
105
|
```
|
104
106
|
|
hafez-0.2.9/requirements.txt
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|