src/English/parse/en_LanguageSpecificFunctions.cpp
/* _fixNameCommaNameHeads deals with a very specific situation:
*   (NPA (NPP ...) (, ,) (NPP ...))
* When this was found by the parser as (NPA (NPP ...) (, ,) (NNP oneword)),
* it will understand the head to be the second name, and we need to
* force the first name to be the head.
*
* Normally, we trust the parser on this kind of thing. For example:
*    IBM president George Bush
* will be rightly found as (NPA (NPP ...) (NN president) (NNP George Bush))
* and changed into (NPA (NPP ...) (NN president) (NPP (NNP George) (NNP Bush))
* and it correctly treats the second name as the head.
*
* In most cases where we don't trust the parser, we are dealing with things
* fixed by _fixNPList. The one outstanding case is what occurs in
* "city, state" constructions, and that is fixed here. (EMB 4/1/2003)
*/


Normally, we trust the parser on this kind of thing.

In most cases where we don't trust the parser, we are dealing with things
fixed by _fixNPList. The one outstanding case is what occurs in
"city, state" constructions, and that is fixed here.
Normally we trust the parser on this kind of thing . In most cases where we don ' t trust the parser we are dealing with things fixed by _fixNPList . The one outstanding case is what occurs in " city state " constructions and that is fixed here .
void EnglishLanguageSpecificFunctions::_fixNameCommaNameHeads(ParseNode* node) {
	if (node->label != EnglishSTags::NPA)
		return;
	if (node->premods == 0 || node->premods->label != EnglishSTags::COMMA)
		return;
	if (node->headNode->label != EnglishSTags::NPP)
		return;
	if (node->premods->next == 0 || node->premods->next->label != EnglishSTags::NPP)
		return;
	if (node->premods->next->next != 0)
		return;
	Symbol s = Symbol(node->toWString().c_str());
	s = Symbol(node->headNode->toWString().c_str());
	node->headNode->next = node->postmods;
	ParseNode *old_premods = node->premods;
	ParseNode *old_postmods = node->headNode;
	node->premods = 0;
	node->headNode = old_premods->next;
	old_premods->next = old_postmods;
	node->postmods = old_premods;
}
void EnglishLanguageSpecificFunctions :: _fixNameCommaNameHeads ( ParseNode * node ) { if ( node -> label != EnglishSTags :: NPA ) return ; if ( node -> premods == 0 || node -> premods -> label != EnglishSTags :: COMMA ) return ; if ( node -> headNode -> label != EnglishSTags :: NPP ) return ; if ( node -> premods -> next == 0 || node -> premods -> next -> label != EnglishSTags :: NPP ) return ; if ( node -> premods -> next -> next != 0 ) return ; Symbol s = Symbol ( node -> toWString ( ) . c_str ( ) ) ; s = Symbol ( node -> headNode -> toWString ( ) . c_str ( ) ) ; node -> headNode -> next = node -> postmods ; ParseNode * old_premods = node -> premods ; ParseNode * old_postmods = node -> headNode ; node -> premods = 0 ; node -> headNode = old_premods -> next ; old_premods -> next = old_postmods ; node -> postmods = old_premods ; }
_fixNameCommaNameHeads deals with a very specific situation:
(NPA (NPP ...) (, ,) (NPP ...))
When this was found by the parser as (NPA (NPP ...) (, ,) (NNP oneword)),
it will understand the head to be the second name, and we need to
force the first name to be the head.
_fixNameCommaNameHeads deals with a very specific situation : ( NPA ( NPP ... ) ( ) ( NPP ... )) When this was found by the parser as ( NPA ( NPP ... ) ( ) ( NNP oneword )) it will understand the head to be the second name and we need to force the first name to be the head .
//		std::cerr << "\nfound: " << s.to_debug_string() << "\n";
 //		std::cerr << "headnode: " << s.to_debug_string() << "\n";
