louismullie / treat

Natural language processing framework for Ruby.
Other
1.37k stars 128 forks source link

Added value checking & recursion to num_children_with_feature #20

Closed robadler closed 12 years ago

robadler commented 12 years ago

New def => def num_children_with_feature(feature, recursive = false, value = nil)

1.9.3p194 :011 > p.num_children_with_feature(:tag) => 0 # No recursion 1.9.3p194 :012 > p.num_children_with_feature(:tag,true) => 50 # Recursion 1.9.3p194 :013 > p.num_children_with_feature(:tag,true,"NP") => 10 # Recursion & value checking.

Didn't change the order for feature & defaulted recursion to false so old code running it will still work in the same way.

louismullie commented 12 years ago

I'm going to merge this, but I'm also thinking of making recursion the default behaviour in this case, as I don't see any use case for a non-recursive method. What do you think?

robadler commented 12 years ago

I'm perfectly fine with it. Normally I'd use it in the case of going down a level at a time myself and then recursion would always work in that case, so I'm fine with it. :)

louismullie commented 12 years ago

Excellent. Then I'm going to make the API as follows: num_children_with_feature(feature, value = nil, recursive = true).