|
| 1 | +import json |
| 2 | + |
| 3 | +f = open('./dbseed/risks.json') |
| 4 | + |
| 5 | +data = json.load(f) |
| 6 | + |
| 7 | +hasSimilarNodes = 0 |
| 8 | +numberSimilarNodes = 0 |
| 9 | + |
| 10 | +hasRisk = 0 |
| 11 | +totalRisk = 0 |
| 12 | +maxRisk = 0 |
| 13 | + |
| 14 | +totalBreached = [] |
| 15 | +totalBreaches = 0 |
| 16 | + |
| 17 | +seenCluster = [] |
| 18 | +validArticleRank = 0 |
| 19 | +validBetweenness = 0 |
| 20 | +validDegree = 0 |
| 21 | +validHarmonicCloseness = 0 |
| 22 | + |
| 23 | +for d in data: |
| 24 | + if "similarNodes" in d and len(d["similarNodes"]) > 0: |
| 25 | + hasSimilarNodes += 1 |
| 26 | + numberSimilarNodes += len(d["similarNodes"]) |
| 27 | + else: |
| 28 | + print(d) |
| 29 | + if "riskScore" in d: |
| 30 | + hasRisk += 1 |
| 31 | + totalRisk += d["riskScore"] |
| 32 | + if d["riskScore"] > maxRisk: |
| 33 | + maxRisk = d["riskScore"] |
| 34 | + if "similarBreachedDomains" in d: |
| 35 | + for breached in d["similarBreachedDomains"]: |
| 36 | + if breached["domain"] not in totalBreached: |
| 37 | + totalBreached.append(breached["domain"]) |
| 38 | + totalBreaches += breached["breaches"] |
| 39 | + if "validMeasuresInCluster" in d: |
| 40 | + for c in d["validMeasuresInCluster"]: |
| 41 | + if c["cluster"] not in seenCluster: |
| 42 | + seenCluster.append(c["cluster"]) |
| 43 | + if c["articleRank"]: |
| 44 | + validArticleRank += 1 |
| 45 | + if c["betweenness"]: |
| 46 | + validBetweenness += 1 |
| 47 | + if c["degree"]: |
| 48 | + validDegree += 1 |
| 49 | + if c["harmonicCloseness"]: |
| 50 | + validHarmonicCloseness += 1 |
| 51 | + |
| 52 | +print(len(data)) |
| 53 | + |
| 54 | +print("Has similar nodes: ", hasSimilarNodes) |
| 55 | +print("Average amount of similar nodes: ", numberSimilarNodes/hasSimilarNodes) |
| 56 | + |
| 57 | +print("Has risk: ", hasRisk) |
| 58 | +print("Average risk: ", totalRisk/hasRisk) |
| 59 | +print("maxRisk: ", maxRisk) |
| 60 | + |
| 61 | +print("Total breached: ", len(totalBreached)) |
| 62 | +print("Total breaches: ", totalBreaches) |
| 63 | + |
| 64 | +print("Number of cluster: ", len(seenCluster)) |
| 65 | +print("Number of valid ArticleRanks: ", validArticleRank) |
| 66 | +print("Number of valid Betweenness: ", validBetweenness) |
| 67 | +print("Number of valid Degree: ", validDegree) |
| 68 | +print("Number of valid Harmonic Closeness: ", validHarmonicCloseness) |
0 commit comments