jwzimmer-zz / tv-tropes

UVM Stat 287 Final Project repo - network of tropes from TV Tropes wiki
MIT License
2 stars 3 forks source link

Make some networks showing indices, tropes, and tropes those tropes link to #22

Open jwzimmer-zz opened 3 years ago

jwzimmer-zz commented 3 years ago

For the "most important" categories of indices, potentially Narrative https://github.com/jwzimmer/tv-tropes/blob/981946c757caede5ac3a15205d5d53c751f0b116/Narrative-relatedIndicesCentral1000Tropes.gml

and the "main" indices from the website, topical, genre, media, and narrative

jwzimmer-zz commented 3 years ago

NarrativeTropes, GenreTropes, MediaTropes, TopicalTropes, looking at up to 50 of the top 10000 most central tropes (by all 4 measures) in the index-trope links and in the trope-trope links: bigfour_all4central_top50_top50

jwzimmer-zz commented 3 years ago

BigFour_tropes_all4_top10000_top50_top20_theirtropes The Big Four indices as nodes, plus up to the top 50 tropes they link to as links, plus up to the top 20 tropes those tropes link to as nodes, plus edges between those tropes and any other nodes already in the graph

bigfourindextheirtropestheirtropesttheiredges
jwzimmer-zz commented 3 years ago

https://github.com/jwzimmer/tv-tropes/commit/22c89f5b9df217837d251a4ba3ed405b3e0130fd bigfourhairball3

using:

self.masterlist = self.get_json('index-list/index-list.json')
        self.indices = [x for x in self.masterlist.keys()]
        #truncated list for testing things quickly or on a subset of indices
        self.masterlist = {self.indices[i]:self.masterlist[self.indices[i]] for i in range(len(self.masterlist)) if self.indices[i] in ("MediaTropes","NarrativeTropes","TopicalTropes","GenreTropes")}
        self.centraltropes = self.get_most_central_tropes_by_all_4_metrics("top_10000_central.json")
        self.masterlisttropes = self.get_json('all-tropes-with-links.json')
        self.supercat = "BigFour_tropes_all4_top10000_top50_edges_noaddednode"

And edges between:

 def add_trope_nodes(self):
        supercat = self.supercat
        #self.G.add_node(supercat,label=supercat)
        for index in self.masterlist: #add all linked tropes as nodes
            indexlinks = []
            for x in self.masterlist[index]:
                #if x not in indexlinks:
                if x in self.centraltropes:
                    indexlinks.append(x)
                if len(indexlinks) > 50:
                    break
            self.G.add_node(index,label=index)
            for y in indexlinks:
                if y in self.G.nodes:
                    self.G.add_edge(index,y)
            #self.G.add_edge(supercat,index)
            for trope in indexlinks:
                self.G.add_node(trope,label=trope)
                self.G.add_edge(index,trope)
                tropetropelinks = [x for x in self.masterlisttropes[trope] if x in self.centraltropes]
                for tr in tropetropelinks:
                    #self.G.add_node(tr,label=tr)
                    self.G.add_edge(trope, tr)
                    trlinks = self.masterlisttropes[tr]
                    for trl in trlinks:
                        if trl in self.G.nodes:
                            self.G.add_edge(tr, trl)
        self.write_gml(self.G, supercat)
        return None
jwzimmer-zz commented 3 years ago

https://github.com/jwzimmer/tv-tropes/commit/a66d9f3c1a94d5df60dbfde3ab58684a2e0d938b Showing edges between tropes for the big four indices when a trope that index links to, links to another trope one of the indices links to.

jwzimmer-zz commented 3 years ago

https://github.com/jwzimmer/tv-tropes/commit/833e6873512489edf67b41c98a2d6523f987d163 bigfour_alltropes bigfour_alltropes

big four indices, showing all tropes they link directly to, and edges whenever those tropes link to each other