#ifndef _PROFILE_H_ #define _PROFILE_H_ #include #include #include #include #include #include #include #include typedef long long tIid; // type for item ids typedef std::map::value_type tIidSValue; typedef std::map::value_type tIIValue; typedef std::map::value_type tIidSValue; typedef std::map::value_type tIidIValue; typedef std::string File; typedef std::string Relation; typedef int Field; enum ResultType {DERIV, MRS}; class Profile { std::string pname; //profile path //vectors rather than singletons for virtual profiles //single profiles have vector length 1 std::vector profiles; std::vector *> items; std::vector *> inputs; std::vector > *> preferences; std::vector > *> relations; std::vector *> readings; std::map itemToProfile; //keep track of which profile result file we are reading boost::iostreams::filtering_stream resultfilter; std::ifstream resultfile; int resultprofilecount; // set to something > -1 if the preferences are from the top-N results instead of from the gold prefs int autoPrefsTopN; //non-standard variable for training profiles std::vector profileRepCount; //for opening possibly zipped files bool openf(boost::iostreams::filtering_stream &, std::ifstream &, const std::string &); std::string getField(std::string, int); public: Profile(const std::string &pn); ~Profile(); std::string getItem(tIid); std::string getInput(tIid); int getPreference(tIid); void setPreference(tIid &, int &, bool append=false); bool isGold(tIid,int); int numGold(tIid); int getReadings(tIid); void setPrefsFromTopNResults(int top_n = 1); //get next result std::pair,std::string> getResult(ResultType t=DERIV); //get result b for item a std::string getResult(tIid &a, int &b, ResultType t=DERIV); std::string &getPath(); std::set* getItemIDs(); bool isVirtual(); unsigned int getRepsForItem(tIid); void scoreProfile(const std::string &scorefile, bool all=false, int n=1); int topNForAutoPrefs(); // returns the number of top-N results if // we set it to synthesize preferences for eg self-training, // or -1 if we didn't }; #endif