strus  0.17
Public Member Functions | List of all members
strus::VectorStorageClientInterface Class Referenceabstract

Interface to a repository for vectors representing word embeddings. More...

#include <vectorStorageClientInterface.hpp>

Public Member Functions

virtual ~VectorStorageClientInterface ()
 Destructor. More...
 
virtual void prepareSearch (const std::string &type)=0
 Prepare datastructures for calling findSimilar( const WordVector&, int,double,bool)const'. More...
 
virtual std::vector
< VectorQueryResult
findSimilar (const std::string &type, const WordVector &vec, int maxNofResults, double minSimilarity, bool realVecWeights) const =0
 Find all features that are within maximum simiarity distance. More...
 
virtual
VectorStorageTransactionInterface
createTransaction ()=0
 Create an insert/update transaction object. More...
 
virtual std::vector< std::string > types () const =0
 Get the list of types defined. More...
 
virtual ValueIteratorInterfacecreateFeatureValueIterator () const =0
 Create an iterator on the feature values inserted. More...
 
virtual std::vector< std::string > featureTypes (const std::string &featureValue) const =0
 Get the list of types assigned to a specific featureValue. More...
 
virtual int nofVectors (const std::string &type) const =0
 Get the number of vectors defined for the features of a type. More...
 
virtual WordVector featureVector (const std::string &type, const std::string &featureValue) const =0
 Get the vector assigned to a feature value. More...
 
virtual double vectorSimilarity (const WordVector &v1, const WordVector &v2) const =0
 Calculate a value between 0.0 and 1.0 representing the similarity of two vectors. More...
 
virtual WordVector normalize (const WordVector &vec) const =0
 Calculate the normalized vector representation of the argument vector. More...
 
virtual std::string config () const =0
 Get the configuration of this storage. More...
 
virtual void close ()=0
 Close client connection and eventually do some cleanup. More...
 

Detailed Description

Interface to a repository for vectors representing word embeddings.

Constructor & Destructor Documentation

virtual strus::VectorStorageClientInterface::~VectorStorageClientInterface ( )
inlinevirtual

Destructor.

Member Function Documentation

virtual void strus::VectorStorageClientInterface::close ( )
pure virtual

Close client connection and eventually do some cleanup.

Remarks
This method is not implicitely called with the destructor because it might be a complicated operation that cannot be afforded in panic shutdown.
Note
the method does not have to be called necessarily.
it calls compactDatabase of the underlying database and can therefore last some time (some minutes in case of leveldb after large inserts).
virtual std::string strus::VectorStorageClientInterface::config ( ) const
pure virtual

Get the configuration of this storage.

Returns
the configuration string
virtual ValueIteratorInterface* strus::VectorStorageClientInterface::createFeatureValueIterator ( ) const
pure virtual

Create an iterator on the feature values inserted.

Returns
the iterator
virtual VectorStorageTransactionInterface* strus::VectorStorageClientInterface::createTransaction ( )
pure virtual

Create an insert/update transaction object.

Returns
the created transaction interface (with ownership)
Note
this function is thread safe, multiple concurrent transactions are allowed
virtual std::vector<std::string> strus::VectorStorageClientInterface::featureTypes ( const std::string &  featureValue) const
pure virtual

Get the list of types assigned to a specific featureValue.

Parameters
[in]featureValuefeature value to get the types assigned to
Returns
the list of types assigned to 'featureValue'
virtual WordVector strus::VectorStorageClientInterface::featureVector ( const std::string &  type,
const std::string &  featureValue 
) const
pure virtual

Get the vector assigned to a feature value.

Parameters
[in]typetype of the feature
[in]featureValuevalue of the feature
Returns
the vector assinged to this feature
virtual std::vector<VectorQueryResult> strus::VectorStorageClientInterface::findSimilar ( const std::string &  type,
const WordVector vec,
int  maxNofResults,
double  minSimilarity,
bool  realVecWeights 
) const
pure virtual

Find all features that are within maximum simiarity distance.

Parameters
[in]typetype of the features to search for
[in]vecvector to search similar features of
[in]maxNofResultslimits the number of results returned
[in]minSimilarityvalue between 0.0 and 1.0 specifying the minimum similarity a result should have
[in]realVecWeightstrue if to calculate the real vector weights and diffs for the best matches and not an approximate value (e.g. the similarity estimation derived from the LSH bits differing)
virtual int strus::VectorStorageClientInterface::nofVectors ( const std::string &  type) const
pure virtual

Get the number of vectors defined for the features of a type.

Parameters
[in]typename of the type
Returns
the number of vectors
virtual WordVector strus::VectorStorageClientInterface::normalize ( const WordVector vec) const
pure virtual

Calculate the normalized vector representation of the argument vector.

virtual void strus::VectorStorageClientInterface::prepareSearch ( const std::string &  type)
pure virtual

Prepare datastructures for calling findSimilar( const WordVector&, int,double,bool)const'.

Remarks
This method does not have to be called, because the structures for search are built implicitely on the first search. It just avoids a massive delay on the first call of find similar.
Parameters
[in]typetype of the features to search for
virtual std::vector<std::string> strus::VectorStorageClientInterface::types ( ) const
pure virtual

Get the list of types defined.

Returns
the list
virtual double strus::VectorStorageClientInterface::vectorSimilarity ( const WordVector v1,
const WordVector v2 
) const
pure virtual

Calculate a value between 0.0 and 1.0 representing the similarity of two vectors.

Parameters
[in]v1first input vector
[in]v2second input vector
Returns
the similarity measure

The documentation for this class was generated from the following file: