예제 #1
0
def author_clusters(algorithm, limit, keyword=""):
	
	query = None
	if (keyword == ""):
		query = "MATCH (a1:Author)-[:Wrote]-(p:Paper)-[:Wrote]-(a2:Author) RETURN a1.name AS source, a2.name AS target LIMIT %d" % (limit)
	else:
		query = "MATCH (a1:Author)-[:Wrote]-(p:Paper)-[:Wrote]-(a2:Author) WHERE '%s' IN a1.keyterms AND '%s' IN a2.keyterms RETURN a1.name AS source, a2.name AS target LIMIT %d" % (keyword, keyword, limit)
	
	print query	
	data = neo4j.cypher.execute(query)
	graph_json = scholarly.compute_community_cluster(data, "title", algorithm)

	return json.dumps(graph_json)
예제 #2
0
def paper_clusters_cluster_info(algorithm, limit, clusterId):
	query = "MATCH (p1:Paper)-[r:References]->(p2:Paper) RETURN p1.title, p2.title LIMIT %d" % (limit)
	
	data = neo4j.cypher.execute(query)
	graph_dict = scholarly.compute_community_cluster(data, "title", algorithm)

	papers_in_cluster = []
	for n in graph_dict["nodes"]:
		if (n["cluster"] == clusterId):
			papers_in_cluster.append({"title" : n["title"], 
			"url" : "http://dblp.uni-trier.de/search/publ?q=" + urllib.quote(n["title"])})

	return render_template("cluster_info.html", data=papers_in_cluster);
예제 #3
0
def paper_clusters(algorithm, limit, keyword=""):

        query = None
        if (keyword == ""):
                query = "MATCH (p1:Paper)-[r:References]->(p2:Paper) RETURN p1.title, p2.title LIMIT %d" % (limit)
        else:
                query = "MATCH (p1:Paper)-[r:References]->(p2:Paper) WHERE p1.title CONTAINS '%s' OR p2.title CONTAINS '%s' RETURN p1.title, p2.title LIMIT %d" % (keyword, keyword, limit)

        print query
        data = neo4j.cypher.execute(query)
        graph_json = scholarly.compute_community_cluster(data, "title", algorithm)

        return json.dumps(graph_json)