An open source, non-profit web search engine
Add wiki score as a feature
Daoud Clarke51252b2fb128
diff --git a/mwmbl/rankeval/evaluation/evaluate_remote.py b/mwmbl/rankeval/evaluation/evaluate_remote.pyindex a77a9e9..e11ae94 100644--- a/mwmbl/rankeval/evaluation/evaluate_remote.py+++ b/mwmbl/rankeval/evaluation/evaluate_remote.py@@ -33,7 +33,7 @@ def run():ranker = LTRRanker(ranker, model, 1000)# ranker = HeuristicRanker(RemoteIndex(), DummyCompleter())model = MwmblRankingModel(ranker)- evaluate(model, fraction=0.01)+ evaluate(model, fraction=0.01, use_test=True)def single_query(query: str):diff --git a/mwmbl/tinysearchengine/rank.py b/mwmbl/tinysearchengine/rank.pyindex 74a8ddb..787adbd 100644--- a/mwmbl/tinysearchengine/rank.py+++ b/mwmbl/tinysearchengine/rank.py@@ -26,6 +26,8 @@ LENGTH_PENALTY = 0.04MATCH_EXPONENT = 2DOMAIN_SCORE_SMOOTHING = 0.1HTTPS_STRING = 'https://'+WIKI_SCORES = json.load(open(Path(__file__).parent.parent / "resources" / "wiki_stats.json"))+WIKI_MAX_SCORE = next(iter(WIKI_SCORES.values()))def score_result(terms: list[str], result: Document, is_complete: bool):@@ -78,6 +80,7 @@ def get_features(terms, title, url, extract, score, is_complete):features['domain_score'] = get_domain_score(url)features['path_length'] = len(path)features['domain_length'] = len(domain)+ features['wiki_score'] = get_wiki_score(url)features['item_score'] = scorereturn features@@ -116,15 +119,9 @@ def get_match_features(terms, result_string, is_complete, is_url):return last_match_char, match_length, total_possible_match_length, len(seen_matches)-WIKI_SCORES = json.load(open(Path(__file__).parent.parent / "resources" / "wiki_stats.json"))-WIKI_MAX_SCORE = next(iter(WIKI_SCORES.values()))--def get_wiki_score(url):title = url.split('/')[-1]- score = WIKI_SCORES.get(title, 0.0) / WIKI_MAX_SCORE- print(f"Score for {url}: {score}")- return score+ return WIKI_SCORES.get(title, 0.0) / WIKI_MAX_SCOREdef order_results(terms: list[str], results: list[Document], is_complete: bool) -> list[Document]: