📄 eventspacebase.h
字号:
//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, Yusuke Miyao/// You may distribute under the terms of the Artistic License.////// <id>$Id: EventSpaceBase.h,v 1.7 2003/05/16 05:29:08 yusuke Exp $</id>/// <collection>Maximum Entropy Estimator</collection>/// <name>EventSpaceBase.h</name>/// <overview>A base class for an event space in ME Model</overview>/////////////////////////////////////////////////////////////////////////#ifndef Amis_EventSpaceBase_h_#define Amis_EventSpaceBase_h_#include <amis/configure.h>#include <amis/Event.h>#include <memory>AMIS_NAMESPACE_BEGIN///////////////////////////////////////////////////////////////////////// <classdef>/// <name>EventSpaceBase</name>/// <overview>A base class for implementation of a set of events</overview>/// <desc>A set of all possible events in the task</desc>/// <body>class EventSpaceBase {private: int num_events; int num_feature_lists; EventFreq sum_event_count; mutable bool is_dirty; mutable Real event_empirical_expectation;protected: void incNumEvents( void ) { ++num_events; } /// Increment a number of events void incNumFeatureLists( int n ) { num_feature_lists += n; } /// Increment a number of feature lists void incSumEventCount( EventFreq c ) { sum_event_count += c; is_dirty = true; } /// Increment a sum of event countspublic: EventSpaceBase( void ) { num_events = 0; num_feature_lists = 0; sum_event_count = 0; is_dirty = true; event_empirical_expectation = 0.0; } virtual ~EventSpaceBase() {} virtual int numEvents( void ) const { return num_events; } /// Get a number of events in the event space (not the sum of event counts) virtual int numFeatureLists( void ) const { return num_feature_lists; } /// Get a number of feature lists in the event space virtual EventFreq sumEventCount( void ) const { return sum_event_count; } /// Get a sum of event counts virtual Real eventEmpiricalExpectation( void ) const { if ( is_dirty ) { event_empirical_expectation = 1.0 / static_cast< Real >( sum_event_count ); is_dirty = false; } AMIS_DEBUG_MESSAGE(3, "eventEmpiricalExpectation()=" << event_empirical_expectation << '\n' << std::flush); return event_empirical_expectation; } /// Get an empirical expectation of an eventpublic: virtual const std::string eventSpaceName( void ) const = 0; /// Get the name of this class /* virtual bool setProducts(std::istream& is, std::vector<Real>& prod ) const { /// dummy implementation AMIS_ABORT("This is dummy EventSpaceBase::setProducts()" ); return false; } /// API for runtime prediction virtual bool setProductsFix(const std::vector< std::pair<Name, Real> >& feats, std::vector< std::pair<Name,Real> >& to ) const { /// if clear_to == ture then to[i] is initialized to 1.0 /// dummy implementation AMIS_ABORT("This is dummy EventSpaceBase::setProductsFix()" ); return false; } virtual bool setProductsFixPacked( const std::vector< std::pair<Name, Real> >& static_feats, const std::vector < std::vector< std::pair<Name,Real> > >& dynamic_feats_vec, std::vector< std::vector< std::pair<Name,Real> > >& to ) const { /// dummy implementation AMIS_ABORT("This is dummy EventSpaceBase::setProductsFixKernel()" ); return false; } */};/// </body>/// </classdef>typedef std::auto_ptr< EventSpaceBase > EventSpacePtr;AMIS_NAMESPACE_END#endif // EventSpaceBase_h_// end of EventSpaceBase.h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -