Exemplo n.º 1
0
t.show("merge collab", Tcollab_merge)

# If (u,v) worked on the same pull request on the same repository, they are added
# as (soft) collaborators.
Tpull_merge = ringo.SelfJoin(Tpull, "owner")
ringo.Select(Tpull_merge, "3_1.name = 3_2.name", True)
ringo.Select(Tpull_merge, "3_1.pullid = 3_2.pullid", True)
ringo.ColMin(Tpull_merge, "3_1.created_at", "3_2.created_at", "created_at")
ringo.Project(Tpull_merge, ("3_1.userid", "3_2.userid", "created_at"))
ringo.Rename(Tpull_merge, "3_1.userid", "userid1")
ringo.Rename(Tpull_merge, "3_2.userid", "userid2")
t.show("merge pull", Tpull_merge)

Tmerge = ringo.UnionAll(Tcollab_merge, Tpull_merge, "collab")
# Remove self-loops from the table.
ringo.Select(Tmerge, "userid1 != userid2")

# Select the base and delta tables from the merged table.
Tbase = ringo.Select(Tmerge, "created_at >= 10", False, True)

#TODO: Iterate over the rows and add (userid, owner) edge
t.show("collab union")

# Convert base table to base graph
Gbase = ringo.ToGraph(Tbase, "userid1", "userid2")
t.show("base graph", Gbase)

TPageRank = ringo.PageRank(Gbase)
TPageRank = ringo.Order(TPageRank, PAGE_RANK_ATTRIBUTE)
ringo.DumpTableContent(TPageRank)
# Graph
graph = ringo.ToGraph(t4, "1_2.1.UserId", "1.UserId")
t.show("graph", graph)
ringo.ShowMetadata(graph)

# Get authority scores
(HTHub, HTAuth) = ringo.GetHits(graph)
t.show("hits", graph)
ringo.ShowMetadata(HTAuth)

t5 = ringo.TableFromHashMap(HTAuth, "UserId", "Authority")
t.show("authority score", t5)

# Select top entries
#ringo.Select(t5, 'Authority > 0.0', CompConstant = True)
#t.show("select", t5)

# Order by final score (in descending order)
ringo.Order(t5, ['Authority'], Asc=False)
t.show("order", t5)

# Save
if not dstdir is None:
    ringo.SaveTableTSV(t5, os.path.join(dstdir, OUTPUT_TABLE_FILENAME))
    t.show("save", t5)

ringo.DumpTableContent(t5, 20)
ringo.ShowMetadata(t5)
ringo.GenerateProvenance(t5, '06-StackOverflow-simple-autogen.py')