commit - 477604c918eaff5487cf8b2e4d9312d587e4742f
commit + 5be2eec1d0eeed73a2c4bb881abb1bc58eaa16da
blob - 2a3e3d1429770fb688fa3bc26cbf5353f5561b0e
blob + da163c21f3dd012a454478bcf736b7f3739b0513
--- painlist
+++ painlist
# use 1,3,5,7,9 for a 5-level scale. it is recommended to document a clear
# meaning for each level to make rating easy and unambiguous.
#
-# an item's pain value is the geometric mean of its ratings.
+# the value of a pain tag (">...<") is the geometric mean of the ratings.
+# an item can have multiple pain tags which are summed.
#
# the output sorts items by pain value. a solid line visualizes a configurable
# threshold (default -t 6). a dotted line shows the weighted median (half of
}
function score(s) {
- if(match(s, />[1-9](x[1-9])*</)) {
+ sum = 0
+ while(match(s, />[1-9](x[1-9])*</)) {
rating = substr(s, RSTART+1, RLENGTH-2)
- split(rating, xs, /x/)
+ s = substr(s, RSTART+RLENGTH)
- return product(xs) ^ (1 / length(xs))
+ split(rating, xs, /x/)
+ sum += product(xs) ^ (1 / length(xs))
}
- return 0
+ return sum
}
function printit() {