Colibri Core
Public Types | Public Member Functions | Protected Attributes | List of all members
PatternSetModel Class Reference

A pattern model based on an unordered set, does not hold data, only patterns. Very suitable for loading constraint models. More...

#include <patternmodel.h>

Inheritance diagram for PatternSetModel:
PatternSet< uint64_t > PatternModelInterface PatternStore< t_patternset, uint64_t, Pattern > PatternStoreInterface PatternStoreInterface PatternStoreInterface

Public Types

typedef PatternSet< uint64_t >::iterator iterator
 
typedef PatternSet< uint64_t >::const_iterator const_iterator
 
- Public Types inherited from PatternSet< uint64_t >
typedef t_patternset::iterator iterator
 
typedef t_patternset::const_iterator const_iterator
 
- Public Types inherited from PatternStore< t_patternset, uint64_t, Pattern >
typedef t_patternset::iterator iterator
 
typedef t_patternset::const_iterator const_iterator
 

Public Member Functions

 PatternSetModel ()
 
 PatternSetModel (std::istream *f, PatternModelOptions options, PatternModelInterface *constrainmodel=NULL)
 
 PatternSetModel (const std::string &filename, const PatternModelOptions &options, PatternModelInterface *constrainmodel=NULL)
 
virtual int getmodeltype () const
 
virtual int getmodelversion () const
 
virtual size_t size () const
 
virtual bool has (const Pattern &pattern) const
 
virtual bool has (const PatternPointer &pattern) const
 
virtual void load (std::string &filename, const PatternModelOptions &options, PatternModelInterface *constrainmodel=NULL)
 
virtual void load (std::istream *f, const PatternModelOptions &options, PatternModelInterface *constrainmodel=NULL)
 
void write (std::ostream *out)
 
void write (const std::string &filename)
 
PatternModelInterfacegetinterface ()
 
virtual unsigned int occurrencecount (const Pattern &pattern)
 
virtual double frequency (const Pattern &)
 
virtual int maxlength () const
 
virtual int minlength () const
 
virtual unsigned int types ()
 
virtual unsigned int tokens () const
 
unsigned char type () const
 
unsigned char version () const
 
- Public Member Functions inherited from PatternSet< uint64_t >
 PatternSet ()
 
 PatternSet (const ClassDecoder &classdecoder)
 
 PatternSet (const ClassEncoder &classencoder)
 
virtual ~PatternSet ()
 
void insert (const Pattern &pattern)
 
bool has (const Pattern &pattern) const
 
bool has (const PatternPointer &pattern) const
 
size_t size () const
 
void reserve (size_t s)
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
iterator find (const Pattern &pattern)
 
const_iterator find (const Pattern &pattern) const
 
iterator find (const PatternPointer &pattern)
 
const_iterator find (const PatternPointer &pattern) const
 
bool erase (const Pattern &pattern)
 
iterator erase (const_iterator position)
 
void write (std::ostream *out)
 
void read (std::istream *in, int MINLENGTH=0, int MAXLENGTH=999999, PatternStoreInterface *constrainstore=NULL, bool DONGRAMS=true, bool DOSKIPGRAMS=true, bool DOFLEXGRAMS=true)
 
void readmap (std::istream *in, int MINTOKENS=0, int MINLENGTH=0, int MAXLENGTH=999999, PatternStoreInterface *constrainstore=NULL, bool DONGRAMS=true, bool DOSKIPGRAMS=true, bool DOFLEXGRAMS=true)
 
- Public Member Functions inherited from PatternStore< t_patternset, uint64_t, Pattern >
 PatternStore ()
 
virtual ~PatternStore ()
 
virtual void attachcorpus (unsigned char *corpusstart, unsigned int corpussize)
 
virtual void attachcorpus (const IndexedCorpus &corpus)
 
virtual void detachcorpus ()
 
unsigned char * getcorpus () const
 
unsigned int getcorpussize () const
 
virtual void use_v1_format ()
 
virtual PatternStoreInterfacegetstoreinterface ()
 
- Public Member Functions inherited from PatternModelInterface
virtual PatternStoreInterfacegetstoreinterface ()
 
virtual PatternStoreInterfacegetstoreinterface ()
 

Protected Attributes

unsigned char model_type
 
unsigned char model_version
 
uint64_t totaltokens
 
uint64_t totaltypes
 
int maxn
 
int minn
 
- Protected Attributes inherited from PatternSet< uint64_t >
t_patternset data
 
- Protected Attributes inherited from PatternStore< t_patternset, uint64_t, Pattern >
unsigned char * corpusstart
 
unsigned int corpussize
 
unsigned char classencodingversion
 
int patterntype
 

Detailed Description

A pattern model based on an unordered set, does not hold data, only patterns. Very suitable for loading constraint models.

Member Typedef Documentation

Constructor & Destructor Documentation

PatternSetModel::PatternSetModel ( )
inline

Empty constructor

PatternSetModel::PatternSetModel ( std::istream *  f,
PatternModelOptions  options,
PatternModelInterface constrainmodel = NULL 
)
inline

Load a PatternSetModel from stream

Parameters
optionsThe options for loading
constrainmodelLoad only patterns that occur in this model
PatternSetModel::PatternSetModel ( const std::string &  filename,
const PatternModelOptions options,
PatternModelInterface constrainmodel = NULL 
)
inline

Load a PatternSetModel from file

Parameters
filenameThe name of the file to load
optionsThe options for loading
constrainmodelLoad only patterns that occur in this model

Member Function Documentation

virtual double PatternSetModel::frequency ( const Pattern )
inlinevirtual

This function does not perform anything in a set context, it always returns zero

Implements PatternModelInterface.

PatternModelInterface* PatternSetModel::getinterface ( )
inline

Get the interface (just a basic typecast)

virtual int PatternSetModel::getmodeltype ( ) const
inlinevirtual

Get the type of the model

Returns
ModelType

Implements PatternModelInterface.

virtual int PatternSetModel::getmodelversion ( ) const
inlinevirtual

Get the version number of the model

Implements PatternModelInterface.

virtual bool PatternSetModel::has ( const Pattern ) const
inlinevirtual

Does the pattern occur in the pattern store?

Implements PatternStoreInterface.

virtual bool PatternSetModel::has ( const PatternPointer ) const
inlinevirtual

Does the pattern occur in the pattern store?

Implements PatternStoreInterface.

virtual void PatternSetModel::load ( std::string &  filename,
const PatternModelOptions options,
PatternModelInterface constrainmodel = NULL 
)
inlinevirtual

Load a PatternSetModel from file

Parameters
filenameThe name of the file to load
optionsThe options for loading
constrainmodelLoad only patterns that occur in this model
virtual void PatternSetModel::load ( std::istream *  f,
const PatternModelOptions options,
PatternModelInterface constrainmodel = NULL 
)
inlinevirtual

Load a PatternSetModel from stream

Parameters
optionsThe options for loading
constrainmodelLoad only patterns that occur in this model
virtual int PatternSetModel::maxlength ( ) const
inlinevirtual

Return the maximum length of patterns in this model

Implements PatternModelInterface.

virtual int PatternSetModel::minlength ( ) const
inlinevirtual

Return the minimum length of patterns in this model

Implements PatternModelInterface.

virtual unsigned int PatternSetModel::occurrencecount ( const Pattern pattern)
inlinevirtual

This function does not perform anything in a set context, it always returns zero

Implements PatternModelInterface.

virtual size_t PatternSetModel::size ( ) const
inlinevirtual

How many patterns are in the pattern store?

Implements PatternStoreInterface.

virtual unsigned int PatternSetModel::tokens ( ) const
inlinevirtual

Returns the total amount of tokens in the original corpus, includes tokens not covered by the model!

Implements PatternModelInterface.

unsigned char PatternSetModel::type ( ) const
inline

Returns the type of the model, value is of the PatternType enumeration.

virtual unsigned int PatternSetModel::types ( )
inlinevirtual

Returns the total amount of unigram/word types in the original corpus, includes types not covered by the model!

Implements PatternModelInterface.

unsigned char PatternSetModel::version ( ) const
inline

Returns the version of the model's implementation and binary serialisation format.

void PatternSetModel::write ( std::ostream *  out)
inlinevirtual

Write a PatternSetModel to an output stream

Implements PatternStore< t_patternset, uint64_t, Pattern >.

void PatternSetModel::write ( const std::string &  filename)
inline

Write a PatternSetModel to an output file. This is a wrapper around write(std::ostream *)

Member Data Documentation

int PatternSetModel::maxn
protected
int PatternSetModel::minn
protected
unsigned char PatternSetModel::model_type
protected
unsigned char PatternSetModel::model_version
protected
uint64_t PatternSetModel::totaltokens
protected
uint64_t PatternSetModel::totaltypes
protected

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