-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcompute_community_pattern.py
More file actions
87 lines (78 loc) · 2.7 KB
/
Copy pathcompute_community_pattern.py
File metadata and controls
87 lines (78 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from community import community
from math import sqrt
# The thresholds that will be used to compute the patterns for each community.
# TODO
th_avg_geo_distance = 4000 # Kilometers
th_avg_cult_distance = 15 # %
th_formality_lvl_low = 0.1
th_formality_lvl_high = 20
th_engagement_lvl = 3.5
th_longevity = 93 # Days
def compute_community_patterns(metrics):
(
structure,
dispersion,
formality,
longevity,
engagement,
) = compute_characteristics_from_metrics(metrics)
community_patterns = {
"SN": False,
"NoP": False,
"IN": False,
"FN": False,
"CoP": False,
"PT": False,
"FG": False,
"IC": False,
}
# Community exhibits structure
if structure:
community_patterns["SN"] = True
# Dispersed
if dispersion:
community_patterns["NoP"] = True
# Informal
if formality <= th_formality_lvl_low:
community_patterns["IN"] = True
# Formal
elif formality >= th_formality_lvl_high:
community_patterns["FN"] = True
# Not dispersed
else:
community_patterns["CoP"] = True
# cohesion not detected
# Low durability / short-lived
if longevity < th_longevity:
community_patterns["PT"] = True
# Not informal but also not formal
if formality >= th_formality_lvl_low and formality <= th_formality_lvl_high:
community_patterns["FG"] = True
# Engaged
if engagement > th_engagement_lvl:
community_patterns["IC"] = True
return (structure, dispersion, formality, longevity, engagement, community_patterns)
def compute_characteristics_from_metrics(metrics):
structure = (
metrics.structure["repo_connections"]
or metrics.structure["follow_connections"]
or metrics.structure["pr_connections"]
)
dispersion = (
metrics.dispersion["avg_geo_distance"] > th_avg_geo_distance
and metrics.dispersion["cultural_distance_variance"] > th_avg_cult_distance
)
engagement = (
metrics.engagement["m_comment_per_pr"]
+ metrics.engagement["mm_comment_dist"]
+ metrics.engagement["m_watchers"]
+ metrics.engagement["m_stargazers"]
+ metrics.engagement["m_active"]
+ metrics.engagement["mm_commit_dist"]
+ metrics.engagement["mm_filecollab_dist"]
)
formality = metrics.formality["m_membership_type"] / (
metrics.formality["milestones"] / metrics.formality["lifetime"]
)
longevity = metrics.longevity
return structure, dispersion, formality, longevity, engagement