Skip to content

Commit 2dd7b0f

Browse files
authored
Merge pull request #169 from openzim/accented_search
Accented search
2 parents 9aa2d40 + a02c4b7 commit 2dd7b0f

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: test
22
on: [push]
33

44
env:
5-
LIBZIM_DL_VERSION: "8.2.0"
5+
LIBZIM_DL_VERSION: "2023-07-13"
66

77
jobs:
88
lint:

.github/workflows/wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- main
88

99
env:
10-
LIBZIM_DL_VERSION: "8.2.0"
10+
LIBZIM_DL_VERSION: "2023-07-13"
1111
MACOSX_DEPLOYMENT_TARGET: "11.0"
1212
CIBW_ENVIRONMENT_PASS_LINUX: "LIBZIM_DL_VERSION"
1313

tests/test_libzim_creator.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,3 +783,46 @@ def test_creator_badfilename(tmpdir):
783783
# forward slash points to non-existing folder
784784
with pytest.raises(IOError):
785785
Creator(tmpdir / "test/test.zim")
786+
787+
788+
def test_accented_search_from_libzim(fpath):
789+
"""copy of libzim accented search test
790+
791+
https://github.com/openzim/libzim/blob/main/test/search.cpp#L290 (88543b00)"""
792+
793+
with Creator(fpath).config_verbose(True).config_indexing(True, "eng") as creator:
794+
creator.add_item(
795+
StaticItem(
796+
path="path0",
797+
title="Test Article0",
798+
content="This is a tèst articlé. temp0",
799+
mimetype="text/html",
800+
)
801+
)
802+
803+
creator.add_item(
804+
StaticItem(
805+
path="path1",
806+
title="Test Article1",
807+
content="This is another test article. For article1.",
808+
mimetype="text/html",
809+
)
810+
)
811+
812+
zim = Archive(fpath)
813+
814+
assert zim.entry_count == 2
815+
assert zim.article_count == 2
816+
assert zim.all_entry_count == 7
817+
818+
ascii_query = Query().set_query("test article")
819+
ascii_searcher = Searcher(zim)
820+
ascii_search = ascii_searcher.search(ascii_query)
821+
assert ascii_search.getEstimatedMatches() == zim.article_count
822+
assert list(ascii_search.getResults(0, zim.article_count)) == ["path0", "path1"]
823+
824+
accented_query = Query().set_query("test àrticlé")
825+
accented_searcher = Searcher(zim)
826+
accented_search = accented_searcher.search(accented_query)
827+
assert accented_search.getEstimatedMatches() == zim.article_count
828+
assert list(accented_search.getResults(0, zim.article_count)) == ["path0", "path1"]

0 commit comments

Comments
 (0)