void Actor::releaseActionEffectors(Action* action,const EffectorIDVector& effectorIDs) { for (size_t i=0;i<effectorIDs.size();i++) { Effector* effector = getEffector(effectorIDs[i]); GB_ASSERT(effector, format("Actor::getEffector: actor doesn't have effector %s", Effector::convertToString(effectorIDs[i]))); Actions children; effector->getDirectChildren(action, children); GB_ASSERT(children.empty(), "Actor::releaseActionEffectors: action isn't allowed to have children on effector at this moment"); Actions becameActive; effector->removeAction(action,becameActive); for(size_t j=0; j<becameActive.size(); j++) { m_activatedEffectors[becameActive[j]].push_back(effectorIDs[i]); } } }
/// Make some consistent parse decision. /// Randomly choose some consistent action, and perform it. /// \param state The state in which the parse decision should be made. /// \todo Allow classifier to confidence-rate actions, and choose highest rated /// action to perform? void Parser::make_consistent_decision(ParseState& state) { assert(!parameter::treebank_has_parse_paths()); Actions actions = state.consistent_actions(); assert(!actions.empty()); if (parameter::parse_left_to_right() || parameter::parse_right_to_left()) { assert(actions.size() == 1); } // Randomly choose some consistent action. Action action = actions.at(ParsePathRandom.get(actions.size())); //Action action = this->best_action(state, actions); Debug::log(5) << "Performing: " << action.to_string() << "\n"; state.perform(action); // FIXME: Don't necessarily use _parse_span_chart. _parse_span_chart.subtract(SpanItem(action), _parse_prc, _parse_rcl, _parse_cbs); }
/// Make some parse decision. /// We find all possible actions at the current parse state. /// We choose some action, and perform it. /// \param state The state in which the parse decision should be made. /// \param output_threshold If the absolute value of the /// confidence of the chosen decision is at least output_threshold, /// then we will output the pre- and post-decision states to /// Debug::log(3). /// \return True iff the action performed is already in the parse /// chart. This can be used to detect the first inconsistent /// decision, but no subsequent inconsistencies. bool Parser::make_decision(ParseState& state, double output_threshold) { Actions actions = state.legal_actions(); assert(!actions.empty()); pair<Action, double> p = this->best_action(state, actions); Action action = p.first; double conf= p.second; bool debugout = false; if (fabs(conf) >= output_threshold) debugout = true; if (debugout) Debug::log(3) << "PRE (conf=" << conf << "): " << state.to_string() << "\n"; else Debug::log(5) << "Performing: " << action.to_string() << "\n"; bool ret = state.perform(action, true); if (debugout) Debug::log(3) << "POST (conf=" << conf << ", ret=" << ret << "): " << state.to_string() << "\n"; // FIXME: Don't necessarily use _parse_span_chart. _parse_span_chart.subtract(SpanItem(action), _parse_prc, _parse_rcl, _parse_cbs); return ret; }