hafez 0.2.8__py3-none-any.whl → 0.3.0__py3-none-any.whl

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/entry.py CHANGED
@@ -103,7 +103,7 @@ 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) -> 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
hafez/utils/db.py CHANGED
@@ -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
@@ -28,14 +29,22 @@ def get_data(id: int = None):
28
29
 
29
30
 
30
31
  def search_data(query: str = None):
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
38
  lst_query = query.split(" ")
37
- df = df[df["poem_string"].str.contains('|'.join(lst_query))]
38
39
 
40
+ # AND Logic
41
+ contains = [df["poem_string"].str.contains(i) for i in lst_query]
42
+ df = df[np.all(contains, axis=0)]
43
+
44
+ # OR Logic
45
+ # df = df[df["poem_string"].str.contains('|'.join(lst_query))]
46
+
47
+ df.drop(columns=["poem_string"], inplace=True, axis=1)
39
48
  return df
40
49
 
41
50
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hafez
3
- Version: 0.2.8
3
+ Version: 0.3.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
@@ -99,6 +99,7 @@ It returns the absolute path of the audio file related to the given `poem`.
99
99
  {"id": 1,
100
100
  "poem": [],
101
101
  "interpretation": "",
102
+ "alt_interpretation": "",
102
103
  "mp3": "https://..."}
103
104
  ```
104
105
 
@@ -0,0 +1,12 @@
1
+ hafez/__init__.py,sha256=e6agkcalSQq5BQAqSxDOqOjEappydKY9T3N0LHLV9SU,257
2
+ hafez/entry.py,sha256=U2Ld2jJr4zTRJdc9Fx_Yi6OJM1bWxY8v2kWpCcZAnRc,3764
3
+ hafez/data/hafez.json,sha256=SZW-vQCAHOcy75MB4pF0Wc0v7Wuaa6_PXccQvcVNuuI,2430767
4
+ hafez/data/audio/do_not_delete_me.txt,sha256=Gh6YTvONnauMYf7pVXjjXiik5C_FSW-e9orhoxC3Nns,23
5
+ hafez/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ hafez/utils/db.py,sha256=GTca0eLEK4C-as21Va7hP2My07St4iiHkNpDtukFriE,1450
7
+ hafez/utils/formating.py,sha256=SlGtfVb30Q0Yg0qysgdoFcN4f-TbuxsxaN-aRE0HDSM,493
8
+ hafez-0.3.0.dist-info/licenses/LICENSE,sha256=TSObqi3glpU9S9P6kSv8d488pt0Cc3xDgoUF6yHlx3g,1099
9
+ hafez-0.3.0.dist-info/METADATA,sha256=23FuzMgJjc0imCbbvKYtEDxZ8IS1fdNzzkF98VW-nys,4039
10
+ hafez-0.3.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
11
+ hafez-0.3.0.dist-info/top_level.txt,sha256=zl_xBZxOuP1dJA41E3Cnxb-LZrnLFhpu7JCz3UW5uDs,6
12
+ hafez-0.3.0.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- hafez/__init__.py,sha256=e6agkcalSQq5BQAqSxDOqOjEappydKY9T3N0LHLV9SU,257
2
- hafez/entry.py,sha256=JoKaNsnhisrrmPkwt6nHY7syaMlDPq4ZvwhRi30jr-E,3754
3
- hafez/data/hafez.json,sha256=K7bDXuMFxfwAD3p2L1tXgqH41aFZaeksO7Y-pUmvkdU,2573404
4
- hafez/data/audio/do_not_delete_me.txt,sha256=Gh6YTvONnauMYf7pVXjjXiik5C_FSW-e9orhoxC3Nns,23
5
- hafez/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- hafez/utils/db.py,sha256=peU1B0rSc1IUEhy802-MkGNN_9mQwKucBiVNI2WRFOM,1178
7
- hafez/utils/formating.py,sha256=SlGtfVb30Q0Yg0qysgdoFcN4f-TbuxsxaN-aRE0HDSM,493
8
- hafez-0.2.8.dist-info/licenses/LICENSE,sha256=TSObqi3glpU9S9P6kSv8d488pt0Cc3xDgoUF6yHlx3g,1099
9
- hafez-0.2.8.dist-info/METADATA,sha256=OhkJ6Z_ux-4sMAH1jYAnKJUNvr88g1qhKqyS5nObmJg,4012
10
- hafez-0.2.8.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
11
- hafez-0.2.8.dist-info/top_level.txt,sha256=zl_xBZxOuP1dJA41E3Cnxb-LZrnLFhpu7JCz3UW5uDs,6
12
- hafez-0.2.8.dist-info/RECORD,,
File without changes