hafez 0.3.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hafez
3
- Version: 0.3.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`
@@ -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`
@@ -103,13 +103,14 @@ def get_poem(poem_id) -> dict:
103
103
  return lst_poem[0]
104
104
 
105
105
 
106
- def search(query: str=None) -> 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
 
@@ -28,14 +28,21 @@ def get_data(id: int = None):
28
28
  return df
29
29
 
30
30
 
31
- def search_data(query: str = None):
31
+ def search_data(query: str = None, exact_match: bool = False) -> pd.DataFrame:
32
32
  query = query.strip()
33
33
 
34
34
  _, df = get_connection()
35
35
  df['poem_string'] = [','.join(map(str, l)) for l in df['poem']]
36
36
 
37
37
  if query is not None and len(query) > 0:
38
- lst_query = query.split(" ")
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]
39
46
 
40
47
  # AND Logic
41
48
  contains = [df["poem_string"].str.contains(i) for i in lst_query]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hafez
3
- Version: 0.3.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`
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "hafez"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  authors = [
5
5
  { name = "Kaveh Bakhtiyari", email = "kbakhtiyari@yahoo.com" },
6
6
  ]
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