Example #1
0
def see_documentation():
    """
    This function redirects to the api documentation
    """
    return jsonify({
        '@context': responses.CONTEXT
    })
Example #2
0
def query_top_related(uri):
    req_args = flask.request.args
    uri = '/' + uri.rstrip('/ ')
    limit = get_int(req_args, 'limit', 50, 0, 100)
    filter = req_args.get('filter')
    results = responses.query_related(uri, filter=filter, limit=limit)
    return jsonify(results)
Example #3
0
def query_top_related(uri):
    req_args = flask.request.args
    uri = '/' + uri.rstrip('/ ')
    limit = get_int(req_args, 'limit', 50, 0, 100)
    filter = req_args.get('filter')
    results = responses.query_related(uri, filter=filter, limit=limit)
    return jsonify(results)
Example #4
0
def query_standardize_uri():
    """
    Look up the URI for a given piece of text. 'text' and 'language' should be
    given as parameters.
    """
    language = flask.request.args.get('language')
    text = flask.request.args.get('text') or flask.request.args.get('term')
    return jsonify(standardize_uri(language, text))
Example #5
0
def see_documentation():
    """
    This function redirects to the api documentation
    """
    return jsonify({
        '@context': responses.CONTEXT,
        'rdfs:comment': 'See http://www.conceptnet.io for more information about ConceptNet, and http://api.conceptnet.io/docs for the API documentation.'
    })
Example #6
0
def query():
    criteria = {}
    offset = get_int(req_args, 'offset', 0, 0, 100000)
    limit = get_int(req_args, 'limit', 50, 0, 1000)
    for key in flask.request.args:
        if key in VALID_KEYS:
            criteria[key] = flask.request.args[key]
    results = responses.query_paginated(criteria, offset=offset, limit=limit)
    return jsonify(results)
Example #7
0
def query():
    req_args = flask.request.args
    criteria = {}
    offset = get_int(req_args, 'offset', 0, 0, 100000)
    limit = get_int(req_args, 'limit', 50, 0, 1000)
    for key in flask.request.args:
        if key in VALID_KEYS:
            criteria[key] = flask.request.args[key]
    results = responses.query_paginated(criteria, offset=offset, limit=limit)
    return jsonify(results)
Example #8
0
def see_documentation():
    """
    This function redirects to the api documentation
    """
    return jsonify({
        '@context':
        responses.CONTEXT,
        'rdfs:comment':
        'See http://www.conceptnet.io for more information about ConceptNet, and http://api.conceptnet.io/docs for the API documentation.'
    })
Example #9
0
def query_standardize_uri():
    """
    Look up the URI for a given piece of text. 'text' and 'language' should be
    given as parameters.
    """
    language = flask.request.args.get('language')
    text = flask.request.args.get('text') or flask.request.args.get('term')
    return jsonify({
        '@context': responses.CONTEXT,
        '@id': standardized_concept_uri(language, text)
    })
Example #10
0
def query_node(top, query):
    req_args = flask.request.args
    path = '/%s/%s' % (top, query.strip('/'))
    offset = get_int(req_args, 'offset', 0, 0, 100000)
    limit = get_int(req_args, 'limit', 20, 0, 1000)
    grouped = req_args.get('grouped', 'false').lower() == 'true'
    if grouped:
        limit = min(limit, 100)
        results = responses.lookup_grouped_by_feature(path, group_limit=limit)
    else:
        results = responses.lookup_paginated(path, offset=offset, limit=limit)
    return jsonify(results)
Example #11
0
def query_node(top, query):
    req_args = flask.request.args
    path = '/%s/%s' % (top, query.strip('/'))
    offset = get_int(req_args, 'offset', 0, 0, 100000)
    limit = get_int(req_args, 'limit', 20, 0, 1000)
    grouped = req_args.get('grouped', 'false').lower() == 'true'
    if grouped:
        limit = min(limit, 100)
        results = responses.lookup_grouped_by_feature(path, feature_limit=limit)
    elif path.startswith('/a/'):
        results = responses.lookup_single_assertion(path)
    else:
        results = responses.lookup_paginated(path, offset=offset, limit=limit)
    return jsonify(results)
Example #12
0
def query_standardize_uri():
    """
    Look up the URI for a given piece of text. 'text' and 'language' should be
    given as parameters.
    """
    language = flask.request.args.get('language')
    text = flask.request.args.get('text') or flask.request.args.get('term')
    if not language:
        return render_error(400, "Please specify a 'language' parameter.")
    if not text:
        return render_error(400, "Please specify a 'text' parameter.")
    return jsonify({
        '@context': responses.CONTEXT,
        '@id': standardized_concept_uri(language, text)
    })
Example #13
0
def query_standardize_uri():
    """
    Look up the URI for a given piece of text. 'text' and 'language' should be
    given as parameters.
    """
    language = flask.request.args.get('language')
    text = flask.request.args.get('text') or flask.request.args.get('term')
    if not language:
        return render_error(400, "Please specify a 'language' parameter.")
    if not text:
        return render_error(400, "Please specify a 'text' parameter.")
    return jsonify({
        '@context': responses.CONTEXT,
        '@id': standardized_concept_uri(language, text)
    })
Example #14
0
def query_relatedness():
    req_args = flask.request.args
    node1 = req_args.get('node1')
    node2 = req_args.get('node2')
    result = responses.query_relatedness(node1, node2)
    return jsonify(result)
Example #15
0
def query_relatedness():
    req_args = flask.request.args
    node1 = req_args.get('node1')
    node2 = req_args.get('node2')
    result = responses.query_relatedness(node1, node2)
    return jsonify(result)
Example #16
0
def render_error(status, details):
    return jsonify(error({}, status=status, details=details), status=status)
Example #17
0
def render_error(status, details):
    return jsonify(error({}, status=status, details=details), status=status)