Commit a368d082 authored by Ian Dennis Miller's avatar Ian Dennis Miller

summary counts objects

parent 1caf97ad
Pipeline #263 passed with stage
in 14 seconds
......@@ -227,3 +227,24 @@ def community_tags():
"""
return jsonify(snapshot.transformation.produce_tags())
@app.route('/summary.json')
def summary():
"""Endpoint returning summary of graph
---
definitions:
Descriptions:
type: array
items:
type: string
responses:
200:
description: Account description
schema:
$ref: '#/definitions/Descriptions'
examples:
['This is an account description', 'This is an account description']
"""
return jsonify(snapshot.query.summary())
......@@ -56,3 +56,38 @@ class Query:
sparql = self.env.get_template('all_followers.sparql').render()
results = self.snapshot.g.query(sparql)
return([edge for edge in results])
def summary(self):
# number of accounts
sparql = self.env.get_template('num_accounts.sparql').render()
results = self.snapshot.g.query(sparql)
num_accounts = int(next(iter(results))[0])
# number of statuses
sparql = self.env.get_template('num_statuses.sparql').render()
results = self.snapshot.g.query(sparql)
num_statuses = int(next(iter(results))[0])
# number of follows
sparql = self.env.get_template('num_social_network_follows.sparql').render()
results = self.snapshot.g.query(sparql)
num_follows = int(next(iter(results))[0])
# number of leads
sparql = self.env.get_template('num_social_network_leads.sparql').render()
results = self.snapshot.g.query(sparql)
num_leads = int(next(iter(results))[0])
# number of favorites
sparql = self.env.get_template('num_favorites.sparql').render()
results = self.snapshot.g.query(sparql)
num_favorites = int(next(iter(results))[0])
return({
'num_accounts': num_accounts,
'num_statuses': num_statuses,
'num_follows': num_follows,
'num_favorites': num_favorites,
'num_leads': num_leads,
'num_edges': num_leads + num_follows,
})
PREFIX twitter: <http://saver.sisrlab.com/twitter-save#>
SELECT (count(?x) AS ?count)
WHERE {
?x rdf:type twitter:account .
}
PREFIX twitter: <http://saver.sisrlab.com/twitter-save#>
SELECT (count(?y) AS ?count)
WHERE {
?x rdf:type twitter:account .
?x twitter:favorited ?y .
}
PREFIX twitter: <http://saver.sisrlab.com/twitter-save#>
SELECT (count(?y) AS ?count)
WHERE {
?x rdf:type twitter:account .
?x twitter:follows ?y .
}
PREFIX twitter: <http://saver.sisrlab.com/twitter-save#>
SELECT (count(?y) AS ?count)
WHERE {
?x rdf:type twitter:account .
?x twitter:leads ?y .
}
PREFIX twitter: <http://saver.sisrlab.com/twitter-save#>
SELECT (count(?x) AS ?count)
WHERE {
?x rdf:type twitter:status .
}
......@@ -120,7 +120,7 @@ def find_tags(community_phrases):
measure = bigram_measures.likelihood_ratio
tag_pairs = finder.nbest(measure, 15)
result[idx] = tag_pairs
result[idx] = [" ".join(pair) for pair in tag_pairs]
return(result)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment