Class InfModelB

Description

A InfModelB extends the InfModel Class, with a backward chaining algorithm.

Only the loaded or added base-triples are stored. A find-query evaluates the inference rules and recursively tries to find the statements. InfModelB memorises "Dead-Ends" until the next add() command, thus makin a second find much faster. InfModelB is safe for loops in Ontologies, that would cause infinite loops. WARNING: A find(null,null,null) might take very long.

Located in /infModel/InfModelB.php (line 23)

Object
   |
   --Model
      |
      --MemModel
         |
         --InfModel
            |
            --InfModelB
Variable Summary
Method Summary
InfModelB InfModelB ([string $baseURI = null])
void add (object Statement $statement)
boolean contains (object Statement &$statement)
object MemModel find (object Node $subject, object Node $predicate, object Node $object)
object FindIterator &findAsIterator ([ $sub = null], [ $pred = null], [ $obj = null])
object Statement findFirstMatchingStatement (object Node $subject, object Node $predicate, object Node $object, [integer $offset = 0])
object MemModel &getBaseMemModel ()
object MemModel &getMemModel ()
object StatementIterator &getStatementIterator ()
boolean remove (object Statement $statement)
boolean saveAs (string $filename, [string $type = 'rdf'])
integer size (boolean 0)
string toString ()
void writeAsHtml ()
string writeRdfToString ()
object array _infFind (object Node $subject, object Node $predicate, object Node $object, array $searchStringIndex, [boolean $findOnlyFirstMatching = false], [integer $offset = 0], [integer $resultCount = 0])
boolean _nodeEqualsFind ( &$find,  $node, object Statement $statement)
Variables
array $findDeadEnds (line 33)

Array that holds combinations of inference rules with distinct find-querys, that don't lead to any inference.

  • access: private

Inherited Variables

Inherited from InfModel

InfModel::$infRules
InfModel::$infRulesEntailIndex
InfModel::$infRulesTriggerIndex
InfModel::$statementRuleIndex
InfModel::$supportedInference

Inherited from MemModel

MemModel::$indexArr
MemModel::$indexed
MemModel::$parsedNamespaces
MemModel::$triples

Inherited from Model

Model::$baseURI
Model::$bNodeCount
Methods
Constructor InfModelB (line 43)

Constructor You can supply a base_uri

  • access: public
InfModelB InfModelB ([string $baseURI = null])
  • string $baseURI
add (line 58)

Adds a new triple to the Model without checking, if the statement is already in the Model. So if you want a duplicate free Model use the addWithoutDuplicates() function (which is slower then add())

  • throws: PhpError
  • access: public
void add (object Statement $statement)
  • object Statement $statement

Redefinition of:
InfModel::add()
Adds a new triple to the Model without checking if the statement is already in the Model.
contains (line 230)

Tests if the Model contains the given triple.

TRUE if the triple belongs to the Model; FALSE otherwise.

  • access: public
boolean contains (object Statement &$statement)
  • object Statement &$statement

Redefinition of:
MemModel::contains()
Tests if the MemModel contains the given triple.
find (line 84)

General method to search for triples.

NULL input for any parameter will match anything. Example: $result = $m->find( NULL, NULL, $node ); Finds all triples with $node as object. Returns an empty MemModel if nothing is found. To improve the search speed with big Models, call index(INDEX_TYPE) before seaching.

It recursively searches in the statements and rules to find matching statements.

  • throws: PhpError
  • access: public
object MemModel find (object Node $subject, object Node $predicate, object Node $object)
  • object Node $subject
  • object Node $predicate
  • object Node $object

Redefinition of:
MemModel::find()
General method to search for triples.
findAsIterator (line 508)

Returns a FindIterator for traversing the MemModel.

Disabled in InfModelB.

  • access: public
object FindIterator &findAsIterator ([ $sub = null], [ $pred = null], [ $obj = null])
  • $sub
  • $pred
  • $obj

Redefinition of:
MemModel::findAsIterator()
Returns a FindIterator for traversing the MemModel.
findFirstMatchingStatement (line 265)

Searches for triples and returns the first matching statement.

NULL input for any parameter will match anything. Example: $result = $m->findFirstMatchingStatement( NULL, NULL, $node ); Returns the first statement of the MemModel where the object equals $node. Returns an NULL if nothing is found. You can define an offset to search for. Default = 0

  • access: public
object Statement findFirstMatchingStatement (object Node $subject, object Node $predicate, object Node $object, integer $offset)
  • object Node $subject
  • object Node $predicate
  • object Node $object
  • integer $offset

Redefinition of:
MemModel::findFirstMatchingStatement()
Searches for triples and returns the first matching statement.
getBaseMemModel (line 336)

Create a MemModel containing only the base triples (without inferred statements) of the current InfModelB.

  • access: public
object MemModel &getBaseMemModel ()
getMemModel (line 320)

Create a MemModel containing all the triples (including inferred statements) of the current InfModelB.

  • access: public
object MemModel &getMemModel ()
getStatementIterator (line 286)

Returns a StatementIterator for traversing the Model.

  • access: public
object StatementIterator &getStatementIterator ()

Redefinition of:
MemModel::getStatementIterator()
Returns a StatementIterator for traversing the MemModel.
remove (line 457)

Removes the triple from the MemModel.

TRUE if the triple is removed. FALSE otherwise.

Checks, if it touches any statements, that added inference rules to the model.

  • throws: PhpError
  • access: public
boolean remove (object Statement $statement)
  • object Statement $statement

Redefinition of:
MemModel::remove()
Removes the triple from the MemModel.
saveAs (line 390)

Saves the RDF,N3 or N-Triple serialization of the full InfModelB (including inferred triples) to a file.

You can decide to which format the model should be serialized by using a corresponding suffix-string as $type parameter. If no $type parameter is placed this method will serialize the model to XML/RDF format. Returns FALSE if the InfModelB couldn't be saved to the file.

  • throws: PhpError
  • access: public
boolean saveAs (string $filename, [string $type = 'rdf'])
  • string $filename
  • string $type

Redefinition of:
MemModel::saveAs()
Saves the RDF,N3 or N-Triple serialization of the MemModel to a file.
size (line 304)

Number of all inferable triples in the Model.

WARNING: uses a find(null,null,null) to find all statements! (might take a while)

  • access: public
integer size (boolean 0)
  • boolean 0

Redefinition of:
MemModel::size()
Number of triples in the MemModel
toString (line 353)

Short Dump of the InfModelB.

  • access: public
string toString ()

Redefinition of:
MemModel::toString()
Short Dump of the MemModel.
toStringIncludingTriples (line 364)

Dumps of the InfModelB including ALL inferable triples.

  • access: public
string toStringIncludingTriples ()

Redefinition of:
MemModel::toStringIncludingTriples()
Dumps of the MemModel including all triples.
writeAsHtml (line 403)

Writes the RDF serialization of the Model including ALL inferable triples as HTML.

  • access: public
void writeAsHtml ()

Redefinition of:
MemModel::writeAsHtml()
Writes the RDF serialization of the MemModel as HTML.
writeAsHtmlTable (line 420)

Writes the RDF serialization of the Model including ALL inferable triples as HTML table.

  • access: public
void writeAsHtmlTable ()

Redefinition of:
MemModel::writeAsHtmlTable()
Writes the RDF serialization of the MemModel as HTML table.
writeRdfToString (line 435)

Writes the RDF serialization of the Model including ALL inferable triples.

  • access: public
string writeRdfToString ()

Redefinition of:
MemModel::writeRdfToString()
Writes the RDF serialization of the MemModel as HTML table.
_infFind (line 135)

This is the main inference method of the InfModelB The algorithm works as follows: Find all statements in the base model, that matches the current find-query.

Check all rules, if they are able to deliver infered statements, that match the current find-query. Don't use rules with queries, that lead to dead-ends and don't use a rule-query-combination that was used before in this branch (ontology loops). If a rule is possible do deliver such statements, get a new find-query, that is possible to find those statements, that are able to trigger this rule. Call this _infFind method wirh the new find-query and entail the resulting statements. If this rule, wasn't able to return any statements with this distinct query, add this combination to the dead-ends. Return the statements from the base triples and those, which were infered.

If $findOnlyFirstMatching is set to true, only the first match in the base-statements is entailed an returned (used in contains() and findFirstMatchingStatement() methods).

You can set an offset to look for the first matching statement by setting the $offset var.

It recursively searches in the statements and rules to find matching statements

  • return: Statements
  • access: private
object array _infFind (object Node $subject, object Node $predicate, object Node $object, array $searchStringIndex, [boolean $findOnlyFirstMatching = false], integer $offset, integer $resultCount)
  • object Node $subject
  • object Node $predicate
  • object Node $object
  • array $searchStringIndex
  • boolean $findOnlyFirstMatching
  • integer $offset
  • integer $resultCount
_nodeEqualsFind (line 484)

Checks, if a single node matches a single find pattern.

TRUE if the node matches. FALSE otherwise.

Checks, if it touches any statements, that added inference rules to the model.

  • access: private
boolean _nodeEqualsFind ( &$find,  $node, object Statement $statement)
  • object Statement $statement
  • &$find
  • $node

Inherited Methods

Inherited From InfModel

InfModel::InfModel()
InfModel::add()
InfModel::findRegex()
InfModel::findVocabulary()
InfModel::getSchema()
InfModel::replace()
InfModel::_addInfRule()
InfModel::_addInfruleToIndex()
InfModel::_addToInference()
InfModel::_findRuleEntailmentInIndex()
InfModel::_findRuleTriggerInIndex()
InfModel::_removeFromInference()

Inherited From MemModel

MemModel::MemModel()
MemModel::add()
MemModel::addModel()
MemModel::addNamespace()
MemModel::addParsedNamespaces()
MemModel::addWithoutDuplicates()
MemModel::close()
MemModel::contains()
MemModel::containsAll()
MemModel::containsAny()
MemModel::equals()
MemModel::find()
MemModel::findAsIterator()
MemModel::findCount()
MemModel::findFirstMatchingStatement()
MemModel::findFirstMatchOff()
MemModel::findRegex()
MemModel::findVocabulary()
MemModel::getIndexType()
MemModel::getParsedNamespaces()
MemModel::getStatementIterator()
MemModel::index()
MemModel::intersect()
MemModel::isEmpty()
MemModel::isIndexed()
MemModel::iterFind()
MemModel::matchStatement()
MemModel::rdqlQuery()
MemModel::rdqlQueryAsIterator()
MemModel::reify()
MemModel::remove()
MemModel::removeNamespace()
MemModel::replace()
MemModel::saveAs()
MemModel::setBaseURI()
MemModel::size()
MemModel::subtract()
MemModel::toString()
MemModel::toStringIncludingTriples()
MemModel::unite()
MemModel::writeAsHtml()
MemModel::writeAsHtmlTable()
MemModel::writeRdfToString()
MemModel::_containsIndex()
MemModel::_findInIndex()
MemModel::_findMatchIndex()
MemModel::_indexOpr()

Inherited From Model

Model::Model()
Model::findForward()
Model::getBaseURI()
Model::getMemModelByRDQL()
Model::getOntModel()
Model::getResModel()
Model::getUniqueResourceURI()
Model::load()
Model::sparqlQuery()
Model::visualize()
Model::_addStatementFromAnotherModel()

Inherited From Object

Object::toString()

Documentation generated on Mon, 26 Jun 2006 14:25:31 +0200 by phpDocumentor 1.3.0RC6