bool CommandTree::containsCommand$(std::vector<std::string> sentence, std::vector<std::string>& cmd, CommandTree* root) { bool star = false; for(uint i=0; i<sentence.size(); i++){ for(uint j=0; j<children_.size(); j++){ if(sentence[i]==children_[j].element_){ if(sentence[i]==end$){ return true; } else{ cmd.push_back(sentence[i]); std::vector<std::string> subsentence(&sentence[i+1], &sentence[sentence.size()]); return children_[j].containsCommand$(subsentence, cmd, root); } } if(children_[j].element_=="*"){ star = true; } } if(star){ cmd.clear(); std::vector<std::string> subsentence(&sentence[i], &sentence[sentence.size()]); return root->containsCommand$(subsentence, cmd, root); } } cmd.clear(); return false; }
void Sentence::AddSubSentence( const string str ) { shared_ptr<SubSentence> subsentence(new SubSentence(str)); SubSentenceInfo subInfo(str,subsentence); _subInfos.push_back(subInfo); }
void Sentence::AddSubSentence( const std::vector<shared_ptr<DataCollection::Character>> vec ) { shared_ptr<SubSentence> subsentence(new SubSentence(vec)); SubSentenceInfo subInfo(LanguageFunc::ConvertCharacterToString(vec),subsentence); _subInfos.push_back(subInfo); }