Skip to content

armgit / mwmbl

Public Imported from GitHub
0

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.tinysearch
index 59e8d4d..b718b3e 100644
Binary files a/devdata/index-v2.tinysearch and b/devdata/index-v2.tinysearch differ
diff --git a/mwmbl/format.py b/mwmbl/format.py
index f4c6902..0a29fbc 100644
--- a/mwmbl/format.py
+++ b/mwmbl/format.py
@@ -7,10 +7,11 @@ from mwmbl.tokenizer import tokenize, clean_unicode
DOCUMENT_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.py
index 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.py
index 67f9294..933ed37 100644
--- a/mwmbl/tinysearchengine/indexer.py
+++ b/mwmbl/tinysearchengine/indexer.py
@@ -37,10 +37,11 @@ class DocumentState(IntEnum):
DELETED = -1
FROM_USER = 2
FROM_GOOGLE = 3
+ FROM_WIKI = 4
ORGANIC_APPROVED = 7
FROM_USER_APPROVED = 8
FROM_GOOGLE_APPROVED = 9
- FROM_WIKI = 10
+ FROM_WIKI_APPROVED = 10
@dataclass
diff --git a/mwmbl/views.py b/mwmbl/views.py
index 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_APPROVED
if state == DocumentState.FROM_USER:
return DocumentState.FROM_USER_APPROVED
+ if state == DocumentState.FROM_WIKI:
+ return DocumentState.FROM_WIKI_APPROVED
if state == DocumentState.FROM_GOOGLE_APPROVED:
return DocumentState.FROM_GOOGLE
if state == DocumentState.FROM_USER_APPROVED:
return DocumentState.FROM_USER
if state == DocumentState.ORGANIC_APPROVED:
return None
+ if state == DocumentState.FROM_WIKI_APPROVED:
+ return DocumentState.FROM_WIKI
raise ValueError(f"Unexpected state {repr(state)}")