src/Generic/relations/discmodel/RelationObservation.cpp
// to improve relation model's performance when using NP chunk
// added on 20071126
// diff from original: not use TWO_PREMODS feature

to improve relation model's performance when using NP chunk
added on 20071126
diff from original: not use TWO_PREMODS feature
to improve relation model ' s performance when using NP chunk added on 20071126 diff from original : not use TWO_PREMODS feature
void RelationObservation::findWordsBetween() {
	_wordsBetweenMentions = CONFUSED;
	_posBetweenMentions = CONFUSED;
	_stemmedWBMentions = CONFUSED;
	if (SerifVersion::isEnglish()) {
		if (_sentenceInfo->entitySets[0] &&
			_m1->getNode()->getParent() == _m2->getNode()->getParent() &&
			_m1->getParent() == 0 && _m2->getParent() == 0)
		{
			bool title_case = false;
			if (_m1->getNode()->getParent()->hasMention()) {
				const Mention *parentMent 
					= _sentenceInfo->mentionSets[0]->getMentionByNode(_m1->getNode()->getParent());
				if (parentMent->getEntityType().isRecognized()) {
					Entity *parentEnt = _sentenceInfo->entitySets[0]->getEntityByMention(parentMent->getUID(),parentMent->getEntityType());
					Entity *m1Ent = _sentenceInfo->entitySets[0]->getEntityByMention(_m1->getUID(),_m1->getEntityType());
					Entity *m2Ent = _sentenceInfo->entitySets[0]->getEntityByMention(_m2->getUID(),_m2->getEntityType());
					if (parentEnt != 0 && (parentEnt == m1Ent || parentEnt == m2Ent))
						title_case = true;
				}
			}
			if (!_npchunkFeatures) {
				if (!title_case) {
					_wordsBetweenMentions = L"TWO_PREMODS";
					_posBetweenMentions = L"TWO_PREMODS";
					_stemmedWBMentions = L"TWO_PREMODS";
					return;
				}
			}
		}
	}
	if (_npchunkFeatures) {
		int end1 = _m1->getNode()->getEndToken();
		int start2=_m2->getNode()->getStartToken();
		if (end1+1 == start2 && _m2->getNode()->getFirstTerminal()->getHeadWord() == Symbol(L"'s")){
			const SynNode* node1 = _m1->getNode()->getHeadPreterm();
			const SynNode* node2 = _m2->getNode()->getHeadPreterm();
			makeWBSymbol(node1->getEndToken() + 1, node2->getStartToken());
			return;
		}
	}
	if (_m1->getNode()->getEndToken() < _m2->getNode()->getStartToken()) {
		makeWBSymbol(_m1->getNode()->getEndToken() + 1, _m2->getNode()->getStartToken());
		return;
	} 
	const SynNode* node1 = _m1->getNode()->getHeadPreterm();
	const SynNode* node2 = _m2->getNode()->getHeadPreterm();
	if (node1 != _m1->getNode())
		node1 = _m1->getNode()->getHeadPreterm()->getParent();
	if (node2 != _m2->getNode())
		node2 = _m2->getNode()->getHeadPreterm()->getParent();
	if (node1->getEndToken() < node2->getStartToken()) {
		makeWBSymbol(node1->getEndToken() + 1, node2->getStartToken());
		return;
	} 
	const SynNode *temp = node2;
	node2 = _m2->getNode()->getHeadPreterm();
	if (node1->getEndToken() < node2->getStartToken()) {
		makeWBSymbol(node1->getEndToken() + 1, node2->getStartToken());
		return;
	} 
	node2 = temp;
	node1 = _m1->getNode()->getHeadPreterm();
	if (node1->getEndToken() < node2->getStartToken()) {
		makeWBSymbol(node1->getEndToken() + 1, node2->getStartToken());
		return;
	} 
	node2 = _m2->getNode()->getHeadPreterm();
	if (node1->getEndToken() < node2->getStartToken()) {
		makeWBSymbol(node1->getEndToken() + 1, node2->getStartToken());
		return;
	} 
}
void RelationObservation :: findWordsBetween ( ) { _wordsBetweenMentions = CONFUSED ; _posBetweenMentions = CONFUSED ; _stemmedWBMentions = CONFUSED ; if ( SerifVersion :: isEnglish ( ) ) { if ( _sentenceInfo -> entitySets [ 0 ] && _m1 -> getNode ( ) -> getParent ( ) == _m2 -> getNode ( ) -> getParent ( ) && _m1 -> getParent ( ) == 0 && _m2 -> getParent ( ) == 0 ) { bool title_case = false ; if ( _m1 -> getNode ( ) -> getParent ( ) -> hasMention ( ) ) { const Mention * parentMent = _sentenceInfo -> mentionSets [ 0 ] -> getMentionByNode ( _m1 -> getNode ( ) -> getParent ( ) ) ; if ( parentMent -> getEntityType ( ) . isRecognized ( ) ) { Entity * parentEnt = _sentenceInfo -> entitySets [ 0 ] -> getEntityByMention ( parentMent -> getUID ( ) , parentMent -> getEntityType ( ) ) ; Entity * m1Ent = _sentenceInfo -> entitySets [ 0 ] -> getEntityByMention ( _m1 -> getUID ( ) , _m1 -> getEntityType ( ) ) ; Entity * m2Ent = _sentenceInfo -> entitySets [ 0 ] -> getEntityByMention ( _m2 -> getUID ( ) , _m2 -> getEntityType ( ) ) ; if ( parentEnt != 0 && ( parentEnt == m1Ent || parentEnt == m2Ent ) ) title_case = true ; } } if ( ! _npchunkFeatures ) { if ( ! title_case ) { _wordsBetweenMentions = L" " ; _posBetweenMentions = L" " ; _stemmedWBMentions = L" " ; return ; } } } } if ( _npchunkFeatures ) { int end1 = _m1 -> getNode ( ) -> getEndToken ( ) ; int start2 = _m2 -> getNode ( ) -> getStartToken ( ) ; if ( end1 + 1 == start2 && _m2 -> getNode ( ) -> getFirstTerminal ( ) -> getHeadWord ( ) == Symbol ( L" " ) ) { const SynNode * node1 = _m1 -> getNode ( ) -> getHeadPreterm ( ) ; const SynNode * node2 = _m2 -> getNode ( ) -> getHeadPreterm ( ) ; makeWBSymbol ( node1 -> getEndToken ( ) + 1 , node2 -> getStartToken ( ) ) ; return ; } } if ( _m1 -> getNode ( ) -> getEndToken ( ) < _m2 -> getNode ( ) -> getStartToken ( ) ) { makeWBSymbol ( _m1 -> getNode ( ) -> getEndToken ( ) + 1 , _m2 -> getNode ( ) -> getStartToken ( ) ) ; return ; } const SynNode * node1 = _m1 -> getNode ( ) -> getHeadPreterm ( ) ; const SynNode * node2 = _m2 -> getNode ( ) -> getHeadPreterm ( ) ; if ( node1 != _m1 -> getNode ( ) ) node1 = _m1 -> getNode ( ) -> getHeadPreterm ( ) -> getParent ( ) ; if ( node2 != _m2 -> getNode ( ) ) node2 = _m2 -> getNode ( ) -> getHeadPreterm ( ) -> getParent ( ) ; if ( node1 -> getEndToken ( ) < node2 -> getStartToken ( ) ) { makeWBSymbol ( node1 -> getEndToken ( ) + 1 , node2 -> getStartToken ( ) ) ; return ; } const SynNode * temp = node2 ; node2 = _m2 -> getNode ( ) -> getHeadPreterm ( ) ; if ( node1 -> getEndToken ( ) < node2 -> getStartToken ( ) ) { makeWBSymbol ( node1 -> getEndToken ( ) + 1 , node2 -> getStartToken ( ) ) ; return ; } node2 = temp ; node1 = _m1 -> getNode ( ) -> getHeadPreterm ( ) ; if ( node1 -> getEndToken ( ) < node2 -> getStartToken ( ) ) { makeWBSymbol ( node1 -> getEndToken ( ) + 1 , node2 -> getStartToken ( ) ) ; return ; } node2 = _m2 -> getNode ( ) -> getHeadPreterm ( ) ; if ( node1 -> getEndToken ( ) < node2 -> getStartToken ( ) ) { makeWBSymbol ( node1 -> getEndToken ( ) + 1 , node2 -> getStartToken ( ) ) ; return ; } }
to improve relation model's performance when using NP chunk
added on 20071126
diff from original: not use TWO_PREMODS feature
to improve relation model ' s performance when using NP chunk added on 20071126 diff from original : not use TWO_PREMODS feature
// this is bad form, and should be fixed later
 //#ifdef ENGLISH_LANGUAGE
 // when we are dealing with two premodifiers, we should deal with this differently
 //#endif
 // option 1
 // option 2
 /*
			_wordsBetweenMentions = Symbol(L"'s");
			_posBetweenMentions = Symbol(L"POS");
			_stemmedWBMentions = Symbol(L"'s");
			*/ //std::cerr << _m1->getNode()->toDebugTextString() << " ~ " << _m2->getNode()->toDebugTextString() << "\n";
 //std::cerr << node1->toDebugTextString() << " ~ " << node2->toDebugTextString() << "\n";
 //std::cerr << _m1->getMentionType() << " " << _m2->getMentionType() << "\n\n";
