src/Chinese/edt/ch_DescLinkFunctions.cpp
// Note: should probably store the modifiers for each entity (and mention?), so we don't have to keep
// recalculating.  Also should add stop words.

should probably store the modifiers for each entity (and mention?), so we don't have to keep
recalculating.  Also should add stop words.
should probably store the modifiers for each entity ( and mention? ) so we don ' t have to keep recalculating . Also should add stop words .
Symbol ChineseDescLinkFunctions::_getUniqueModifierRatio(Mention *ment, Entity *entity, EntitySet *entitySet) {
	SymbolHash entityWords(50);
	int n_ent_words = 0;
	int unique = 0;
	int total = 0;
	Symbol entityMentWords[20];
	for (int i = 0; i < entity->getNMentions(); i++) {
		Mention *entityMent = entitySet->getMention(entity->getMention(i));
		int n_words = entityMent->getNode()->getTerminalSymbols(entityMentWords, 20);
		for (int j = 0; j < n_words; j++) {
			if (_stopWords->lookup(entityMentWords[j]))
				continue;
			if (! entityWords.lookup(entityMentWords[j])) {
				entityWords.add(entityMentWords[j]);
				n_ent_words++;
			}
		}
	}
	Symbol mentionWords[20];
	int n_ment_words = ment->getNode()->getTerminalSymbols(mentionWords, 20);
	if (n_ment_words == 1)
		return Symbol(L"u[0.0]");
	if (n_ent_words == 0)
		return Symbol(L"u[1.0]");
	for (int k = 0; k < n_ment_words; k++) {
		if (_stopWords->lookup(mentionWords[k]))
			continue;
		if (mentionWords[k] == ment->getHead()->getHeadWord())
			continue;
		if (! entityWords.lookup(mentionWords[k]))
			unique++;
		total++;
	}
	double ratio = (double)unique/(double)total;
	if (ratio == 0.0)
		return Symbol(L"u[0.0]");
	else if (ratio < 0.25)
		return Symbol(L"u[<.25]");
	else if (ratio < 0.5)
		return Symbol(L"u[<.5]");
	else if (ratio < 0.75)
		return Symbol(L"u[<.75]");
	else if (ratio < 1.0)
		return Symbol(L"u[<1.0]");
	else
		return Symbol(L"u[1.0]");
}
Symbol ChineseDescLinkFunctions :: _getUniqueModifierRatio ( Mention * ment , Entity * entity , EntitySet * entitySet ) { SymbolHash entityWords ( 50 ) ; int n_ent_words = 0 ; int unique = 0 ; int total = 0 ; Symbol entityMentWords [ 20 ] ; for ( int i = 0 ; i < entity -> getNMentions ( ) ; i ++ ) { Mention * entityMent = entitySet -> getMention ( entity -> getMention ( i ) ) ; int n_words = entityMent -> getNode ( ) -> getTerminalSymbols ( entityMentWords , 20 ) ; for ( int j = 0 ; j < n_words ; j ++ ) { if ( _stopWords -> lookup ( entityMentWords [ j ] ) ) continue ; if ( ! entityWords . lookup ( entityMentWords [ j ] ) ) { entityWords . add ( entityMentWords [ j ] ) ; n_ent_words ++ ; } } } Symbol mentionWords [ 20 ] ; int n_ment_words = ment -> getNode ( ) -> getTerminalSymbols ( mentionWords , 20 ) ; if ( n_ment_words == 1 ) return Symbol ( L" " ) ; if ( n_ent_words == 0 ) return Symbol ( L" " ) ; for ( int k = 0 ; k < n_ment_words ; k ++ ) { if ( _stopWords -> lookup ( mentionWords [ k ] ) ) continue ; if ( mentionWords [ k ] == ment -> getHead ( ) -> getHeadWord ( ) ) continue ; if ( ! entityWords . lookup ( mentionWords [ k ] ) ) unique ++ ; total ++ ; } double ratio = ( double ) unique / ( double ) total ; if ( ratio == 0.0 ) return Symbol ( L" " ) ; else if ( ratio < 0.25 ) return Symbol ( L" " ) ; else if ( ratio < 0.5 ) return Symbol ( L" " ) ; else if ( ratio < 0.75 ) return Symbol ( L" " ) ; else if ( ratio < 1.0 ) return Symbol ( L" " ) ; else return Symbol ( L" " ) ; }
Note: should probably store the modifiers for each entity (and mention?
Note : should probably store the modifiers for each entity ( and mention?
// collect Entity words
 // JCS - 03/08/04 - Don't want this to count against a link if modifier occured in head word of ent
 //if (entityMentWords[j] == entityMent->getHead()->getHeadWord())
 //	continue;
 // collect Mention words
