src/Generic/theories/SentenceTheory.cpp
// If you want to see the biggest gains from this, run with the default values
// for parser_lambda and parser_max_entries_per_cell.  If these are set to their
// "fast-parsing" values (-1 and 5), then the diversity in the parses is not so good.

If you want to see the biggest gains from this, run with the default values
for parser_lambda and parser_max_entries_per_cell.  If these are set to their
"fast-parsing" values (-1 and 5), then the diversity in the parses is not so good.
If you want to see the biggest gains from this run with the default values for parser_lambda and parser_max_entries_per_cell . If these are set to their " fast - parsing " values ( - 1 and 5 ) then the diversity in the parses is not so good .
float SentenceTheory::scoreParseForBadTemporalAttachments(Parse* p) const {
	if (_temporalWords.size() == 0) {
		_temporalWords.insert(Symbol(L"yesterday"));
		_temporalWords.insert(Symbol(L"today"));
		_temporalWords.insert(Symbol(L"sunday"));
		_temporalWords.insert(Symbol(L"monday"));
		_temporalWords.insert(Symbol(L"tuesday"));
		_temporalWords.insert(Symbol(L"wednesday"));
		_temporalWords.insert(Symbol(L"thursday"));
		_temporalWords.insert(Symbol(L"friday"));
		_temporalWords.insert(Symbol(L"saturday"));
	}
	float score = 0.0;
	std::vector<const SynNode*> nodes;
	p->getRoot()->getAllTerminalNodes(nodes);
	for (size_t i = 0; i < (nodes.size()-1); i++) { 
		const SynNode* node = nodes[i];
		if (_temporalWords.find(node->getTag()) != _temporalWords.end() &&
			node->getStartToken() != 0) {
			while (node->getParent() && node->getParent()->getNChildren() == 1) {
				node = node->getParent();
			}
			const SynNode* prevTerminal = p->getRoot()->getCoveringNodeFromTokenSpan(node->getStartToken()-1, node->getStartToken()-1);
			if (prevTerminal->getParent() && prevTerminal->getParent()->getTag().to_debug_string()[0] == L'N' &&
				node->getParent() && node->getParent()->getTag().to_debug_string()[0] == L'N') {
				bool foundAFollowingVerb = false;
				for (size_t j = i+1; j < nodes.size(); j++) {
					const SynNode* candidate = nodes[j];
					if (candidate->getParent() && candidate->getParent()->getTag().to_debug_string()[0] == L'V') {
						foundAFollowingVerb = true;
						break;
					}
				}
				if (foundAFollowingVerb) {
					score -= 1000;
				}
			}
		}
	}
	return score;
}
float SentenceTheory :: scoreParseForBadTemporalAttachments ( Parse * p ) const { if ( _temporalWords . size ( ) == 0 ) { _temporalWords . insert ( Symbol ( L" " ) ) ; _temporalWords . insert ( Symbol ( L" " ) ) ; _temporalWords . insert ( Symbol ( L" " ) ) ; _temporalWords . insert ( Symbol ( L" " ) ) ; _temporalWords . insert ( Symbol ( L" " ) ) ; _temporalWords . insert ( Symbol ( L" " ) ) ; _temporalWords . insert ( Symbol ( L" " ) ) ; _temporalWords . insert ( Symbol ( L" " ) ) ; _temporalWords . insert ( Symbol ( L" " ) ) ; } float score = 0.0 ; std :: vector < const SynNode * > nodes ; p -> getRoot ( ) -> getAllTerminalNodes ( nodes ) ; for ( size_t i = 0 ; i < ( nodes . size ( ) - 1 ) ; i ++ ) { const SynNode * node = nodes [ i ] ; if ( _temporalWords . find ( node -> getTag ( ) ) != _temporalWords . end ( ) && node -> getStartToken ( ) != 0 ) { while ( node -> getParent ( ) && node -> getParent ( ) -> getNChildren ( ) == 1 ) { node = node -> getParent ( ) ; } const SynNode * prevTerminal = p -> getRoot ( ) -> getCoveringNodeFromTokenSpan ( node -> getStartToken ( ) - 1 , node -> getStartToken ( ) - 1 ) ; if ( prevTerminal -> getParent ( ) && prevTerminal -> getParent ( ) -> getTag ( ) . to_debug_string ( ) [ 0 ] == L' ' && node -> getParent ( ) && node -> getParent ( ) -> getTag ( ) . to_debug_string ( ) [ 0 ] == L' ' ) { bool foundAFollowingVerb = false ; for ( size_t j = i + 1 ; j < nodes . size ( ) ; j ++ ) { const SynNode * candidate = nodes [ j ] ; if ( candidate -> getParent ( ) && candidate -> getParent ( ) -> getTag ( ) . to_debug_string ( ) [ 0 ] == L' ' ) { foundAFollowingVerb = true ; break ; } } if ( foundAFollowingVerb ) { score -= 1000 ; } } } } return score ; }
If you want to see the biggest gains from this, run with the default values
for parser_lambda and parser_max_entries_per_cell.
If you want to see the biggest gains from this run with the default values for parser_lambda and parser_max_entries_per_cell .
//std::cout << "SentenceTheory::scoreParseForBadTemporalAttachments: Found " << nodes.size() << " terminal nodes\n";
 // -1 is to make sure we can have a following verb
 // Do we belong to our set of suspicious words?  Are we not the first word?
 // Ascend up any unary projections
 // Make sure we are immediately following a noun and our parent is a noun phrase
 // Make sure a verb follows us
 //std::wcout << L"DATELIKE:\n" << node->toTextString() << L"\n";
