algorithm - How would you express this in Haskell? -


would use if/else write algorithm in haskell? there way express without them? it's hard extract functions out of middle have meaning. output of machine learning system.

i'm implementing algorithm classifying segments of html content content or boilerplate described here. has weights hard coded.

curr_linkdensity <= 0.333333 | prev_linkdensity <= 0.555556 | | curr_numwords <= 16 | | | next_numwords <= 15 | | | | prev_numwords <= 4: boilerplate | | | | prev_numwords > 4: content | | | next_numwords > 15: content | | curr_numwords > 16: content | prev_linkdensity > 0.555556 | | curr_numwords <= 40 | | | next_numwords <= 17: boilerplate | | | next_numwords > 17: content | | curr_numwords > 40: content curr_linkdensity > 0.333333: boilerplate 

since there 3 paths in decision tree leads boilerplate state, i'd iterate , simplify them:

isboilerplate =   prev_linkdensity   <= 0.555556 && curr_numwords <= 16 && prev_numwords <= 4   || prev_linkdensity > 0.555556 && curr_numwords <= 40 && next_numwords <= 17   || curr_linkdensity > 0.333333 

Comments