Made analytics more sensitive to text lengths in the scenes.
It was jumping a little bit back every time I added a new shot. And it always offsetting my daily percentage since it is much more sensitive to smallest changes. I hope this fixes it.
This commit is contained in:
parent
a220c5c16f
commit
06afb118d7
1 changed files with 34 additions and 6 deletions
|
@ -675,7 +675,9 @@ def load(project):
|
|||
for scenename in data["scenes"]:
|
||||
|
||||
shotsfractions = []
|
||||
shotslengths = []
|
||||
textlength = 0
|
||||
prevtextpos = 0
|
||||
for shot in data["scenes"][scenename]["shots"]:
|
||||
for t in shot[-1]:
|
||||
textlength = textlength + len(t[-1])
|
||||
|
@ -713,6 +715,34 @@ def load(project):
|
|||
except:
|
||||
shotsfractions.append(0.0)
|
||||
|
||||
shotslengths.append( textlength - prevtextpos )
|
||||
prevtextpos = textlength
|
||||
|
||||
# Adjusting fractions based on the length of the text marked.
|
||||
|
||||
lastlen = 0
|
||||
for t in data["scenes"][scenename]["shots"][-1][-1]:
|
||||
lastlen = lastlen + len(t[-1])
|
||||
|
||||
|
||||
try:
|
||||
avgtxtlng = sum(shotslengths) / len(shotslengths)
|
||||
except:
|
||||
avgtxtlng = 1
|
||||
|
||||
avgtxtlng = min(1, avgtxtlng)
|
||||
|
||||
sf = []
|
||||
for n, i in enumerate(shotsfractions):
|
||||
try:
|
||||
l = shotslengths[n]
|
||||
except:
|
||||
l = 0
|
||||
|
||||
|
||||
nf = l / (textlength - lastlen) * i
|
||||
|
||||
sf.append(nf)
|
||||
|
||||
# If the last block isn't shot_block. It's safe to assume that
|
||||
# not all of the shots are yet marked in the text. Therefor we
|
||||
|
@ -720,9 +750,7 @@ def load(project):
|
|||
|
||||
multiply_by = 1
|
||||
if not data["scenes"][scenename].get("no_more_shots") and data["scenes"][scenename]["shots"][-1][0] == "text_block":
|
||||
lastlen = 0
|
||||
for t in data["scenes"][scenename]["shots"][-1][-1]:
|
||||
lastlen = lastlen + len(t[-1])
|
||||
|
||||
try:
|
||||
multiply_by = (textlength - lastlen) / textlength
|
||||
except:
|
||||
|
@ -731,7 +759,7 @@ def load(project):
|
|||
|
||||
try:
|
||||
data["scenes"][scenename]["fraction"] = \
|
||||
( sum(shotsfractions) / len(shotsfractions) ) * multiply_by
|
||||
( sum(sf) ) * multiply_by
|
||||
except:
|
||||
data["scenes"][scenename]["fraction"] = 0.0
|
||||
|
||||
|
|
Loading…
Reference in a new issue