sofie.maxsat
Class Literal

java.lang.Object
  extended by sofie.maxsat.Hypothesis
      extended by sofie.maxsat.Literal
All Implemented Interfaces:
java.lang.Comparable<Hypothesis>

public class Literal
extends Hypothesis

Class Literal 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 literal, i.e. a hypothesis with a truth value, possibly containing variables.


Nested Class Summary
 
Nested classes/interfaces inherited from class sofie.maxsat.Hypothesis
Hypothesis.Truth
 
Field Summary
static javatools.database.ResultIterator.ResultWrapper<Hypothesis> disambiguationPriorWrapper
          Converts a hypothesis line to a Fact object
protected  Hypothesis.Truth hasInstances
          TRUE if this literal has instances
protected static javatools.database.ResultIterator.ResultWrapper<Hypothesis> patternOccurrencesWrapper
          Converts a database line to a Hypothesis object
protected  boolean polarity
          Holds the polarity
static javatools.database.ResultIterator.ResultWrapper<Hypothesis> yagoWrapper
          Converts a database line to a Hypothesis object
 
Fields inherited from class sofie.maxsat.Hypothesis
components, DISAMBIGUATEDAS, DISAMBIGUATIONPRIOR, FLAGSET, PATTERNOCCURRENCES, priority, relation, value, WORDINCONTEXT
 
Constructor Summary
Literal(boolean pol, java.util.List<java.lang.String> parts)
          Constructs a literal
Literal(boolean pol, basics.datagraph.Relation r, java.lang.String... a)
          Constructs a literal
Literal(boolean pol, java.lang.String... parts)
          Constructs a literal
 
Method Summary
 java.util.Map<java.lang.String,java.lang.String> bindingsToMatch(Hypothesis f, java.util.Map<java.lang.String,java.lang.String> bindings)
          Returns the bindings of variables of this literal that are necessary to match this literal to f.
protected  javatools.datatypes.PeekIterator<Hypothesis> closedWorldIterator(javatools.datatypes.PeekIterator<Hypothesis> it)
          Helper routine for ground().
 java.lang.Iterable<Hypothesis> ground()
          Returns a set of grounded hypotheses for the literal.
 int groundPriority(java.util.Collection<java.lang.String> knownVariables)
          Returns how good it would be to ground this literal with the current known variables
 boolean hasInstances()
          TRUE for a literal that has instances
 boolean hasVariable()
          TRUE if the literal contains a variable
 javatools.datatypes.PeekIterator<Hypothesis> instances()
          Loads all instantiations of this literal from the database
 boolean isFree()
          TRUE for free literals
 boolean isUnhappyWith(Hypothesis h)
          TRUE if the literal is unhappy with this hypothesis
static void main(java.lang.String[] args)
          Test method
 boolean matches(Hypothesis f)
          Returns the bindings of variables of this literal that are necessary to match this literal to f.
protected static java.lang.String normalize(java.lang.String a)
          Normalizes an identifier
static Literal parse(java.lang.String lit)
          Constructs a literal
 boolean polarity()
          Returns the polarity
 Hypothesis.Truth polarityOf(Hypothesis f)
          Returns the value of f, adjusted for polarity
protected  java.lang.Iterable<Hypothesis> singleHypothesis(boolean value)
          Helper routine for ground().
 Literal swapPolarity()
          Swaps the polarity, returns THIS
 java.lang.String toString()
           
 Literal withBindings(java.util.Map<java.lang.String,java.lang.String> bindings)
          Applies the bindings
 
Methods inherited from class sofie.maxsat.Hypothesis
arg, compareTo, component, components, containsPolysem, equals, hashCode, hasVirtualRelation, isEntity, isPolysem, isString, isVariable, numArgs, numComponents, priority, relationIfKnown, relationName, saveTo, saveTo, setPriority, setRelations, setValue, setValue, setValue, trace, value
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

polarity

protected boolean polarity
Holds the polarity


patternOccurrencesWrapper

protected static javatools.database.ResultIterator.ResultWrapper<Hypothesis> patternOccurrencesWrapper
Converts a database line to a Hypothesis object


yagoWrapper

public static javatools.database.ResultIterator.ResultWrapper<Hypothesis> yagoWrapper
Converts a database line to a Hypothesis object


disambiguationPriorWrapper

public static javatools.database.ResultIterator.ResultWrapper<Hypothesis> disambiguationPriorWrapper
Converts a hypothesis line to a Fact object


hasInstances

protected Hypothesis.Truth hasInstances
TRUE if this literal has instances

Constructor Detail

Literal

public Literal(boolean pol,
               java.util.List<java.lang.String> parts)
Constructs a literal


Literal

public Literal(boolean pol,
               java.lang.String... parts)
Constructs a literal


Literal

public Literal(boolean pol,
               basics.datagraph.Relation r,
               java.lang.String... a)
Constructs a literal

Method Detail

polarity

public boolean polarity()
Returns the polarity


swapPolarity

public Literal swapPolarity()
Swaps the polarity, returns THIS


polarityOf

public Hypothesis.Truth polarityOf(Hypothesis f)
Returns the value of f, adjusted for polarity


isUnhappyWith

public boolean isUnhappyWith(Hypothesis h)
TRUE if the literal is unhappy with this hypothesis


toString

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

bindingsToMatch

public java.util.Map<java.lang.String,java.lang.String> bindingsToMatch(Hypothesis f,
                                                                        java.util.Map<java.lang.String,java.lang.String> bindings)
Returns the bindings of variables of this literal that are necessary to match this literal to f. NULL for failure


withBindings

public Literal withBindings(java.util.Map<java.lang.String,java.lang.String> bindings)
Applies the bindings


matches

public boolean matches(Hypothesis f)
Returns the bindings of variables of this literal that are necessary to match this literal to f. NULL for failure


isFree

public boolean isFree()
TRUE for free literals


groundPriority

public int groundPriority(java.util.Collection<java.lang.String> knownVariables)
Returns how good it would be to ground this literal with the current known variables


hasVariable

public boolean hasVariable()
TRUE if the literal contains a variable


singleHypothesis

protected java.lang.Iterable<Hypothesis> singleHypothesis(boolean value)
Helper routine for ground(). Returns the hypothesis only if it makes the literal unhappy. Sets this's value to value


closedWorldIterator

protected javatools.datatypes.PeekIterator<Hypothesis> closedWorldIterator(javatools.datatypes.PeekIterator<Hypothesis> it)
Helper routine for ground(). If the polarity of this literal is TRUE, we want to return only FALSE groundings. In the closed world assumption, there are no explicit FALSE groundings. Hence, in this case, we return a dummy hypothesis with truth value FALSE.


ground

public java.lang.Iterable<Hypothesis> ground()
                                      throws java.sql.SQLException
Returns a set of grounded hypotheses for the literal. Returns only those hypotheses that make the literal unhappy. Returns a hypothesis with value=-2 if that hypothesis should be added to the database.

Throws:
java.sql.SQLException

normalize

protected static java.lang.String normalize(java.lang.String a)
Normalizes an identifier


parse

public static Literal parse(java.lang.String lit)
Constructs a literal


instances

public javatools.datatypes.PeekIterator<Hypothesis> instances()
                                                       throws java.sql.SQLException
Loads all instantiations of this literal from the database

Throws:
java.sql.SQLException

hasInstances

public boolean hasInstances()
                     throws java.sql.SQLException
TRUE for a literal that has instances

Throws:
java.sql.SQLException

main

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

Throws:
java.lang.Exception