From 26235c2770f10fc6975a06fd3a8167cbd23029a9 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Mon, 25 Nov 2013 00:14:16 -0500 Subject: remove dead code, add adagrad crf learner --- decoder/ff_factory.h | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) (limited to 'decoder/ff_factory.h') diff --git a/decoder/ff_factory.h b/decoder/ff_factory.h index bfdd3257..1aa8e55f 100644 --- a/decoder/ff_factory.h +++ b/decoder/ff_factory.h @@ -1,8 +1,6 @@ #ifndef _FF_FACTORY_H_ #define _FF_FACTORY_H_ -// FsaF* vs F* (regular ff/factory). - //TODO: use http://www.boost.org/doc/libs/1_43_0/libs/functional/factory/doc/html/index.html ? /*TODO: register state identity separately from feature function identity? as @@ -25,13 +23,15 @@ class FeatureFunction; class FsaFeatureFunction; -struct UntypedFactory { +class UntypedFactory { + public: virtual ~UntypedFactory(); virtual std::string usage(bool params,bool verbose) const = 0; }; template -struct FactoryBase : public UntypedFactory { +class FactoryBase : public UntypedFactory { + public: typedef FF F; typedef boost::shared_ptr FP; @@ -40,7 +40,8 @@ struct FactoryBase : public UntypedFactory { /* see cdec_ff.cc for example usage: this create concrete factories to be registered */ template -struct FFFactory : public FactoryBase { +class FFFactory : public FactoryBase { + public: FP Create(std::string param) const { FF *ret=new FF(param); return FP(ret); @@ -51,18 +52,6 @@ struct FFFactory : public FactoryBase { }; -// same as above, but we didn't want to require a typedef e.g. Parent in FF class, and template typedef isn't available -template -struct FsaFactory : public FactoryBase { - FP Create(std::string param) const { - FF *ret=new FF(param); - return FP(ret); - } - virtual std::string usage(bool params,bool verbose) const { - return FF::usage(params,verbose); - } -}; - struct UntypedFactoryRegistry { std::string usage(std::string const& ffname,bool params=true,bool verbose=true) const; bool have(std::string const& ffname); @@ -70,7 +59,6 @@ struct UntypedFactoryRegistry { void Register(const std::string& ffname, UntypedFactory* factory); void Register(UntypedFactory* factory); void clear(); - static bool parse_debug(std::string & param_in_out); // returns true iff param starts w/ debug (and remove that prefix from param) protected: typedef boost::shared_ptr FactoryP; typedef std::map Factmap; @@ -92,26 +80,16 @@ struct FactoryRegistry : public UntypedFactoryRegistry { Factmap::const_iterator it = reg_.find(ffname); if (it == reg_.end()) throw std::runtime_error("I don't know how to create feature "+ffname); - bool debug=parse_debug(param); - if (debug) - cerr<<"debug enabled for "<(*it->second).Create(param); return res; } }; typedef FactoryRegistry FFRegistry; -typedef FactoryRegistry FsaFFRegistry; -extern FsaFFRegistry fsa_ff_registry; -inline FsaFFRegistry & global_fsa_ff_registry() { return fsa_ff_registry; } extern FFRegistry ff_registry; -inline FFRegistry & global_ff_registry() { return ff_registry; } +inline FFRegistry& global_ff_registry() { return ff_registry; } -void ff_usage(std::string const& name,std::ostream &out=std::cout); +void ff_usage(std::string const& name,std::ostream& out=std::cerr); -/* -extern boost::shared_ptr global_fsa_ff_registry; -extern boost::shared_ptr global_ff_registry; -*/ #endif -- cgit v1.2.3