FunctionalWeight.hpp

Go to the documentation of this file.
00001 #ifndef wali_wfa_epr_FUNCTIONAL_WEIGHT_GUARD
00002 #define wali_wfa_epr_FUNCTIONAL_WEIGHT_GUARD 1
00003 
00004 /*!
00005  * @author Akash Lal
00006  */
00007 
00008 #include "wali/wfa/ITrans.hpp"
00009 #include "wali/SemElem.hpp"
00010 
00011 namespace wali {
00012   namespace wfa {
00013     namespace epr {
00014 
00015       /*! 
00016        * @class FunctionalWeight
00017        * @brief Functional weights for representing error-projection automaton
00018        *
00019        * This class provides functional weights that are used in the
00020        * automaton for representing the error projection operation.
00021        * This class is not a semiring, and cannot be used freely as one (even
00022        * though the type system allows this). There are no
00023        * combine and extend operation.
00024        */
00025 
00026       class FunctionalWeight : public SemElem {
00027       public:
00028         //FunctionalWeight();
00029         FunctionalWeight(ITrans *l, ITrans *r);
00030         virtual ~FunctionalWeight();
00031 
00032         //////////////////////
00033         // Semiring operations
00034         //////////////////////
00035 
00036         sem_elem_t one() const;
00037         sem_elem_t zero() const;
00038         sem_elem_t extend(SemElem *se);
00039         sem_elem_t combine(SemElem *se);
00040         bool equal(SemElem *se) const;
00041 
00042         std::ostream &print(std::ostream &o) const;
00043 
00044         //////////////////////
00045         // Apply functional
00046         //////////////////////
00047 
00048         // return left \extend se \extend right
00049         TaggedWeight apply(TaggedWeight tw);
00050 
00051       private:
00052         // normalization operation
00053         void normalize();
00054 
00055         // The functional weight is \lambda x. (left \extend x \extend right)
00056         ITrans *ltrans, *rtrans;
00057       };
00058     } // namespace epr
00059   } // namespace wfa
00060 } // namespace wali
00061 
00062 #endif // wali_wfa_epr_FUNCTIONAL_WEIGHT_GUARD