Exemplo n.º 1
0
    def download_file(dataset):
        log_db = LogDB(app.config['LOG_DB'])
        log_db.log_download_file(dataset, request.remote_addr)

        if dataset in ['verified', 'collab']:
            dark_term_db = DarkTermDB(app.config["DARK_TERM_DB"])
            file_ptr = download_handler.get_file_path(dataset, dark_term_db)
            file_ptr = file_ptr.replace('webapp/', '', 1)
            return send_file(
                file_ptr,
                as_attachment=True,
                attachment_filename=f'darkjargon-net_{dataset}.csv')
        if dataset == 'timestamps':
            return send_file(
                'static/data/dark-terms_timestamps.pkl.gz',
                as_attachment=True,
                attachment_filename='dark-terms_timestamps.pkl.gz')
        if dataset == 'kl':
            return send_file(
                'static/data/kl_clean-term-mapping.tar.gz',
                as_attachment=True,
                attachment_filename='kl_clean-term-mapping.tar.gz')
        if dataset == 'mlm-bert':
            return send_file(
                'static/data/mlm-bert_clean-term-mapping.pkl.gz',
                as_attachment=True,
                attachment_filename='mlm-bert_clean-term-mapping.pkl.gz')
        # print error
        return 'Download Error'
Exemplo n.º 2
0
def get_collab_for_file_dump(dark_term_db: DarkTermDB):
    header = [
        'dark term', 'definition', 'definition source', 'submitted by',
        'vote_valid', 'vote_invalid'
    ]
    body = dark_term_db.fetch_collab_for_file_dump()
    return header, body
Exemplo n.º 3
0
def get_verified(dark_term_db: DarkTermDB):
    """
    helper function to read verified data from db
    The first return value is the name of the columns as a 1-d list
    The second is the data as a 2-d list
    The table in the HTML will automatically expand
    """
    header = ['dark term', 'definition', 'definition source']
    body = dark_term_db.fetch_verified()
    return header, body
Exemplo n.º 4
0
 def collab():
     log_db = LogDB(app.config['LOG_DB'])
     if request.method == 'GET':
         log_db.log_collab_get(request.remote_addr)
         dark_term_db = DarkTermDB(app.config["DARK_TERM_DB"])
         header, body = backend.get_collab(dark_term_db)
         return render_template("collab.html", header=header, body=body)
     else:
         dark_term = request.form['dark_term']
         log_db.log_dark_term_collab_click(dark_term, request.remote_addr)
         definition = request.form['definition']
         definition_source = request.form['definition_source']
         user_name = request.form['user_name']
         dark_term_db = DarkTermDB(app.config["DARK_TERM_DB"])
         dark_term_db.insert_collab(dark_term, definition,
                                    definition_source, user_name)
         return 'success'
Exemplo n.º 5
0
def get_collab(dark_term_db: DarkTermDB):
    header = [
        'dark term', 'definition', 'definition source', 'submitted by', '', ''
    ]
    body = dark_term_db.fetch_collab()
    return header, body
Exemplo n.º 6
0
 def dark_term_thumbs_down(dark_term_id):
     log_db = LogDB(app.config['LOG_DB'])
     log_db.log_thumbs_down(dark_term_id, request.remote_addr)
     dark_term_db = DarkTermDB(app.config["DARK_TERM_DB"])
     dark_term_db.thumbs_down(dark_term_id)
     return 'success'
Exemplo n.º 7
0
 def table():
     log_db = LogDB(app.config['LOG_DB'])
     log_db.log_verified(request.remote_addr)
     dark_term_db = DarkTermDB(app.config["DARK_TERM_DB"])
     header, body = backend.get_verified(dark_term_db)
     return render_template("body.html", header=header, body=body)