1. Inline syntax
?? The rules demonstrate as follows, and the weights and the parties must specify specific parameters. Also, variables that use inline syntax must start with an uppercase letter.
model.add ( ' Dogs ') & Likes (B, ' Dogs ')) >> Friends (A, B), 5.0, True);
?? Because the inline syntax must be a subset of the groovy syntax, the following operator variants are not supported:
&&
||
-
<<
<-
!
?? Note that the variants are supported by all unsupported operators. Arithmetic rules are not supported for inline syntax.
2. String syntax
?? The rules are as follows:
model.add (rule:(Likes (A, ' Dogs ') & Likes (B, ' Dogs ') >> Friends (A, B) ", Weight:5.0, squared:true ); //rules that act in the same way as abovemodel.add (rule:"5.0: (Likes (A, ' Dogs ') && likes (b, ' Dogs ')), Friends (A, b) ^2" ); //the non-weighted (constrained) Form of the above rulemodel.add (rule:(Likes (A, ' Dogs ') && likes (b, ' Dogs ')), Friends (A, B) " ); //arithmetic constraints.model.add (rule:"Likes (A, +b) = 1." );
?? String syntax because the groovy syntax can not be respected, so all operators can be used, while specifying the weights and the peace side is also more flexible.
3. Bulk string syntax
?? The rules demonstrate the following:
Model.addrules ("" " 1: (Likes (A, ' Dogs ') & Likes (B, ' Dogs ')) >> Friends (A, B) ^2 +b) = 1
//model.addrules (new FileReader ("MyRules.txt"));
?? You can use the Addrules () method to add multiple rules at once, one row per rule, and each rule must define weights and squares.
4. Constraints
?? Constraints (constraints) are non-weighted arithmetic rules. Develop an arithmetic rule that explicitly specifies or does not specify whether it is not weighted (if a period is used at the end of the rule).
// Specify a non-weighted rule (constraint) with a period Model.add ( "likes (A, +b) = 1." // implicitly indicates that the Model.add rule is not weighted ( "likes (A, +b) = 1" );
Rule specification for probabilistic soft logic (psl,probabilistic soft logic) in groovy language