Exemplo n.º 1
0
def enrich():
    log_cmd('Requested enrich', 'green')
    ttl_file = request.files['ttl']
    params_file = request.files['params']
    prom = params_file.read()
    params = json.loads(prom.decode('utf8'))
    config = {
        "input_file": ttl_file,
        "link_type": params['kg'],
        "predicate": params['pred'],
    }
    #ont, enr_stats, ont_stats, subs_data, ontology_summary = main(options, ont_query)
    start = time.time()
    enriched_ontology, ontology_stats, ontology_summary, enrichment_warns_num = main('options.json', config)
    end = time.time()
    enrichment_stats = get_enrichment_stats(ontology_summary)
    result_dict = {
        "enriched_ontology": enriched_ontology.decode('utf8'),
        "enrichment_time": math.ceil(end - start),
        "enrichment_warns_num": enrichment_warns_num,
        "ontology_stats": ontology_stats,
        "ontology_summary": ontology_summary,
        "enrichment_stats": enrichment_stats,
    }
    #print(result_dict['ontology_summary']['https://w3id.org/i40/sto#IEC_42010']['added'])
    return jsonify(result_dict)
Exemplo n.º 2
0
def index():
    """Render result page."""
    log_cmd('Requested result.index', 'green')
    return render_template('result.html',
                           page_title='Result',
                           local_css='result.css',
                           )
Exemplo n.º 3
0
def index():
    """Render upload page."""
    log_cmd('Requested upload.index', 'green')
    return render_template(
        'upload.html',
        page_title='Upload',
        local_css='upload.css',
    )
Exemplo n.º 4
0
def index():
    """Render graph page."""
    log_cmd('Requested graph.index', 'green')
    return render_template('graph.html',
                           page_title='Graph',
                           local_css='graph.css',
                           #options = options,
                           )
Exemplo n.º 5
0
def index():
    """Render validation page."""
    log_cmd('Requested validation.index', 'green')
    return render_template(
        'validation.html',
        page_title='Validation',
        local_css='validation.css',
    )
Exemplo n.º 6
0
def index():
    """Render enrichment page."""
    log_cmd('Requested enrichment.index', 'green')
    return render_template(
        'enrichment.html',
        page_title='Enrichment',
        local_css='enrichment.css',
    )
Exemplo n.º 7
0
def index():
    """Render overview page."""
    log_cmd('Requested overview.index', 'green')
    return render_template(
        'overview.html',
        page_title='Overview',
        local_css='overview.css',
    )
Exemplo n.º 8
0
def index():
    """Render statistics page."""
    log_cmd('Requested statistics.index', 'green')
    return render_template(
        'statistics.html',
        page_title='Statistics',
        local_css='statistics.css',
    )
Exemplo n.º 9
0
def index():
    """Render wheel page."""
    log_cmd('Requested wheel.index', 'green')
    #options = get_sto_subs()
    return render_template(
        'wheel.html',
        page_title='Wheel',
        local_css='wheel.css',
        #options = options,
    )
Exemplo n.º 10
0
def upload_file():
    """ """
    log_cmd('Requested file upload', 'green')
    current_path = os.path.dirname(os.path.abspath(__file__))
    upload_folder = 'files'
    upload_path = os.path.join(current_path, upload_folder)
    file = request.files['file']
    filename = secure_filename(file.filename) + str(int(time.time()))
    file.save(os.path.join(upload_path, filename))
    return jsonify({'filename': filename})
Exemplo n.º 11
0
def get_graph_data():
    """ """
    log_cmd('Requested graph data', 'green')

    enriched_ttl_file = request.files['enriched_ttl']
    subs_data_file = request.files['subs_data']
    prom_subs = subs_data_file.read()
    subs_data = json.loads(prom_subs.decode('utf8'))
    prefixes_file = request.files['prefixes']
    prom_prefixes = prefixes_file.read()
    prefixes = json.loads(prom_prefixes.decode('utf8'))
    ont = Ontology(enriched_ttl_file, 'Enriched Ontology')
    print('after')
    #graph_data, flag = get_cy_data(ont, subs_data)
    graph_data, flag = get_sigma_data(ont, subs_data, prefixes)
    return jsonify({"graph_data": graph_data, "flag": flag})
Exemplo n.º 12
0
def main():
    """Main entry point of the app."""
    app = create_app()
    logger = logging.getLogger(__name__)
    try:
        http_server = WSGIServer((CONFIG['host'], CONFIG['port']),
                                 app,
                                 log=logging,
                                 error_log=logging)
        log_text = 'Server is running on {}:{}'.format(CONFIG['host'],
                                                       CONFIG['port'])
        log_cmd(log_text, 'green')
        http_server.serve_forever()
    except Exception as exc:
        log_cmd('Error while launching the server', 'red')
        logger.error(exc)
        logger.exception(traceback.format_exc())
    finally:
        pass
Exemplo n.º 13
0
def get_wheel_data():
    """ """
    log_cmd('Requested wheel data', 'green')
    names = [
        'sto:IEC_62541', 'rdf:type', 'dcterms:hasLicense',
        'sto:hasClassification', 'sto:hasDeveloper', 'dcterms:subject',
        'sto:hasDomain', 'sto:hasPublisher', 'sto:relatedTo',
        'sto:useStructureOf', 'sto:hasDBpediaResource',
        'sto:hasOfficialResource', 'sto:hasTag', 'sto:hasWikipediaArticle',
        'dcterms:hasLicense', 'lingg:hypernym', 'rdfs:comment', 'rdfs:label'
    ]
    colors = [
        'gray', 'lightblue', 'lightgray', 'lightgray', 'lightgray',
        'lightgreen', 'lightgray', 'lightgray', 'lightblue', 'lightgreen',
        'lightsalmon', 'lightsalmon', 'lightgray', 'lightsalmon', 'lightgray',
        'lightgreen', 'lightblue', 'lightgray'
    ]
    mtx = np.zeros((len(names), len(names))).astype(int)
    mtx[:, 0] = np.ones(len(names))

    return jsonify({'mtx': mtx.tolist(), 'names': names, 'colors': colors})
Exemplo n.º 14
0
def get_sto_properties():
    """ """
    log_cmd('Requested sto-properties', 'green')
    return jsonify(sto_properties())
Exemplo n.º 15
0
def get_standard_organizations():
    """ """
    log_cmd('Requested standard-organizations', 'green')
    return jsonify(standard_organizations())
Exemplo n.º 16
0
def get_standards():
    """ """
    log_cmd('Requested standards', 'green')
    return jsonify(standards())
Exemplo n.º 17
0
def get_enrichment_data():
    """ """
    log_cmd('Requested enrichment data', 'green')
    return jsonify({})
Exemplo n.º 18
0
def get_statistics_data():
    """ """
    log_cmd('Requested statistics data', 'green')
    return jsonify({})
Exemplo n.º 19
0
def template():
    """ """
    log_cmd('Requested SHACL template', 'green')
    with open(os.path.join(STATIC_DIR, 'template.ttl'), 'r') as f:
        template = f.read()
    return template