def see_documentation(): """ This function redirects to the api documentation """ return jsonify({ '@context': responses.CONTEXT })
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)
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))
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.' })
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)
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)
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) })
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)
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)
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) })
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)
def render_error(status, details): return jsonify(error({}, status=status, details=details), status=status)