Rule specification for probabilistic soft logic (psl,probabilistic soft logic) in groovy language

Source: Internet
Author: User
Tags arithmetic uppercase letter

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.