src/PredFinder/elf/ElfRelationFactory.cpp
// RELATIONS FROM MANUAL PATTERNS
/**
 * Static factory method that builds an ElfRelation_ptr multiset (with the relation name as the key)
 * from a PatternSet found using manual Distillation patterns. 
 * Args filled with fake but plausible values. Used only for pattern validation.
 *
 * @param pattern_set_set The set of PatternSet items containing
 * the pattern(s); may be from multiple pattern files (eru:attendedSchool, eru:employs, etc.).
 * @param output_relations A pointer to the multiset of ElfRelation pointers that will be
 * filled by this method.
 * @param tbd_predicates A set of the "output" tbd predicates (e.g., "eru:bombingAttackEvent") 
 * that can be created from PatternReturns found in the patterns (e.g., "bombing").
 * @param dump Whether to dump information (which is voluminous).
 *
 * @author afrankel@bbn.com
 * @date 2010.10.11
 **/
RELATIONS FROM MANUAL PATTERNS
Static factory method that builds an ElfRelation_ptr multiset (with the relation name as the key)
from a PatternSet found using manual Distillation patterns.
Args filled with fake but plausible values. Used only for pattern validation.

@param pattern_set_set The set of PatternSet items containing
the pattern(s); may be from multiple pattern files (eru:attendedSchool, eru:employs, etc.).
@param output_relations A pointer to the multiset of ElfRelation pointers that will be
filled by this method.
@param tbd_predicates A set of the "output" tbd predicates
that can be created from PatternReturns found in the patterns .
@param dump Whether to dump information (which is voluminous).


RELATIONS FROM MANUAL PATTERNS Static factory method that builds an ElfRelation_ptr multiset ( with the relation name as the key ) from a PatternSet found using manual Distillation patterns . Args filled with fake but plausible values . Used only for pattern validation . @param pattern_set_set The set of PatternSet items containing the pattern ( s ) ; may be from multiple pattern files ( eru : attendedSchool eru : employs etc . ) . @param output_relations A pointer to the multiset of ElfRelation pointers that will be filled by this method . @param tbd_predicates A set of the " output " tbd predicates that can be created from PatternReturns found in the patterns . @param dump Whether to dump information ( which is voluminous ) .
void ElfRelationFactory::fake_relations_from_man_pattern_set(
										  const std::vector<PatternSet_ptr> & pattern_set_set, 
										  ElfRelationMultisetSortedByName & output_relations,
										  std::set<std::wstring> & tbd_pattern_set_names,
										  std::set<std::wstring> & tbd_predicates,
										  bool dump ) {
	bool verbose = ParamReader::getOptionalTrueFalseParamWithDefaultVal(
		"verbose_pattern_verification",  false);
	BOOST_FOREACH(PatternSet_ptr ps, pattern_set_set) {
		IDToPatternReturnVecSeqMap ipr_vec_seq_map;
		bool tbd_found(false);
		if (ps) {
			ps->getPatternReturns(ipr_vec_seq_map, dump);
			tbd_found = find_tbd_patterns(ipr_vec_seq_map, tbd_predicates, dump);
		}
		if (verbose) {
			SessionLogger::info("patt_set_name_0") << ps->getPatternSetName() << endl;
		}
		if (tbd_found) {
			tbd_pattern_set_names.insert(ps->getPatternSetName().to_string());
		} else {
			BOOST_FOREACH(IDToPatternReturnVecSeqMap::value_type id_vec_seq_pair, ipr_vec_seq_map) {
				if (verbose) {
					SessionLogger::info("top_level_id_0") << "  " << id_vec_seq_pair.first << endl;
				}
				std::vector< std::vector< ElfRelationArg_ptr > > arg_vec_vec;
				fake_args_from_man_pattern(ps->getPatternSetName(), id_vec_seq_pair, arg_vec_vec);
				BOOST_FOREACH(std::vector< ElfRelationArg_ptr > arg_vec, arg_vec_vec) {
					add_relation_from_arg_vec(arg_vec, ps->getPatternSetName().to_string(), 
						id_vec_seq_pair.first.to_string(), output_relations);
				}
			}
		}
	}
	if (dump) {
		BOOST_FOREACH(ElfRelation_ptr ptr, output_relations) {
			std::ostringstream ostr;
			ptr->dump(ostr,  0);
			SessionLogger::info("fake_rel_dump_0") << ostr.str();
		}
		if (!tbd_pattern_set_names.empty()) {
			SessionLogger::info("fake_rel_tbd_1") << "'tbd' pattern set names: <" 
				<< boost::algorithm::join(tbd_pattern_set_names, ",") << ">\n";
		}
		if (!tbd_predicates.empty()) {
			SessionLogger::info("fake_rel_tbd_2") << "'tbd' predicates: <" 
				<< boost::algorithm::join(tbd_predicates, ",") << ">\n";
		}
	}
	return;
}
void ElfRelationFactory :: fake_relations_from_man_pattern_set ( const std :: vector < PatternSet_ptr > & pattern_set_set , ElfRelationMultisetSortedByName & output_relations , std :: set < std :: wstring > & tbd_pattern_set_names , std :: set < std :: wstring > & tbd_predicates , bool dump ) { bool verbose = ParamReader :: getOptionalTrueFalseParamWithDefaultVal ( " " , false ) ; BOOST_FOREACH ( PatternSet_ptr ps , pattern_set_set ) { IDToPatternReturnVecSeqMap ipr_vec_seq_map ; bool tbd_found ( false ) ; if ( ps ) { ps -> getPatternReturns ( ipr_vec_seq_map , dump ) ; tbd_found = find_tbd_patterns ( ipr_vec_seq_map , tbd_predicates , dump ) ; } if ( verbose ) { SessionLogger :: info ( " " ) << ps -> getPatternSetName ( ) << endl ; } if ( tbd_found ) { tbd_pattern_set_names . insert ( ps -> getPatternSetName ( ) . to_string ( ) ) ; } else { BOOST_FOREACH ( IDToPatternReturnVecSeqMap :: value_type id_vec_seq_pair , ipr_vec_seq_map ) { if ( verbose ) { SessionLogger :: info ( " " ) << " " << id_vec_seq_pair . first << endl ; } std :: vector < std :: vector < ElfRelationArg_ptr > > arg_vec_vec ; fake_args_from_man_pattern ( ps -> getPatternSetName ( ) , id_vec_seq_pair , arg_vec_vec ) ; BOOST_FOREACH ( std :: vector < ElfRelationArg_ptr > arg_vec , arg_vec_vec ) { add_relation_from_arg_vec ( arg_vec , ps -> getPatternSetName ( ) . to_string ( ) , id_vec_seq_pair . first . to_string ( ) , output_relations ) ; } } } } if ( dump ) { BOOST_FOREACH ( ElfRelation_ptr ptr , output_relations ) { std :: ostringstream ostr ; ptr -> dump ( ostr , 0 ) ; SessionLogger :: info ( " " ) << ostr . str ( ) ; } if ( ! tbd_pattern_set_names . empty ( ) ) { SessionLogger :: info ( " " ) << " " << boost :: algorithm :: join ( tbd_pattern_set_names , " " ) << " \n " ; } if ( ! tbd_predicates . empty ( ) ) { SessionLogger :: info ( " " ) << " " << boost :: algorithm :: join ( tbd_predicates , " " ) << " \n " ; } } return ; }
RELATIONS FROM MANUAL PATTERNS
 Static factory method that builds an ElfRelation_ptr multiset (with the relation name as the key)
 from a PatternSet found using manual Distillation patterns.
RELATIONS FROM MANUAL PATTERNS Static factory method that builds an ElfRelation_ptr multiset ( with the relation name as the key ) from a PatternSet found using manual Distillation patterns .
/* = false */ // Hierarchy:
 // Predicate pattern set (e.g., the set {eru:attendedSchool, eru:employs, ...}) (passed in as a param to this method)
 //		Predicate pattern (e.g., eru:attendedSchool)
 //				Top-level pattern, w/unique ID (e.g., graduated_from_vprop or attended_vprop)
 // An IDToPatternReturnVecMap maps an id to a vector of PatternReturn pointers. 
 // Each PatternReturn pointer corresponds to the information that will be stored in an arg.
 // In the pattern file, the info that goes into a PatternReturn is represented as an sexp
 // headed by the keyword "return". Example:
 //		(return (role eru:educationalInstitution) (type ic:EducationalInstitution))
 // Retrieve each predicate pattern in the pattern set. 
 /* defaultVal=*/ // Retrieve each top-level pattern in the predicate pattern.
 // For each top-level pattern, instantiate a relation and 
 // push it onto the end of output_relations (unless output_relations already contains it).
 /*indent=*/