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"]:
|
for scenename in data["scenes"]:
|
||||||
|
|
||||||
shotsfractions = []
|
shotsfractions = []
|
||||||
|
shotslengths = []
|
||||||
textlength = 0
|
textlength = 0
|
||||||
|
prevtextpos = 0
|
||||||
for shot in data["scenes"][scenename]["shots"]:
|
for shot in data["scenes"][scenename]["shots"]:
|
||||||
for t in shot[-1]:
|
for t in shot[-1]:
|
||||||
textlength = textlength + len(t[-1])
|
textlength = textlength + len(t[-1])
|
||||||
|
@ -711,18 +713,44 @@ def load(project):
|
||||||
elif len(os.listdir(folder+"/extra")) > 0:
|
elif len(os.listdir(folder+"/extra")) > 0:
|
||||||
shotsfractions.append(0.2)
|
shotsfractions.append(0.2)
|
||||||
except:
|
except:
|
||||||
shotsfractions.append(0.0)
|
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
|
# 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
|
# not all of the shots are yet marked in the text. Therefor we
|
||||||
# want to estimate how much is marked.
|
# want to estimate how much is marked.
|
||||||
|
|
||||||
multiply_by = 1
|
multiply_by = 1
|
||||||
if not data["scenes"][scenename].get("no_more_shots") and data["scenes"][scenename]["shots"][-1][0] == "text_block":
|
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:
|
try:
|
||||||
multiply_by = (textlength - lastlen) / textlength
|
multiply_by = (textlength - lastlen) / textlength
|
||||||
except:
|
except:
|
||||||
|
@ -731,7 +759,7 @@ def load(project):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data["scenes"][scenename]["fraction"] = \
|
data["scenes"][scenename]["fraction"] = \
|
||||||
( sum(shotsfractions) / len(shotsfractions) ) * multiply_by
|
( sum(sf) ) * multiply_by
|
||||||
except:
|
except:
|
||||||
data["scenes"][scenename]["fraction"] = 0.0
|
data["scenes"][scenename]["fraction"] = 0.0
|
||||||
|
|
||||||
|
@ -757,7 +785,7 @@ def load(project):
|
||||||
|
|
||||||
# FINAL STUFF...
|
# FINAL STUFF...
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data["fraction"] = sum(fractions) / len(fractions)
|
data["fraction"] = sum(fractions) / len(fractions)
|
||||||
except:
|
except:
|
||||||
data["fraction"] = 0.0
|
data["fraction"] = 0.0
|
||||||
|
|
Loading…
Reference in a new issue