Thanks for the great work so far on this, I'm having a blast trying it out. One thing I'd love to see is a way to express that one of a group of steps is required, rather than just a list of optional steps.
For instance, I have this working rule:
(def rules [{:id :statement
:optional-steps []
:rule [:actor
#{:get-value
#{"NN"} #{"NNP"} ;; singular, singular proper
#{"NNS"} #{"NNPS"}} ;; plural, plural proper
:verb
#{:get-value #{"VBD"}}
:object
#{:get-value
#{"NN"} #{"NNP"}
#{"NNS"} #{"NNPS"}}
#{#{"."}}
]}])
"bob experienced enlightenment." => {:errors nil, :result {:rule :statement, :data {:actor ["bob"], :verb ["experienced"], :object ["enlightenment"]}}}
"people experienced enlightenment." => {:errors nil, :result {:rule :statement, :data {:actor ["people"], :verb ["experienced"], :object ["enlightenment"]}}}
note that some of the POS tags are different than the postagga defaults, I'm plugging in the Stanford NLP lib for tagging
This rule finds simple statements of actor - verb - object, where the actor and object can both be singular or plural. But it isn't possible to disambiguate between singular and plural in the result map, meaning that if I want to look specifically for singular or plural actors or objects, I need to either make both optional (which could result in a false hit with no actor/object), or branch and write more rules to cover all cases (singular actor - verb - singular object, plural actor - verb - singular object etc...) which would get pretty huge.
It would be great if I could specify something like an OR condition, either in the optional steps vector or the body of the rule, for example:
(def desired-rules
[{:id :statement
:optional-steps [;; grouping of two or more steps to indicate
;; that one of them is required
[:actor-singular
:actor-plural]
]
:rule [:actor-singular
#{:multi :get-value
#{"NN"} #{"NNP"}} ;; singular, singular proper
:actor-plural
#{:multi :get-value
#{"NNS"} #{"NNPS"}} ;; plural, plural proper
:verb
#{:get-value #{"VBD"}}
:object
#{:get-value
#{"NN"} #{"NNP"}
#{"NNS"} #{"NNPS"}}
#{#{"."}}
]}])
"bob experienced enlightenment." => {:errors nil, :result {:rule :statement, :data {:actor-singular ["bob"], :verb ["experienced"], :object ["enlightenment"]}}}
"people experienced enlightenment." => {:errors nil, :result {:rule :statement, :data {:actor-plural ["people"], :verb ["experienced"], :object ["enlightenment"]}}}
Would something like this make sense to add? Is there some other property of the rule syntax that can achieve this already? Happy to contribute to make it happen.