src/LearnIt/MatchInfo.cpp
/** The only slot constrain enforced right now is that slots which say
  * that they must corefer in fact do */
The only slot constrain enforced right now is that slots which say
that they must corefer in fact do
The only slot constrain enforced right now is that slots which say that they must corefer in fact do
bool MatchInfo::_satisfiesSlotPairConstraints(
	const std::vector<SlotFiller_ptr>& slot_fillers,
	const std::vector<SlotPairConstraints_ptr>& constraints)
{
	typedef std::pair<int, int> IntPair;
	BOOST_FOREACH(const SlotPairConstraints_ptr& constraint, constraints) {
		if (!constraint->mustCorefer() && !constraint->mustNotCorefer()) continue;
		if (std::max(constraint->first(), constraint->second()) 
			> slot_fillers.size()) 
		{
			throw UnexpectedInputException("MatchInfo::_satisfiesSlotPairConstraints",
                                "Invalid slot number in constraint");
		}
		const Entity* e1=slot_fillers[constraint->first()]->getMentionEntity();
		const Entity* e2=slot_fillers[constraint->second()]->getMentionEntity();
		if (constraint->mustCorefer() && !(e1 && e2 && e1==e2)) {
			return false;
		}
		else if (constraint->mustNotCorefer() && (e1 && e2 && e1==e2)) {
			return false;
		}
	}
	return true;
}
bool MatchInfo :: _satisfiesSlotPairConstraints ( const std :: vector < SlotFiller_ptr > & slot_fillers , const std :: vector < SlotPairConstraints_ptr > & constraints ) { typedef std :: pair < int , int > IntPair ; BOOST_FOREACH ( const SlotPairConstraints_ptr & constraint , constraints ) { if ( ! constraint -> mustCorefer ( ) && ! constraint -> mustNotCorefer ( ) ) continue ; if ( std :: max ( constraint -> first ( ) , constraint -> second ( ) ) > slot_fillers . size ( ) ) { throw UnexpectedInputException ( " " , " " ) ; } const Entity * e1 = slot_fillers [ constraint -> first ( ) ] -> getMentionEntity ( ) ; const Entity * e2 = slot_fillers [ constraint -> second ( ) ] -> getMentionEntity ( ) ; if ( constraint -> mustCorefer ( ) && ! ( e1 && e2 && e1 == e2 ) ) { return false ; } else if ( constraint -> mustNotCorefer ( ) && ( e1 && e2 && e1 == e2 ) ) { return false ; } } return true ; }
The only slot constrain enforced right now is that slots which say
 that they must corefer in fact do
The only slot constrain enforced right now is that slots which say that they must corefer in fact do