sofie.maxsat
Class Rule

java.lang.Object
  extended by sofie.maxsat.Rule

public class Rule
extends java.lang.Object

Class Rule This class is part of the SOFIE system (http://mpii.de/yago-naga/sofie). It is licensed under the Creative Commons Attribution-Noncommercial-Share-Alike 3.0 Unported License (http://creativecommons.org/licenses/by-nc-sa/3.0/) by Fabian M. Suchanek (http://suchanek.name). If you use this class for scientific purposes, please cite Fabian M. Suchanek, Mauro Sozio, Gerhard Weikum "SOFIE: A Self-Organizing Framework for Information Extraction" (International World Wide Web Conference 2009) This class represents a rule, i.e. a disjunction of literals.


Field Summary
protected static int allIds
          Counts all existing rules
protected  java.lang.String description
          Holds a description
protected  int id
          Holds the id of the current rule
protected  java.util.List<Literal> literals
          Holds the literals
protected  int numFreeLiterals
          Holds the number of free literals
protected  java.util.List<Literal>[] resolveOrder
          Given the index of one literal, lists the literals to be instantiated next
protected  double weight
          Holds the weight of this rule
 
Constructor Summary
Rule(java.lang.String description, double weight, java.util.List<Literal> literals)
          Constructs a rule
Rule(java.lang.String description, double weight, Literal... literals)
          Constructs a rule
 
Method Summary
 boolean equals(java.lang.Object obj)
           
protected  void ground(java.util.List<Literal> literalsToDo, int numUnsatisfied, double weight, java.util.Map<java.lang.String,java.lang.String> bindings, Literal freeLiteral, Measures measures, java.util.List<Hypothesis> grounded)
          Helper for groundedrules(), fills a list of grounded rules
 int hashCode()
           
 int indexOf(Literal lit)
          Returns the index of the literal (for some instantiuation of the variables)
 Literal literal(int i)
          Returns the ith literal
static java.util.List<Rule> loadFrom(java.io.File file)
          Returns the rules defined in that file
static void main(java.lang.String[] args)
          Test
 int numLiterals()
           
static Rule parse(java.lang.String line, java.lang.String description)
          Parses a line into a rule.
protected static Literal resolveNext(java.util.List<Literal> toDo, java.util.Set<java.lang.String> knownVariables)
          Returns the Literal from the list that has to be instantiated next, given a set of known variables
 java.lang.String toString()
           
 void updateMeasures(Hypothesis hyp, Measures measures)
          Adds the measures of unsatisfied rules
 double weight()
          returns the rule weight
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

allIds

protected static int allIds
Counts all existing rules


id

protected int id
Holds the id of the current rule


description

protected java.lang.String description
Holds a description


literals

protected java.util.List<Literal> literals
Holds the literals


numFreeLiterals

protected int numFreeLiterals
Holds the number of free literals


weight

protected double weight
Holds the weight of this rule


resolveOrder

protected java.util.List<Literal>[] resolveOrder
Given the index of one literal, lists the literals to be instantiated next

Constructor Detail

Rule

public Rule(java.lang.String description,
            double weight,
            Literal... literals)
Constructs a rule


Rule

public Rule(java.lang.String description,
            double weight,
            java.util.List<Literal> literals)
Constructs a rule

Method Detail

literal

public Literal literal(int i)
Returns the ith literal


resolveNext

protected static Literal resolveNext(java.util.List<Literal> toDo,
                                     java.util.Set<java.lang.String> knownVariables)
Returns the Literal from the list that has to be instantiated next, given a set of known variables


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

numLiterals

public int numLiterals()

indexOf

public int indexOf(Literal lit)
Returns the index of the literal (for some instantiuation of the variables)


weight

public double weight()
returns the rule weight


parse

public static Rule parse(java.lang.String line,
                         java.lang.String description)
Parses a line into a rule.


loadFrom

public static java.util.List<Rule> loadFrom(java.io.File file)
                                     throws java.io.IOException
Returns the rules defined in that file

Throws:
java.io.IOException

updateMeasures

public void updateMeasures(Hypothesis hyp,
                           Measures measures)
                    throws java.sql.SQLException
Adds the measures of unsatisfied rules

Throws:
java.sql.SQLException

ground

protected void ground(java.util.List<Literal> literalsToDo,
                      int numUnsatisfied,
                      double weight,
                      java.util.Map<java.lang.String,java.lang.String> bindings,
                      Literal freeLiteral,
                      Measures measures,
                      java.util.List<Hypothesis> grounded)
               throws java.sql.SQLException
Helper for groundedrules(), fills a list of grounded rules

Throws:
java.sql.SQLException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Test

Throws:
java.lang.Exception