-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Search functionality - Backend (#91)
* add full text search index in neo4j * implement search API * search for id as well as tags
- Loading branch information
1 parent
46bc840
commit 3317fae
Showing
7 changed files
with
123 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import re | ||
import unicodedata | ||
import unidecode | ||
|
||
def normalizing(line, lang="default"): | ||
"""normalize a string depending of the language code lang""" | ||
line = unicodedata.normalize("NFC", line) | ||
|
||
# removing accent | ||
if lang in ["fr", "ca", "es", "it", "nl", "pt", "sk", "en"]: | ||
line = re.sub(r"[¢£¤¥§©ª®°²³µ¶¹º¼½¾×‰€™]", "-", line) | ||
line = unidecode.unidecode(line) | ||
|
||
# lower case except if language in list | ||
if lang not in []: | ||
line = line.lower() | ||
|
||
# changing unwanted character to "-" | ||
line = re.sub(r"[\u0000-\u0027\u200b]", "-", line) | ||
line = re.sub(r"&\w+;", "-", line) | ||
line = re.sub( | ||
r"[\s!\"#\$%&'()*+,\/:;<=>?@\[\\\]^_`{\|}~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿×ˆ˜–—‘’‚“”„†‡•…‰‹›€™\t]", # noqa: E501 | ||
"-", | ||
line, | ||
) | ||
|
||
# removing excess "-" | ||
line = re.sub(r"-+", "-", line) | ||
line = line.strip("-") | ||
return line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,4 @@ py==1.11.0 | |
pyparsing==3.0.9 | ||
pytest==7.1.2 | ||
pytz==2022.1 | ||
tomli==2.0.1 | ||
Unidecode==1.3.4 | ||
tomli==2.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
neo4j==4.4.5 | ||
pytz==2022.1 | ||
Unidecode==1.3.4 | ||
Unidecode==1.3.4 | ||
iso-639==0.4.5 |