mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 05:39:12 +00:00
Rename explicit filter to word filter to be more specific
This commit is contained in:
@@ -140,7 +140,7 @@ def test_notes_search_with_include_filter(content_config: ContentConfig, search_
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
# assert actual_data contains explicitly included word "Emacs"
|
||||
# assert actual_data contains word "Emacs"
|
||||
search_result = response.json()[0]["entry"]
|
||||
assert "Emacs" in search_result
|
||||
|
||||
@@ -156,6 +156,6 @@ def test_notes_search_with_exclude_filter(content_config: ContentConfig, search_
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
# assert actual_data does not contains explicitly excluded word "Emacs"
|
||||
# assert actual_data does not contains word "Emacs"
|
||||
search_result = response.json()[0]["entry"]
|
||||
assert "clone" not in search_result
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
import torch
|
||||
|
||||
# Application Packages
|
||||
from src.search_filter.explicit_filter import ExplicitFilter
|
||||
from src.search_filter.word_filter import WordFilter
|
||||
from src.utils.config import SearchType
|
||||
|
||||
|
||||
def test_no_explicit_filter(tmp_path):
|
||||
def test_no_word_filter(tmp_path):
|
||||
# Arrange
|
||||
explicit_filter = ExplicitFilter(tmp_path, SearchType.Org)
|
||||
word_filter = WordFilter(tmp_path, SearchType.Org)
|
||||
embeddings, entries = arrange_content()
|
||||
q_with_no_filter = 'head tail'
|
||||
|
||||
# Act
|
||||
can_filter = explicit_filter.can_filter(q_with_no_filter)
|
||||
ret_query, ret_entries, ret_emb = explicit_filter.apply(q_with_no_filter, entries.copy(), embeddings)
|
||||
can_filter = word_filter.can_filter(q_with_no_filter)
|
||||
ret_query, ret_entries, ret_emb = word_filter.apply(q_with_no_filter, entries.copy(), embeddings)
|
||||
|
||||
# Assert
|
||||
assert can_filter == False
|
||||
@@ -23,15 +23,15 @@ def test_no_explicit_filter(tmp_path):
|
||||
assert ret_entries == entries
|
||||
|
||||
|
||||
def test_explicit_exclude_filter(tmp_path):
|
||||
def test_word_exclude_filter(tmp_path):
|
||||
# Arrange
|
||||
explicit_filter = ExplicitFilter(tmp_path, SearchType.Org)
|
||||
word_filter = WordFilter(tmp_path, SearchType.Org)
|
||||
embeddings, entries = arrange_content()
|
||||
q_with_exclude_filter = 'head -"exclude_word" tail'
|
||||
|
||||
# Act
|
||||
can_filter = explicit_filter.can_filter(q_with_exclude_filter)
|
||||
ret_query, ret_entries, ret_emb = explicit_filter.apply(q_with_exclude_filter, entries.copy(), embeddings)
|
||||
can_filter = word_filter.can_filter(q_with_exclude_filter)
|
||||
ret_query, ret_entries, ret_emb = word_filter.apply(q_with_exclude_filter, entries.copy(), embeddings)
|
||||
|
||||
# Assert
|
||||
assert can_filter == True
|
||||
@@ -40,15 +40,15 @@ def test_explicit_exclude_filter(tmp_path):
|
||||
assert ret_entries == [entries[0], entries[2]]
|
||||
|
||||
|
||||
def test_explicit_include_filter(tmp_path):
|
||||
def test_word_include_filter(tmp_path):
|
||||
# Arrange
|
||||
explicit_filter = ExplicitFilter(tmp_path, SearchType.Org)
|
||||
word_filter = WordFilter(tmp_path, SearchType.Org)
|
||||
embeddings, entries = arrange_content()
|
||||
query_with_include_filter = 'head +"include_word" tail'
|
||||
|
||||
# Act
|
||||
can_filter = explicit_filter.can_filter(query_with_include_filter)
|
||||
ret_query, ret_entries, ret_emb = explicit_filter.apply(query_with_include_filter, entries.copy(), embeddings)
|
||||
can_filter = word_filter.can_filter(query_with_include_filter)
|
||||
ret_query, ret_entries, ret_emb = word_filter.apply(query_with_include_filter, entries.copy(), embeddings)
|
||||
|
||||
# Assert
|
||||
assert can_filter == True
|
||||
@@ -57,15 +57,15 @@ def test_explicit_include_filter(tmp_path):
|
||||
assert ret_entries == [entries[2], entries[3]]
|
||||
|
||||
|
||||
def test_explicit_include_and_exclude_filter(tmp_path):
|
||||
def test_word_include_and_exclude_filter(tmp_path):
|
||||
# Arrange
|
||||
explicit_filter = ExplicitFilter(tmp_path, SearchType.Org)
|
||||
word_filter = WordFilter(tmp_path, SearchType.Org)
|
||||
embeddings, entries = arrange_content()
|
||||
query_with_include_and_exclude_filter = 'head +"include_word" -"exclude_word" tail'
|
||||
|
||||
# Act
|
||||
can_filter = explicit_filter.can_filter(query_with_include_and_exclude_filter)
|
||||
ret_query, ret_entries, ret_emb = explicit_filter.apply(query_with_include_and_exclude_filter, entries.copy(), embeddings)
|
||||
can_filter = word_filter.can_filter(query_with_include_and_exclude_filter)
|
||||
ret_query, ret_entries, ret_emb = word_filter.apply(query_with_include_and_exclude_filter, entries.copy(), embeddings)
|
||||
|
||||
# Assert
|
||||
assert can_filter == True
|
||||
Reference in New Issue
Block a user