src/PredFinder/macros/GenerateIndividualOperator.cpp
/**
 * Implements ReadingMacroOperator::apply.
 *
 * Splits any matching ElfRelations in this
 * document, replacing the match with the
 * resulting relations, and adding the newly
 * generated individual. If there are no matches,
 * the result is a no-op and the document is
 * unchanged.
 *
 * @param document The ELF document, which will be
 * transformed in-place.
 *
 * @author nward@bbn.com
 * @date 2010.10.08
 **/


Splits any matching ElfRelations in this
document, replacing the match with the
resulting relations, and adding the newly
generated individual. If there are no matches,
the result is a no-op and the document is
unchanged.

@param document The ELF document, which will be
transformed in-place.


Splits any matching ElfRelations in this document replacing the match with the resulting relations and adding the newly generated individual . If there are no matches the result is a no - op and the document is unchanged . @param document The ELF document which will be transformed in - place .
void GenerateIndividualOperator::apply(ElfDocument_ptr document) const {
	std::set<ElfRelation_ptr> relations = document->get_relations();
	std::set<ElfRelation_ptr> relations_to_remove;
	BOOST_FOREACH(ElfRelation_ptr relation, relations) {
		if (matches(relation)) {
			std::set<ElfRelation_ptr> split_relations;
			BOOST_FOREACH(RelationParameter_ptr relation_parameter, _relations) {
				ElfRelation_ptr split_relation = relation_parameter->to_elf_relation(document, relation, _individual);
				split_relation->add_source(_source_id);
				if (split_relation->get_args().size() >= 2)
					split_relations.insert(split_relation);
			}
			document->add_relations(split_relations);
			relations_to_remove.insert(relation);
		}
	}
	document->remove_relations(relations_to_remove);
}
void GenerateIndividualOperator :: apply ( ElfDocument_ptr document ) const { std :: set < ElfRelation_ptr > relations = document -> get_relations ( ) ; std :: set < ElfRelation_ptr > relations_to_remove ; BOOST_FOREACH ( ElfRelation_ptr relation , relations ) { if ( matches ( relation ) ) { std :: set < ElfRelation_ptr > split_relations ; BOOST_FOREACH ( RelationParameter_ptr relation_parameter , _relations ) { ElfRelation_ptr split_relation = relation_parameter -> to_elf_relation ( document , relation , _individual ) ; split_relation -> add_source ( _source_id ) ; if ( split_relation -> get_args ( ) . size ( ) >= 2 ) split_relations . insert ( split_relation ) ; } document -> add_relations ( split_relations ) ; relations_to_remove . insert ( relation ) ; } } document -> remove_relations ( relations_to_remove ) ; }
Implements ReadingMacroOperator::apply.
Implements ReadingMacroOperator :: apply .
// Loop through the document's relations, checking for matching relations
 // Make sure this is a matching relation
 // Generate each of the relations from the split
 //   Make the generated individual available in case it's referenced
 //   in one of the relation parameter's role parameters
 // Mark the original relation that we split for removal
 //   Don't want to invalidate our iterators
 // Loop through the relations we split and remove them from the document
