hyspirit.engines
Class HyPSQLEngine

java.lang.Object
  extended by hyspirit.engines.HyEngine
      extended by hyspirit.engines.HyInferenceEngine
          extended by hyspirit.engines.HyPSQLEngine
All Implemented Interfaces:
java.lang.Runnable

public class HyPSQLEngine
extends HyInferenceEngine

A PSQL engine runs PSQL (probabilistic SQL) programs. For example:

INSERT INTO index VALUES
0.5 ('sailing', 'doc1'),
0.9 ('boats', 'doc1'),
0.6 ('sailing', 'doc2');

INSERT INTO query VALUES 0.5 ('sailing'), 0.5('boats');

-- Simple retrieval matching query against index:
SELECT DISJOINT * FROM query, index where query.term = index.term;

Describing full-text retrieval with SQL is intutive, but causes quickly scalability problems. For solving this, the Apriorie framework runs external scalable engines. The Java-API engines are just convenient Java front-ends for accessing the functionality of the background engines, that serve knowledge bases.

Apriorie has patented its technology for large-scale probability estimations in PSQL. Basically, there are just two additional clauses needed, namely "ASSUMPTION" and "EVIDENCE KEY".

For example, the following view definition is crucial for IR:
CREATE VIEW invDocFreq AS
SELECT term
FROM docFreq
ASSUMPTION MAX INFORMATIVE
EVIDENCE KEY ();

The view invDocFreq(term) yields a probabilistic interpretation of the common inverse document frequency, an important parameter for relevance-based information retrieval.

Many more retrieval aspects can be described in PSQL. The Apriorie framework comes with various PSQL and other logical programs for implementing retrieval tasks such as classification and ad-hoc retrieval.


Field Summary
 
Fields inherited from class hyspirit.engines.HyInferenceEngine
deleteQueryProgram, retrieveProgram
 
Fields inherited from class hyspirit.engines.HyEngine
argumentString, LOG, stdin, TIME_PREFIX
 
Constructor Summary
HyPSQLEngine()
          Create an engine.
HyPSQLEngine(java.lang.String fileName)
          Create an engine and run (evaluate) the argument file.
 
Method Summary
protected  java.lang.String[] buildCommand()
          Builds the command from the parameters.
 java.lang.String echoSpecial(java.lang.String message)
          Returns a string which lets the engine echo the given message
protected  java.lang.String getStreamEndMessage()
          Returns the stream end message.
 void reset()
          Resets all parameters of the engine after destroying a possibly running process.
 
Methods inherited from class hyspirit.engines.HyInferenceEngine
deleteQuery, deleteQueryProgram, echo, eval, evalFile, nextTuple, retrieve, retrieveProgram, runProgram
 
Methods inherited from class hyspirit.engines.HyEngine
closeSTDIN, destroy, exitValue, getCommand, getEngineName, getInputReader, getOutputWriter, getPercentageCPU, getRealTime, getSTDERR, getSTDIN, getSTDOUT, getSysTime, getUserTime, hasNext, isInClientMode, isRunning, kb, kb, kb, next, readFromSTDIN, restart, run, send, send, sendAndReceive, sendFile, setArgumentString, setLogger, start, suppressSTDERR, takesTime, takeTime, waitFor, waitTillRunning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HyPSQLEngine

public HyPSQLEngine()
             throws HySpiritException
Create an engine. Sets defaults of deleteQueryProgram (DELETE FROM qterm) and retrieveProgram (SELECT * FROM retrieve).

Throws:
HySpiritException

HyPSQLEngine

public HyPSQLEngine(java.lang.String fileName)
             throws HySpiritException,
                    java.io.IOException
Create an engine and run (evaluate) the argument file. This is just a short cut for engine = new HyPSQLEngine(); engine.runFile(fileName).

Parameters:
fileName - the file name
Throws:
HySpiritException
java.io.IOException
Method Detail

getStreamEndMessage

protected java.lang.String getStreamEndMessage()
Returns the stream end message. The stream end message is needed for send in order to determine when the whole output is read.

Overrides:
getStreamEndMessage in class HyInferenceEngine
Returns:
the stream end message

echoSpecial

public java.lang.String echoSpecial(java.lang.String message)
Returns a string which lets the engine echo the given message

Overrides:
echoSpecial in class HyInferenceEngine
Parameters:
message - the message to be echoed
Returns:
the echo string

reset

public void reset()
Resets all parameters of the engine after destroying a possibly running process. You have to restart the process with run().

Overrides:
reset in class HyEngine

buildCommand

protected java.lang.String[] buildCommand()
Description copied from class: HyEngine
Builds the command from the parameters. If subclasses support other parameters, they have to override the buildCommand and reset methods. Be sure that you place the support for new, additional parameters somewhere. This means the block
   if (this.argumentString != null) {
     StringTokenizer strTok= new StringTokenizer(this.argumentString);
     while (strTok.hasMoreTokens()) commandVec.add(strTok.nextToken());
  }
  
should appear somewhere in your buildCommand implementation.

The output of this method is used in the run() method.

Overrides:
buildCommand in class HyEngine
Returns:
the command string array