de.unidu.is.retrieval.pire
Class PDatalogIndex

java.lang.Object
  extended byde.unidu.is.retrieval.pire.PDatalogIndex
All Implemented Interfaces:
Index

public class PDatalogIndex
extends java.lang.Object
implements Index

A document index, represented by specific relations. using pDatalog++.

Since:
2003-11-09
Version:
$Revision: 1.20 $, $Date: 2005/03/14 17:33:14 $
Author:
Henrik Nottelmann

Field Summary
protected  RelationBase base
          The relation base used by this index.
protected  java.lang.String collectionName
          The name of the corresponding collection.
protected  java.lang.String name
          The prefix for the relations, containing the collection name and the index key.
protected  java.util.Map removeRelations
          Map with relations which names of temporary relations which have to be deleted after retrieval.
 
Fields inherited from interface de.unidu.is.retrieval.pire.Index
DF_RELATION, DOCID_RELATION, EXPECTATION_RELATION, IDB_RD_RELATION, PROB_RELATION, RD_RELATION, RSV_RELATION, TF_RELATION, VARIANCE_RELATION, WEIGHT_RELATION
 
Constructor Summary
PDatalogIndex(RelationBase base, java.lang.String collectionName, java.lang.String key)
          Creates a new index.
 
Method Summary
 void add(Fact fact)
          Adds the fact to the knowledge base.
 EDBRelation addEDBRelation(java.lang.String name, int arity, boolean create)
          Creates a new EDB relation.
 IDBRelation addIDBRelation(java.lang.String name, int arity, boolean create)
          Creates a new IDB relation.
 void addMomentsCondition(java.lang.String queryID, double weight, java.lang.Object value, java.util.List addList)
          Adds a query condition for computing moments.
 void addRule(java.lang.String queryID, java.lang.String[] relations, double prob, java.util.List addList)
          Add a rule with the given relations and a single argument to the specified list.
 void closeQuery(java.lang.String queryID)
          Finishes the processing of this query and frees used resources.
 void completeRelation(java.lang.String name)
          Signals that the specified relation is complete.
 void compute(IDBRelation relation, java.util.Collection rules)
          Computes the result of the specified rules (all corresponding to the specified IDB relation).
 void compute(Rule rule)
          Computes the result of the specified rule.
 void compute(java.lang.String relationName, int arity, java.util.Collection rules)
          Computes the result of the specified rules (all corresponding to the specified IDB relation).
 void computeDisjoint(IDBRelation relation, java.util.Collection rules)
          Computes the result of the specified rules (all corresponding to the specified IDB relation).
 void computeDisjoint(java.lang.String relationName, int arity, java.util.Collection rules)
          Computes the result of the specified rules (all corresponding to the specified IDB relation).
 void computeMoments()
          Computes the moments of the indexing weights.
 void computeMoments(java.lang.String queryID, java.util.List ruleList)
          Finishes the computation of the moments.
 void computeProbs(java.lang.String queryID, java.util.List list, boolean computeDisjoint)
          Computes the probabilities of relevance for the given query based on the RSVs specified by the list of rules.
 java.lang.String convert(java.lang.String relationName)
          Converts a relative relation name into an absolute one, using the collection name and the index key as a prefix.
 java.lang.String convertCollection(java.lang.String relationName)
          Converts a relative relation name into an absolute one, using only the collection name as a prefix.
 double getMax(java.lang.String relation)
          Returns the maximum probability for the specified relation.
 double getMaxRSV(java.lang.String queryID, java.lang.String conditionID)
          Returns the maximum RSV for the specified query condition.
 java.lang.String getProbRelation(java.lang.String queryID, java.lang.String subqueryID)
           
 java.util.List getProbs(java.lang.String queryID, int numDocs)
          Returns the document ids and probabilities of relevance of the first documents.
 double getRD(java.lang.String key)
          Returns the value corresponding to the specified key in the rd relation.
 double getRD(java.lang.String key, double defaultValue)
          Returns the value corresponding to the specified key in the rd or idb_rd relations or a default value if no entry is found.
 Relation getRelation(java.lang.String name)
          Returns the specified relation.
 java.lang.String getRSVRelation(java.lang.String queryID, java.lang.String subqueryID)
           
 void init()
          Inits the index.
 void initQuery(java.lang.String queryID)
          Initialises the relation for the specified query.
 void insert(java.lang.String docID)
          Inserts the document id to the corresponding table.
 void insert(java.lang.String docID, java.lang.String token, int tokencount)
          Inserts the specified value into the given document.
 java.util.Iterator iterator(java.lang.String relation)
          Returns an iterator over the specified relation.
 void remove()
          Removes the index.
 void removeRelation(java.lang.String name)
          Removes the specified relation from this index.
 void setRD(java.lang.String key, double value)
          Sets the value corresponding to the specified key in the rd relation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

base

protected RelationBase base
The relation base used by this index.


collectionName

protected java.lang.String collectionName
The name of the corresponding collection.


name

protected java.lang.String name
The prefix for the relations, containing the collection name and the index key.


removeRelations

protected java.util.Map removeRelations
Map with relations which names of temporary relations which have to be deleted after retrieval. Keys are query IDs (as strings), the values are sets of relation names (as strings).

Constructor Detail

PDatalogIndex

public PDatalogIndex(RelationBase base,
                     java.lang.String collectionName,
                     java.lang.String key)
Creates a new index.

Parameters:
base - relation base
collectionName - name of the collection
key - index key
Method Detail

convert

public java.lang.String convert(java.lang.String relationName)
Converts a relative relation name into an absolute one, using the collection name and the index key as a prefix.

Specified by:
convert in interface Index
Parameters:
relationName - relative name of the relation
Returns:
absolute name of the relation

convertCollection

public java.lang.String convertCollection(java.lang.String relationName)
Converts a relative relation name into an absolute one, using only the collection name as a prefix.

Specified by:
convertCollection in interface Index
Parameters:
relationName - relative name of the relation
Returns:
absolute name of the relation

init

public void init()
Inits the index.

Specified by:
init in interface Index

insert

public void insert(java.lang.String docID)
Inserts the document id to the corresponding table.

Specified by:
insert in interface Index
Parameters:
docID - document id

insert

public void insert(java.lang.String docID,
                   java.lang.String token,
                   int tokencount)
Inserts the specified value into the given document.

Specified by:
insert in interface Index
Parameters:
docID - document id
token - token
tokencount - number of occurences of the value

computeMoments

public void computeMoments()
Computes the moments of the indexing weights.

Specified by:
computeMoments in interface Index

remove

public void remove()
Removes the index.

Specified by:
remove in interface Index

initQuery

public void initQuery(java.lang.String queryID)
Initialises the relation for the specified query.

Specified by:
initQuery in interface Index
Parameters:
queryID - query id

addRule

public void addRule(java.lang.String queryID,
                    java.lang.String[] relations,
                    double prob,
                    java.util.List addList)
Add a rule with the given relations and a single argument to the specified list.

Specified by:
addRule in interface Index
Parameters:
queryID - query id
relations - array of relation names
prob - probability of the rule
addList - list to which the rule is added

computeProbs

public void computeProbs(java.lang.String queryID,
                         java.util.List list,
                         boolean computeDisjoint)
Computes the probabilities of relevance for the given query based on the RSVs specified by the list of rules.

Specified by:
computeProbs in interface Index
Parameters:
queryID - query id
list - list of rules for computing the probabilities of relevance
computeDisjoint - if true, disjointness is assumed

getMaxRSV

public double getMaxRSV(java.lang.String queryID,
                        java.lang.String conditionID)
Returns the maximum RSV for the specified query condition.

Specified by:
getMaxRSV in interface Index
Parameters:
queryID - query id
conditionID - condition identifier (in the relation name)
Returns:
maximum RSV for the specified query

getMax

public double getMax(java.lang.String relation)
Returns the maximum probability for the specified relation.

Specified by:
getMax in interface Index
Parameters:
relation - relation name
Returns:
maximum probability for the specified relation

getProbs

public java.util.List getProbs(java.lang.String queryID,
                               int numDocs)
Returns the document ids and probabilities of relevance of the first documents.

Specified by:
getProbs in interface Index
Parameters:
queryID - query id
numDocs - number of documents to be retrieved
Returns:
list of ProbDoc instances

closeQuery

public void closeQuery(java.lang.String queryID)
Finishes the processing of this query and frees used resources.

Specified by:
closeQuery in interface Index
Parameters:
queryID - query id

addMomentsCondition

public void addMomentsCondition(java.lang.String queryID,
                                double weight,
                                java.lang.Object value,
                                java.util.List addList)
Adds a query condition for computing moments. This method can apply the condition directly (i.e., it computes the moments for that condition) or store it for later reference in computeMoments.

Specified by:
addMomentsCondition in interface Index
Parameters:
queryID - query id
weight - condition weight
value - comparison value

computeMoments

public void computeMoments(java.lang.String queryID,
                           java.util.List ruleList)
Finishes the computation of the moments.

Specified by:
computeMoments in interface Index
Parameters:
queryID - query id

getRD

public double getRD(java.lang.String key)
Returns the value corresponding to the specified key in the rd relation.

Currently, only extensionally added values (via setRD(String,double)) can be retrieved, but not computed values.

Specified by:
getRD in interface Index
Parameters:
key - value key
Returns:
value

getRD

public double getRD(java.lang.String key,
                    double defaultValue)
Returns the value corresponding to the specified key in the rd or idb_rd relations or a default value if no entry is found.

Specified by:
getRD in interface Index
Parameters:
key - value key
defaultValue - default value used if no value is found
Returns:
value for the specified key

setRD

public void setRD(java.lang.String key,
                  double value)
Sets the value corresponding to the specified key in the rd relation.

Specified by:
setRD in interface Index
Parameters:
key - value key
value - value

add

public void add(Fact fact)
Adds the fact to the knowledge base.

Specified by:
add in interface Index
Parameters:
fact - fact to be added

compute

public void compute(Rule rule)
Computes the result of the specified rule.

Specified by:
compute in interface Index
Parameters:
rule - single rule for target relation

compute

public void compute(IDBRelation relation,
                    java.util.Collection rules)
Computes the result of the specified rules (all corresponding to the specified IDB relation).

Specified by:
compute in interface Index
Parameters:
relation - target relation
rules - collection of rules for target relation

compute

public void compute(java.lang.String relationName,
                    int arity,
                    java.util.Collection rules)
Computes the result of the specified rules (all corresponding to the specified IDB relation).

Parameters:
relationName - target relation name
arity - target relation arity
rules - collection of rules for target relation

computeDisjoint

public void computeDisjoint(IDBRelation relation,
                            java.util.Collection rules)
Computes the result of the specified rules (all corresponding to the specified IDB relation). The results from the single rules are considered to be disjoint.

Specified by:
computeDisjoint in interface Index
Parameters:
relation - target relation
rules - collection of rules for target relation

computeDisjoint

public void computeDisjoint(java.lang.String relationName,
                            int arity,
                            java.util.Collection rules)
Computes the result of the specified rules (all corresponding to the specified IDB relation). The results from the single rules are considered to be disjoint.

Specified by:
computeDisjoint in interface Index
Parameters:
relationName - target relation name
arity - arity
rules - collection of rules for target relation

iterator

public java.util.Iterator iterator(java.lang.String relation)
Returns an iterator over the specified relation.

Specified by:
iterator in interface Index
Parameters:
relation - relation name
Returns:
iterator over the specified relation (Fact instances)

getRelation

public Relation getRelation(java.lang.String name)
Returns the specified relation.

Parameters:
name - relation name
Returns:
relation object

addEDBRelation

public EDBRelation addEDBRelation(java.lang.String name,
                                  int arity,
                                  boolean create)
Creates a new EDB relation.

Specified by:
addEDBRelation in interface Index
Parameters:
name - name of the relation
arity - arity of the relation
create - if true, the relation is physically created
Returns:
new EDB relation

addIDBRelation

public IDBRelation addIDBRelation(java.lang.String name,
                                  int arity,
                                  boolean create)
Creates a new IDB relation.

Specified by:
addIDBRelation in interface Index
Parameters:
name - name of the relation
arity - arity of the relation
create - if true, the relation is physically created
Returns:
new IDB relation

completeRelation

public void completeRelation(java.lang.String name)
Signals that the specified relation is complete.

Specified by:
completeRelation in interface Index
Parameters:
name - relation name

removeRelation

public void removeRelation(java.lang.String name)
Removes the specified relation from this index.

Specified by:
removeRelation in interface Index
Parameters:
name - relation name

getRSVRelation

public java.lang.String getRSVRelation(java.lang.String queryID,
                                       java.lang.String subqueryID)
Specified by:
getRSVRelation in interface Index
Parameters:
queryID -
subqueryID -

getProbRelation

public java.lang.String getProbRelation(java.lang.String queryID,
                                        java.lang.String subqueryID)
Specified by:
getProbRelation in interface Index
Parameters:
queryID -
subqueryID -