operator
Class CRFOperator

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

public class CRFOperator
extends StatOperator

A CRF operator in Felix.

Author:
Ce Zhang

Nested Class Summary
(package private)  class CRFOperator.Node
          Class for a node in the CRFOperator.Sequence.
(package private)  class CRFOperator.Sequence
          In-memory representation of a CRF chain.
 
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 bigramDMO
          The DataMovementOperator representing the table/view for all bigram features.
(package private)  DataMovementOperator crfDMO
          The DataMovementOperator used as CRF Chain rule.
(package private)  FelixPredicate crfHead
          Target predicate of this CRF operator.
(package private)  DataMovementOperator getAllBigramFeaturesDMO
          The DataMovementOperator fetching all bigram features.
(package private)  DataMovementOperator getAllPossiblePartitioningDMO
          The DataMovementOperator fetching a partition of grounded literals (which may be a sequence or multiples sequences)
(package private)  DataMovementOperator getAllUnigramFeaturesDMO
          The DataMovementOperator fetching all unigram features.
(package private)  DataMovementOperator getBigramFeaturesForPartitioningDMO
          The DataMovementOperator fetching all bigram features for a given sequence.
(package private)  DataMovementOperator getUnigramFeaturesForPartitioningDMO
          The DataMovementOperator fetching all unigram features for a given sequence
(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)  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
CRFOperator(FelixQuery _fq, java.util.HashSet<FelixPredicate> _goalPredicates, parser.CommandOptions _opt)
          The constructor of CRFOperator.
 
Method Summary
(package private)  java.lang.String array2str(java.lang.String[] _array)
          Return the signature of a string array as a string.
 java.lang.String explain()
          Human-readable representation of the logic plan.
 void fastInfer(java.io.BufferedWriter bw)
          Conduct CRF infer WITH knowledge about partitioning which is parsed statically from the input program.
 int getPartitionSize()
          Estimate the number of sequences.
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, java.util.HashSet<mln.ConjunctiveQuery> chainQueries)
          Generate Data Movement Operator used by this CRF Operator.
 void run()
          Method that executes this operator.
 void slowInfer(java.io.BufferedWriter bw)
          Conduct CRF infer WITHOUT knowledge about partitioning which is parsed statically from the input program.
 
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

crfHead

FelixPredicate crfHead
Target predicate of this CRF 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 CRF (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. Here String[] means there can be multiple fields corresponding to CRF's labeling field.


lrDMOs

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


crfDMO

DataMovementOperator crfDMO
The DataMovementOperator used as CRF Chain rule.


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.


bigramDMO

DataMovementOperator bigramDMO
The DataMovementOperator representing the table/view for all bigram features.


labelDomainDMO

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


getAllPossiblePartitioningDMO

DataMovementOperator getAllPossiblePartitioningDMO
The DataMovementOperator fetching a partition of grounded literals (which may be a sequence or multiples sequences)


getBigramFeaturesForPartitioningDMO

DataMovementOperator getBigramFeaturesForPartitioningDMO
The DataMovementOperator fetching all bigram features for a given sequence.


getUnigramFeaturesForPartitioningDMO

DataMovementOperator getUnigramFeaturesForPartitioningDMO
The DataMovementOperator fetching all unigram features for a given sequence


getAllBigramFeaturesDMO

DataMovementOperator getAllBigramFeaturesDMO
The DataMovementOperator fetching all bigram features.


getAllUnigramFeaturesDMO

DataMovementOperator getAllUnigramFeaturesDMO
The DataMovementOperator fetching all unigram features.

Constructor Detail

CRFOperator

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

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)
Return the signature of a string array as a string.

Parameters:
_array -
Returns:

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

fastInfer

public void fastInfer(java.io.BufferedWriter bw)
Conduct CRF infer WITH knowledge about partitioning which is parsed statically from the input program.

Parameters:
bw - Buffered writer to dump results.

slowInfer

public void slowInfer(java.io.BufferedWriter bw)
Conduct CRF infer WITHOUT knowledge about partitioning which is parsed statically from the input program.

Parameters:
bw - Buffered writer to dump results.

prepareDMO

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

Parameters:
rules - rules defining this operator.

getPartitionSize

public int getPartitionSize()
Estimate the number of sequences.

Returns:

logAdd

public static double logAdd(double logX,
                            double logY)