예제 #1
0
def main(config_filename=None):
    # establish config filename
    if config_filename is None:
        config_filename = input('Insert Config Filename (filename.yaml): ')
        if ('yaml' in config_filename) == True:
            config_filename = config_filename[:-5]

    # import config file
    with open('./src/config/{}.yaml'.format(config_filename)) as file:
        config = yaml.load(file)

    # initialize the OSRM server
    init_osrm.main(config, logger)

    # initialize and connect to the server
    db = init_db(config)

    # add origins and destinations
    init_destinations(db, config)
    init_origins(db, config)
    db['con'].close()

    # query
    query.main(config)

    # shutdown the OSRM server
    shutdown_db(config)
예제 #2
0
    def test_write_and_read(self):
        # test writes
        opts = copy(self.options)
        opts.key = 'sandbox_one'
        opts.value = 'one'
        query.OPTIONS = opts
        query.main()
        self.assertTrue(query.LAST_DATA is None)
        opts = copy(self.options)
        opts.key = 'sandbox_two'
        opts.value = 'two'
        query.OPTIONS = opts
        query.main()
        self.assertTrue(query.LAST_DATA is None)

        # test reads
        opts = copy(self.options)
        opts.key = 'sandbox_one'
        opts.value = None
        query.OPTIONS = opts
        query.main()
        self.assertEquals(query.LAST_DATA, 'one')
        opts = copy(self.options)
        opts.key = 'sandbox_two'
        opts.value = None
        query.OPTIONS = opts
        query.main()
        self.assertEquals(query.LAST_DATA, 'two')
예제 #3
0
    def get(self, query):
        videos = main(query)

        response = app.response_class(response=videos,
                                      status=200,
                                      mimetype='application/json')
        return response
예제 #4
0
def metrics(query_string):
    """
  A helper function to obtain performance metrics for the search engine for a particular query.
  Uses the results from elasticsearch as the true labels
  Inputs:
    query_string : The query input of the user
  Outputs:
    confusion_matrix : A tuple of true positive, true negative, false positive and false negative of the results returned by our search engine
  """
    results, happ_time = query.main(query_string)
    #results, happ_time = query.main(query_string)
    es_results, es_time = search_snippet(query_string)
    es_doc_ids = {
        x['_source']['id']
        for x in [i for i in es_results['hits']['hits']]
    }
    doc_ids = {x['_source']['id'] for x in [i for i in results['hits']]}

    print(happ_time, es_time)
    tp = len(doc_ids.intersection(es_doc_ids))
    fp = len(doc_ids) - tp
    fn = len(es_doc_ids) - tp
    tn = query.ind.ndocs - tp - fp - fn
    confusion_matrix = (tp, fp, fn, tn, happ_time, es_time)
    return confusion_matrix
예제 #5
0
 def makeQuery(self):
     queryText = self.lineEdit.text()
     results = query.main(query=queryText)
     answer = ''
     for docId in results:
         answer += "document # {} \n".format(docId)
     self.textBrowser.setText(answer)
def query_string():
    """
    Route for performing queries.
    """
    reqobj = request.json
    if reqobj['engine'] == 1:
        return jsonify(query.main(reqobj['query'])[0]), 200
    elif reqobj['engine'] == 2:
        return jsonify(search_snippet(reqobj['query'])['hits']), 200
    else:
        abort(400)
예제 #7
0
def index(req):
    server = sapi.ModPythonServer(req)
    try:
        query.main(server, cfg, "viewvc.py")
    finally:
        server.close()
예제 #8
0
파일: query.py 프로젝트: foresthz/fusion5.1
def index(req):
  server = sapi.ModPythonServer(req)
  try:
    query.main(server, cfg, "viewvc.py")
  finally:
    server.close()
'''
Runs query.1, query.2 and query.3
Writes results to textfile in trec format
'''

import query
import parameters
import os

OUT_DIR = "testbed/"
RESULT_FILE = "control_results.txt"
if parameters.use_thesaurus:
    RESULT_FILE = "thesaurus_results.txt"
QUERY_DIR = "testbed/"
COLLECTION = "testbed/emotions_collection"

# clear results textfile
output = OUT_DIR + RESULT_FILE
if os.path.isfile(OUT_DIR + RESULT_FILE):
    with open(output, "w") as f:
        f.write("")
    f.close()

# run queries
for i in range(1, 4):
    f = open(QUERY_DIR + "query." + str(i), "r")
    lines = f.readlines()
    text_query = lines[0]
    if (text_query != ""):
        query.main(str(i), COLLECTION, text_query)
예제 #10
0
파일: run.py 프로젝트: tawfiqjaffar/MP3INFO
#!/usr/bin/env python3
import subprocess
import argparse
import query

parser = argparse.ArgumentParser()

parser.add_argument('-s', '--search', help="python3 run.py -s 'songOrArist'")

args = parser.parse_args()

if args.search is None:
    print('No argument provided. Killing process.')
else:
    query.main(args.search)
예제 #11
0
파일: routes.py 프로젝트: alx-b/blog
def testing():
    query.main()
    return render_template("testing.html")
예제 #12
0
def reply():
    #access your DB get your results here
    # print request.args.get("query")
    val = query.main(request.args.get("query"))
    data = {"value": val}
    return jsonify(data)
예제 #13
0
def main():
    createState()
    createColor()
    createTeam()
    createPlayer()
    query.main()
예제 #14
0
    "$numberDouble": "0.2053644061088562"
}, {
    "$numberDouble": "-0.8933081030845642"
}, {
    "$numberDouble": "-0.07082071900367737"
}, {
    "$numberDouble": "-0.6869916915893555"
}, {
    "$numberDouble": "0.7410644292831421"
}, {
    "$numberDouble": "2.1064789295196533"
}, {
    "$numberDouble": "-1.4959757328033447"
}, {
    "$numberDouble": "-0.9279530048370361"
}, {
    "$numberDouble": "-0.8800253868103027"
}, {
    "$numberDouble": "-1.0426535606384277"
}, {
    "$numberDouble": "-1.1729164123535156"
}]
dd = []
for i in x:
    dd.append(float(i['$numberDouble']))
query.main(dd)
end = time.time()
print(end - start)

#-----------------------------------------------------------------------------