felix.dstruct
Class FelixPredicate

java.lang.Object
  extended by tuffy.mln.Predicate
      extended by felix.dstruct.FelixPredicate

public class FelixPredicate
extends tuffy.mln.Predicate

The predicate object used in Felix, which extends the Predicate class in Tuffy to contain Felix-related fields and methods.

Author:
Ce Zhang

Nested Class Summary
static class FelixPredicate.FPProperty
          Properties that can be assigned to each predicate.
 
Field Summary
 ConcurrentOperatorsBucket belongsTo
          The parent ConcurrentOperatorsBucket.
 FelixPredicate corefMAPPredicate
          If isCorefPredicate is true, which relation serves as the linear-view-representation of it?
 java.lang.String dependencyFile
          Path the HDFS file that this predicate depends on.
 java.lang.String dependencyName
          Type of dependencies, e.g., "hdfs", "jdbc" etc.
 boolean isCorefMapPredicate
          Whether this predicate is the view-based representation of a coref operator.
 boolean isCorefPredicate
          Whether this predicate is a coref operator.
 java.lang.String jdbcdep
          Whether the extraction of this relation relies on other relations.
 boolean loadFromDatabase
          Whether the evidence file of this relation exists in some relational table instead of input evid.
 java.lang.String loadingSchema
          see loadFromDatabase
 java.lang.String loadingTable
          see loadFromDatabase
 java.lang.String mapinitScript
          Python script for running before all MAPs.
 java.lang.String mapinputvar
          The name of MAP's input variable.
 java.lang.String mapScript
          Python script for MAP.
 StatOperator.OPType mustbe
          The type of operator this predicate must be assigned to.
 boolean needExtractFeatures
          Do we need to extract features from HDFS for this relation?
 FelixPredicate oriCorefPredicate
          If isCorefMapPredicate is true, to which this predicate serves.
 java.lang.String reduceinitScript
          Python script for running before all REDUCEs.
 java.lang.String reduceinputkeyvar
          The name of REDUCE's input key variable.
 java.lang.String reduceinputvaluesvar
          The name of REDUCE's input value variable.
 java.lang.String reduceScript
          Python script for MAP.
 java.lang.String viewDef
          If this relation is defined as a view instead of a table, what is its view definition?
 java.lang.String xmltag
          If the input is XML tag, which <xmltag></xmltag> should we send to MAP as a unit?
 
Fields inherited from class tuffy.mln.Predicate
hasEvid, isCurrentlyView
 
Constructor Summary
FelixPredicate(java.lang.String aname, boolean aClosedWorld)
          The constructor.
 
Method Summary
 void addEvidence(tuffy.mln.Atom a)
          Adds atom as evidence to this predicate (Override Felix version) - the difference is that we sometimes flush it to file directly.
 void flushStrEvidence(java.lang.String rName)
          Flushes string-based evidence to database.
 java.util.ArrayList<java.lang.String> getCRFPartitionFields()
          Get partitioning fields of sequence if this predicate is CRF.
 java.util.ArrayList<java.lang.String> getKeyFieldsArgs()
          Get the key position if this predicate is LR or CRF.
 java.util.HashSet<java.lang.Integer> getKeyPositions()
          Get FelixPredicate#keyPositions.
 java.util.ArrayList<java.lang.String> getLabelFieldsArgs()
          Get the label fields' name if this predicate is LR or CRF.
 java.util.ArrayList<java.lang.String> getLabelFieldsTypeTable()
          Get the label types if this predicate is LR or CRF.
 java.util.ArrayList<java.lang.Integer> getLabelPositions()
          Get the label position if this predicate is LR or CRF.
static java.lang.String getNextTmpPredicateName()
          Get the name of the next temporary predicate.
 FelixPredicate getOriCorefPredicate()
          If isCorefMapPredicate is true, to which this predicate serves.
 java.util.HashSet<FelixClause> getPropertyClauses(FelixPredicate.FPProperty prop)
          Get clauses associated to the given property.
 java.util.HashSet<FelixClause> getRelevantClauses()
          Get all clauses related to this predicate.
 boolean hasProperty(FelixPredicate.FPProperty prop)
          Whether this predicate has the given property.
 boolean isCorefMap()
          Whether this predicate is the view-based representation of a coref operator.
 void registerProperty(FelixPredicate.FPProperty prop, FelixClause evid, int... _pos)
          Add a property to this predicate, along with the clause with this property.
 void setEmbeddedPythonCode(java.lang.String content)
          Sets embedded python code for this predicate
 java.lang.String toString()
          Returns string representation of this predicate.
 void tryToExtractSeqFromChainRule(FelixClause fc)
          If the given clause is a CRF chain rule, try to extract the partitions of sequence.
 
Methods inherited from class tuffy.mln.Predicate
addDependentAttrPosition, addFunctionalDependency, addQuery, addRelatedClause, appendArgument, appendArgument, appendToWriter, arity, closeFiles, createTable, flushEvidence, getArgPositionByName, getArgs, getBuiltInPredByName, getDependentAttrPositions, getDependentAttrs, getID, getKeyAttrPositions, getKeyAttrs, getLabelAttrPositions, getName, getQueryAtoms, getRelAct, getRelatedClauses, getRelName, getTypeAt, groundAndStoreAtom, hasDependentAttributes, hasMoreToGround, hasQuery, hasSoftEvidence, isBuiltIn, isBuiltInPredName, isClosedWorld, isCompletelySepcified, isImmutable, isSafeRefOnly, noNeedToGround, prepareDB, sealDefinition, setAllQuery, setClosedWorld, setCompeletelySpecified, setDB, setHasSoftEvidence, setID, setMLN, setSafeRefOnly, storeQueries
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dependencyFile

public java.lang.String dependencyFile
Path the HDFS file that this predicate depends on.


dependencyName

public java.lang.String dependencyName
Type of dependencies, e.g., "hdfs", "jdbc" etc.


mapScript

public java.lang.String mapScript
Python script for MAP.


mapinitScript

public java.lang.String mapinitScript
Python script for running before all MAPs.


reduceinitScript

public java.lang.String reduceinitScript
Python script for running before all REDUCEs.


reduceScript

public java.lang.String reduceScript
Python script for MAP.


needExtractFeatures

public boolean needExtractFeatures
Do we need to extract features from HDFS for this relation?


xmltag

public java.lang.String xmltag
If the input is XML tag, which <xmltag></xmltag> should we send to MAP as a unit?


jdbcdep

public java.lang.String jdbcdep
Whether the extraction of this relation relies on other relations.


mapinputvar

public java.lang.String mapinputvar
The name of MAP's input variable.


reduceinputkeyvar

public java.lang.String reduceinputkeyvar
The name of REDUCE's input key variable.


reduceinputvaluesvar

public java.lang.String reduceinputvaluesvar
The name of REDUCE's input value variable.


loadFromDatabase

public boolean loadFromDatabase
Whether the evidence file of this relation exists in some relational table instead of input evid. file.


loadingSchema

public java.lang.String loadingSchema
see loadFromDatabase


loadingTable

public java.lang.String loadingTable
see loadFromDatabase


mustbe

public StatOperator.OPType mustbe
The type of operator this predicate must be assigned to.


belongsTo

public ConcurrentOperatorsBucket belongsTo
The parent ConcurrentOperatorsBucket.


isCorefMapPredicate

public boolean isCorefMapPredicate
Whether this predicate is the view-based representation of a coref operator. This predicate must with a name suffix ``_map''.


isCorefPredicate

public boolean isCorefPredicate
Whether this predicate is a coref operator.


oriCorefPredicate

public FelixPredicate oriCorefPredicate
If isCorefMapPredicate is true, to which this predicate serves.


corefMAPPredicate

public FelixPredicate corefMAPPredicate
If isCorefPredicate is true, which relation serves as the linear-view-representation of it?


viewDef

public java.lang.String viewDef
If this relation is defined as a view instead of a table, what is its view definition?

Constructor Detail

FelixPredicate

public FelixPredicate(java.lang.String aname,
                      boolean aClosedWorld)
The constructor.

Parameters:
aname -
aClosedWorld -
Method Detail

addEvidence

public void addEvidence(tuffy.mln.Atom a)
Adds atom as evidence to this predicate (Override Felix version) - the difference is that we sometimes flush it to file directly.

Overrides:
addEvidence in class tuffy.mln.Predicate
Parameters:
a -

getLabelPositions

public java.util.ArrayList<java.lang.Integer> getLabelPositions()
Get the label position if this predicate is LR or CRF.

Returns:

setEmbeddedPythonCode

public void setEmbeddedPythonCode(java.lang.String content)
Sets embedded python code for this predicate

Parameters:
content -

getCRFPartitionFields

public java.util.ArrayList<java.lang.String> getCRFPartitionFields()
Get partitioning fields of sequence if this predicate is CRF.

Returns:

getKeyFieldsArgs

public java.util.ArrayList<java.lang.String> getKeyFieldsArgs()
Get the key position if this predicate is LR or CRF.

Returns:

getLabelFieldsTypeTable

public java.util.ArrayList<java.lang.String> getLabelFieldsTypeTable()
Get the label types if this predicate is LR or CRF.

Returns:

getLabelFieldsArgs

public java.util.ArrayList<java.lang.String> getLabelFieldsArgs()
Get the label fields' name if this predicate is LR or CRF.

Returns:

getNextTmpPredicateName

public static java.lang.String getNextTmpPredicateName()
Get the name of the next temporary predicate.

Returns:

isCorefMap

public boolean isCorefMap()
Whether this predicate is the view-based representation of a coref operator.

Returns:

getOriCorefPredicate

public FelixPredicate getOriCorefPredicate()
If isCorefMapPredicate is true, to which this predicate serves.

Returns:

getPropertyClauses

public java.util.HashSet<FelixClause> getPropertyClauses(FelixPredicate.FPProperty prop)
Get clauses associated to the given property.

Parameters:
prop -
Returns:

hasProperty

public boolean hasProperty(FelixPredicate.FPProperty prop)
Whether this predicate has the given property.

Parameters:
prop -
Returns:

getKeyPositions

public java.util.HashSet<java.lang.Integer> getKeyPositions()
Get FelixPredicate#keyPositions.

Returns:

flushStrEvidence

public void flushStrEvidence(java.lang.String rName)
Flushes string-based evidence to database.

Parameters:
rName -

getRelevantClauses

public java.util.HashSet<FelixClause> getRelevantClauses()
Get all clauses related to this predicate.

Returns:

registerProperty

public void registerProperty(FelixPredicate.FPProperty prop,
                             FelixClause evid,
                             int... _pos)
Add a property to this predicate, along with the clause with this property.

Parameters:
prop -
evid -
_pos - if this property is key constraint, this parameter is the position of keys.

tryToExtractSeqFromChainRule

public void tryToExtractSeqFromChainRule(FelixClause fc)
If the given clause is a CRF chain rule, try to extract the partitions of sequence.

Parameters:
fc -

toString

public java.lang.String toString()
Returns string representation of this predicate.

Overrides:
toString in class java.lang.Object