Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Save bandwidth by checking wether better results are available at peers
Browse files Browse the repository at this point in the history
  • Loading branch information
rtrevinnoc committed Feb 13, 2021
1 parent e8537e3 commit 721bead
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Monad.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from itertools import tee, islice, chain
from nltk.corpus import wordnet
from SPARQLWrapper import SPARQLWrapper, JSON
# from polyglot.detect import Detector
from polyglot.detect import Detector

import os.path, os, shutil, json, random, smtplib, sys, socket, re, mimetypes, datetime, lmdb, hnswlib, time, bson, requests
bson.loads = bson.BSON.decode
Expand Down
8 changes: 2 additions & 6 deletions future.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,9 +848,7 @@ def _answerPeer():
numberOfPage = request.args.get("numberOfPage", 1, type=int)
minimumScore = request.args.get("minimumScore", 0, type=float)
result = answerPeer(query, q_vec, queryLanguage, numberOfURLs, numberOfPage)
print("maxPeer: ", max(result["url_scores"]))
print("maxOriginator: ", minimumScore)
if max(result["url_scores"]) >= minimumScore:
if max(result["url_scores"]) <= minimumScore:
return jsonify(result=result)
else:
raise Exception("No relevant results.")
Expand All @@ -866,9 +864,7 @@ def _answerPeerImages():
numberOfPage = request.args.get("numberOfPage", 1, type=int)
minimumScore = request.args.get("minimumScore", 0, type=float)
result = answerPeerImages(query, q_vec, queryLanguage, numberOfURLs, numberOfPage)
print("maxPeer: ", max(result["images_scores"]))
print("maxOriginator: ", minimumScore)
if max(result["images_scores"]) >= minimumScore:
if max(result["images_scores"]) <= minimumScore:
return jsonify(result=result)
else:
raise Exception("No relevant results.")
Expand Down

0 comments on commit 721bead

Please sign in to comment.