mirror of
https://gitlab.com/Oreolek/improv_forest.git
synced 2024-06-17 07:30:56 +03:00
Probability math - done right
This commit is contained in:
parent
1d1ae715b5
commit
2c4846bc15
|
@ -20,6 +20,7 @@ template = (phrase) ->
|
|||
|
||||
parseGroup = (group) ->
|
||||
groups = []
|
||||
occurence = {}
|
||||
for phrase in group.phrases
|
||||
nexttpl = null
|
||||
templates = []
|
||||
|
@ -34,8 +35,11 @@ parseGroup = (group) ->
|
|||
if groups.indexOf(grp) == -1
|
||||
groups.push grp
|
||||
if directive == ':'
|
||||
distribution[grp] ?= 0
|
||||
distribution[grp] += 1
|
||||
occurence[grp] ?= 0
|
||||
occurence[grp] += 1
|
||||
for filename, value of occurence
|
||||
distribution[filename] ?= 1
|
||||
distribution[filename] *= value/group.phrases.length
|
||||
for filename in groups
|
||||
if spec[filename]?
|
||||
for groupdata in spec[filename].groups
|
||||
|
@ -60,4 +64,6 @@ for file in files
|
|||
for group in spec.description.groups
|
||||
parseGroup(group)
|
||||
|
||||
for filename, value of distribution
|
||||
distribution[filename] = Math.round(value * 1000) / 1000
|
||||
console.log distribution
|
||||
|
|
Loading…
Reference in a new issue