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

Commit

Permalink
Distributed testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rtrevinnoc committed Feb 13, 2021
1 parent fdc1d2d commit 049bb5f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
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
30 changes: 30 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
=============
API Endpoints
=============

All public FUTURE instances expose a set of dedicated routes that allow to automate the extraction of information.
Each one of these simulate as if a user (in this case an application) entered a query through the user interface, but instead reply with JSON.

Output
======

The most important routes in a FUTURE instance are the **output** endpoints, because they allow to extract information from the server easily.
These are used to obtain URL's or images from the index, or perhaps to get a list of all registered peers in a given instance.

/_answer
--------

.. note:: The parameters for this route are:

This is the main method to get
+-------+---------+--------+------+
| Input | | Output | |
+=======+=========+========+======+
| Name | Type | Name | Type |
+-------+---------+--------+------+
| query | String | | |
+-------+---------+--------+------+
| page | Integer | | |
+-------+---------+--------+------+
| | | | |
+-------+---------+--------+------+
6 changes: 6 additions & 0 deletions future.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@ def _retrieveImage():
image = requests.get("http:" + url, allow_redirects=True)
except:
image = requests.get("https:" + url, allow_redirects=True)
else:
image = requests.get(url, allow_redirects=True)

pic = Image.open(io.BytesIO(image.content))
pic.thumbnail((480, 480), Image.LANCZOS)
Expand Down Expand Up @@ -846,6 +848,8 @@ 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:
return jsonify(result=result)
else:
Expand All @@ -862,6 +866,8 @@ 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["url_scores"]))
print("maxOriginator: ", minimumScore)
if max(result["images_scores"]) >= minimumScore:
return jsonify(result=result)
else:
Expand Down

0 comments on commit 049bb5f

Please sign in to comment.