operator
Class LROperator

java.lang.Object
  extended by java.lang.Thread
      extended by dstruct.StatOperator
          extended by operator.LROperator
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Runnable

public class LROperator
extends StatOperator

A LR operator in Felix.

Author:
Ce Zhang

Nested Class Summary
 
Nested classes/interfaces inherited from class dstruct.StatOperator
StatOperator.OPType
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
(package private)  DataMovementOperator getAllUnigramFeaturesDMO
          The DataMovementOperator fetching all unigram features.
(package private)  java.util.HashMap<java.lang.Integer,java.lang.String[]> id2Label
          The inverse map of label2ID.
(package private)  java.util.HashMap<java.lang.String,java.lang.Integer> label2ID
          Mapping from label's constant ID to a new label ID.
(package private)  DataMovementOperator labelDomainDMO
          The DataMovementOperator representing the table/view for all possible labels.
(package private)  DataMovementOperator lrDMO
          The DataMovementOperator which is the union of all LR rules.
(package private)  java.util.ArrayList<DataMovementOperator> lrDMOs
          All DataMovementOperators used as LR rules.
(package private)  FelixPredicate lrHead
          Target predicate of this LR operator.
(package private)  DataMovementOperator unigramDMO
          The DataMovementOperator representing the table/view for all unigram features.
 
Fields inherited from class dstruct.StatOperator
allDMOs, allRelevantFelixClause, belongsToBucket, clauseConstraints, dataCrackerSignature, db, fq, inputPredicates, isMarginal, options, outputPredicates, partitionedInto, precedence, type
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LROperator(FelixQuery _fq, java.util.HashSet<FelixPredicate> _goalPredicates, parser.CommandOptions _opt)
          The constructor of LROperator.
 
Method Summary
(package private)  java.lang.String array2str(java.lang.String[] _array)
           
 java.lang.String explain()
          Human-readable representation of the logic plan.
 void inferAndDumpToTmpFile(java.lang.String signature, double[] weights, java.io.BufferedWriter bw)
          Infer and dump answers to the given buffered writer (with a format that can be COPY into postgres table directly).
static double logAdd(double logX, double logY)
           
 void prepare()
          Generate the operator-specified logic plan, i.e., all data movement operators that will be used for inference.
 void prepareDMO(java.util.HashSet<mln.ConjunctiveQuery> lrQueries)
          Generate Data Movement Operator used by this LR Operator.
 void run()
          Method that executes this operator.
 
Methods inherited from class dstruct.StatOperator
clone, getAllDMOs, getPrecedence, getTargetPredicateIfHasOnlyOne, toString, translateFelixClasesIntoFactorGraphEdgeQueries
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lrHead

FelixPredicate lrHead
Target predicate of this LR operator.


label2ID

java.util.HashMap<java.lang.String,java.lang.Integer> label2ID
Mapping from label's constant ID to a new label ID. This new label ID is from 0, which is used in the inference of LR (s.t., we can use array to represent labels).


id2Label

java.util.HashMap<java.lang.Integer,java.lang.String[]> id2Label
The inverse map of label2ID.


lrDMOs

java.util.ArrayList<DataMovementOperator> lrDMOs
All DataMovementOperators used as LR rules.


lrDMO

DataMovementOperator lrDMO
The DataMovementOperator which is the union of all LR rules.


unigramDMO

DataMovementOperator unigramDMO
The DataMovementOperator representing the table/view for all unigram features.


labelDomainDMO

DataMovementOperator labelDomainDMO
The DataMovementOperator representing the table/view for all possible labels.


getAllUnigramFeaturesDMO

DataMovementOperator getAllUnigramFeaturesDMO
The DataMovementOperator fetching all unigram features.

Constructor Detail

LROperator

public LROperator(FelixQuery _fq,
                  java.util.HashSet<FelixPredicate> _goalPredicates,
                  parser.CommandOptions _opt)
The constructor of LROperator.

Parameters:
_fq - Felix query.
_goalPredicates - target predicates of this coref operator.
_opt - Command line options of this Felix run.
Method Detail

prepare

public void prepare()
Description copied from class: StatOperator
Generate the operator-specified logic plan, i.e., all data movement operators that will be used for inference. This function should be invoked after a new instance of operator is created. Any valid Felix operator should implement this method.

Specified by:
prepare in class StatOperator

array2str

java.lang.String array2str(java.lang.String[] _array)

run

public void run()
Description copied from class: StatOperator
Method that executes this operator. Any valid Felix operator should implement this method.

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class StatOperator

explain

public java.lang.String explain()
Description copied from class: StatOperator
Human-readable representation of the logic plan. Any valid Felix operator should implement this method. TODO: need to think out a better to explain physical plan. (e.g., a graph?)

Specified by:
explain in class StatOperator

prepareDMO

public void prepareDMO(java.util.HashSet<mln.ConjunctiveQuery> lrQueries)
Generate Data Movement Operator used by this LR Operator.

Parameters:
rules - rules defining this operator.

logAdd

public static double logAdd(double logX,
                            double logY)

inferAndDumpToTmpFile

public void inferAndDumpToTmpFile(java.lang.String signature,
                                  double[] weights,
                                  java.io.BufferedWriter bw)
Infer and dump answers to the given buffered writer (with a format that can be COPY into postgres table directly).

Parameters:
signature - signature of current predicate instance.
weights - array of weights. Each entry corresponding to the weight of a label.
bw -