An open source, non-profit web search engine
Fix up document state handling
Daoud Clarke1af9cbd47da2
diff --git a/devdata/index-v2.tinysearch b/devdata/index-v2.tinysearchindex 59e8d4d..b718b3e 100644Binary files a/devdata/index-v2.tinysearch and b/devdata/index-v2.tinysearch differdiff --git a/mwmbl/format.py b/mwmbl/format.pyindex f4c6902..0a29fbc 100644--- a/mwmbl/format.py+++ b/mwmbl/format.py@@ -7,10 +7,11 @@ from mwmbl.tokenizer import tokenize, clean_unicodeDOCUMENT_SOURCES = {DocumentState.FROM_GOOGLE: 'google',DocumentState.FROM_USER: 'user',+ DocumentState.FROM_WIKI: 'wikipedia',DocumentState.ORGANIC_APPROVED: 'mwmbl',DocumentState.FROM_GOOGLE_APPROVED: 'google',DocumentState.FROM_USER_APPROVED: 'user',- DocumentState.FROM_WIKI: 'wikipedia',+ DocumentState.FROM_WIKI_APPROVED: 'wikipedia',}diff --git a/mwmbl/rankeval/evaluation/evaluate_remote.py b/mwmbl/rankeval/evaluation/evaluate_remote.pyindex af43fe4..1a2b96f 100644--- a/mwmbl/rankeval/evaluation/evaluate_remote.py+++ b/mwmbl/rankeval/evaluation/evaluate_remote.py@@ -33,7 +33,7 @@ def run():ranker = LTRRanker(RemoteIndex(), DummyCompleter(), model, 1000, True, 5)# ranker = HeuristicRanker(RemoteIndex(), DummyCompleter())model = MwmblRankingModel(ranker)- evaluate(model, fraction=0.01, use_test=True)+ evaluate(model, fraction=0.01, use_test=False)def single_query(query: str):diff --git a/mwmbl/tinysearchengine/indexer.py b/mwmbl/tinysearchengine/indexer.pyindex 67f9294..933ed37 100644--- a/mwmbl/tinysearchengine/indexer.py+++ b/mwmbl/tinysearchengine/indexer.py@@ -37,10 +37,11 @@ class DocumentState(IntEnum):DELETED = -1FROM_USER = 2FROM_GOOGLE = 3+ FROM_WIKI = 4ORGANIC_APPROVED = 7FROM_USER_APPROVED = 8FROM_GOOGLE_APPROVED = 9- FROM_WIKI = 10+ FROM_WIKI_APPROVED = 10@dataclassdiff --git a/mwmbl/views.py b/mwmbl/views.pyindex 5d14be6..05afa70 100644--- a/mwmbl/views.py+++ b/mwmbl/views.py@@ -210,12 +210,16 @@ def switch_state(state: Optional[DocumentState]) -> Optional[DocumentState]:return DocumentState.FROM_GOOGLE_APPROVEDif state == DocumentState.FROM_USER:return DocumentState.FROM_USER_APPROVED+ if state == DocumentState.FROM_WIKI:+ return DocumentState.FROM_WIKI_APPROVEDif state == DocumentState.FROM_GOOGLE_APPROVED:return DocumentState.FROM_GOOGLEif state == DocumentState.FROM_USER_APPROVED:return DocumentState.FROM_USERif state == DocumentState.ORGANIC_APPROVED:return None+ if state == DocumentState.FROM_WIKI_APPROVED:+ return DocumentState.FROM_WIKIraise ValueError(f"Unexpected state {repr(state)}")