Wiki source code of Duncan Result

Version 15.4 by Alexandru Colesnicov on 2018/11/05 18:32

Show last authors
1 {{velocity}}
2
3 #set($class="Duncan1.Code.GDataClass")
4 #set($template="Duncan1.Code.GDataTemplate")
5 #set($xwlquery="from doc.object($class) as obj where doc.fullName <> '$template' order by doc.date desc")
6 #set($list=$services.query.xwql($xwlquery).execute())
7
8 {{/velocity}}
9
10 {{python}}
11
12 import sys
13 print "Python version is ", sys.version
14 print
15
16 totalF=0
17 totalM=0
18 nPos=list.size()
19 for item in list:
20 itemdoc = xwiki.getDocument(item)
21 nFInPos = itemdoc.getValue('QuaWoman')
22 nMInPos = itemdoc.getValue('QuaMan')
23 totalF += nFInPos
24 totalM += nMInPos
25 totalFM = totalF+totalM
26 print "%s records processed\n%s pers. incl. woman: %s; man: %s" % (nPos, totalFM, totalF, totalM)
27
28 iDunc = 0.0
29 for item in list:
30 itemdoc = xwiki.getDocument(item)
31 nFInPos = itemdoc.getValue("QuaWoman")
32 nMInPos = itemdoc.getValue("QuaMan")
33 iDunc += abs(nFInPos/float(totalF) - nMInPos/float(totalM))
34 iDunc *= 0.5
35 print "Duncan index = %s" % (iDunc)
36 {{/python}}