-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrandLocuteur.py
175 lines (136 loc) · 4.32 KB
/
grandLocuteur.py
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 24 08:37:35 2020
@author: Lenovo T420s
"""
import buildSenten as build
import matplotlib.pyplot as plt
import numpy as np
def preparationTimeSpeak(totalSpeachGr):
def traitment1(a):
return (a[0],a[1], a[2],)
return list(map(traitment1,totalSpeachGr ))
def pretraitementOne(subMeetings,meeting = "" ):
res = { }
for sm in subMeetings:
try:
if meeting == "":
orgSpeachT = build.organisedSpeachTotalPipe(sm)
else:
orgSpeachT = build.organisedSpeachTotalPipe(sm, meeting)
res[meeting + sm] = { }
res[meeting + sm]["timeSent"] = preparationTimeSpeak(orgSpeachT)
except OSError:
print("erreur lors du chargement de " +meeting+ " " + sm )
except TypeError:
print("erreur lors du chargement de " +meeting+ " " + sm )
return res
def pretraitement(meetings):
c = { }
for m in meetings:
c.update(pretraitementOne(m[1],m[0]))
return c
def ISMeeting():
ism = "IS100"
number = 10
part = ["a","b","c","d"]
res = []
for i in range (0, number):
res.append((ism + str(i), part))
return res
def tSMeeting():
tsm = "TS300"
tsm10 = "TS30"
number = 13
part = ["a","b","c","d"]
res = []
for i in range (3, number):
if i < 10:
res.append((tsm + str(i), part))
else:
res.append((tsm10 + str(i), part))
return res
"""ajout du temps par personne"""
def timeBySpeaker(TSMeeting):
res = { }
for t in TSMeeting:
res[t[0]] = res.get(t[0], 0) + t[2] - t[1]
return res
def AddTimeBySpeaker(corpus):
for k in corpus.keys():
corpus[k]["timeSpk"]= timeBySpeaker(corpus[k]["timeSent"])
def bestSpk(TSpkMeeting):
first = True
tot = 0
for k,v in TSpkMeeting.items():
tot += v
if first :
res= (k,v)
first = False
elif v > res[1]:
res = (k,v)
if not first:
return (res[0], res[1],res[1] / tot)
else: return (None,0,0)
def AddBestSpeaker(corpus):
for k in corpus.keys():
corpus[k]["BestSpk"]= bestSpk(corpus[k]["timeSpk"])
def bestSpkRepartition(corpus, TimeProportionlength):
res = { }
for v in corpus.values():
n = int (v["BestSpk"][2] / TimeProportionlength)
res[n * TimeProportionlength] = res.get(n * TimeProportionlength,0) + 1
return sorted(res.items())
def affichageSPKRep(result):
plt.plot(np.array(result[0]) , np.array(result[1]), label='repartition')
plt.xlabel('proportionSpeak')
plt.xlabel('number')
plt.title("Repartition de la proportionde parole du plus grand parleur au sein des réunions ")
plt.legend()
plt.show()
def AddRole(corpus,timeprop,ecart,sc1,sc2):
for v in corpus.values():
if v["BestSpk"][2] > timeprop:
b = bestBySection(v,ecart)
score = countSection(v["BestSpk"][0],b)
if score > sc2 :
v["BestSpk"].append("coordinator")
elif score >sc1:
v["BestSpk"].append("presenter")
def timeBySpeakerSection(TSMeeting,beg,en):
res = { }
for t in TSMeeting:
if t[1]<beg and t[1]> en:
res[t[0]] = res.get(t[0], 0) + t[2] - t[1]
return res
def bestBySection(meeting, ecart):
r = []
for i in range(0,2700, ecart):
tmp = bestSpk(timeBySpeakerSection(meeting["timeSent"],i,i + ecart))
if tmp[0] != None:
r.append(tmp[0])
return r
def countSection(spkB,secspkB):
if len(secspkB) == 0 :
return 0
return secspkB.count(spkB) / len(secspkB)
i = pretraitement(ISMeeting())
AddTimeBySpeaker(i)
AddBestSpeaker(i)
t = pretraitement(tSMeeting())
AddTimeBySpeaker(t)
AddBestSpeaker(t)
tot = []
tot.extend( ISMeeting())
tot.extend( tSMeeting())
c = pretraitement(tot)
AddTimeBySpeaker(c)
AddBestSpeaker(c)
AddRole(c, 0.33, 5*60, 0.1, 0.5)
print(c)
ib = bestSpkRepartition(i,0.15)
print(ib)
tb = bestSpkRepartition(t,0.15)
print(tb)
totb = bestSpkRepartition(c,0.15)
print(totb)