00001 #ifndef IRI_RULE_LEARNER_SYMBOLS_H 00002 #define IRI_RULE_LEARNER_SYMBOLS_H 1 00003 00004 #include <iri_rule_learner/RuleLearnerConfig.h> 00005 #include <fstream> 00006 00007 static const std::string DUMMY_ACTION_NAME = "dummyAction"; 00008 static const std::string DEFAULT_ACTION_NAME = "default"; 00009 00010 class Symbol 00011 { 00012 public: 00013 std::string name_; 00014 std::vector<std::string> param_names_; 00015 00016 Symbol() {} 00017 00018 Symbol(std::string line); 00019 00020 Symbol(std::string name, std::vector<std::string> param_names) : 00021 name_(name), 00022 param_names_(param_names) 00023 { } 00024 00025 bool has_name(std::string name); 00026 00027 bool has_param_name(std::string param); 00028 00029 bool has_param_names_in(std::vector<std::string> params); 00030 00031 bool exists(); 00032 00033 friend bool operator== (Symbol &s1, Symbol &s2); 00034 friend std::ostream& operator<<(std::ostream &out, const Symbol &s); 00035 }; 00036 00037 // utils 00038 bool compare_vector_strings(std::vector<std::string> v1, std::vector<std::string> v2); 00039 char choose_variable_separator(std::string str); 00040 std::string trim(const std::string& str, const std::string& whitespace = " \t"); 00041 template <typename T> 00042 void remove_duplicates(std::vector<T>& vec) 00043 { 00044 std::sort(vec.begin(), vec.end()); 00045 vec.erase(std::unique(vec.begin(), vec.end()), vec.end()); 00046 } 00047 00048 // get data from string 00049 Symbol get_symbol_from_string(std::string line); 00050 std::string get_symbol_name_from_string(std::string line); 00051 std::vector< std::string > get_symbol_param_names_from_string(std::string line); 00052 00053 #endif