src/PredFinder/elf/ElfIndividualFactory.cpp
/**
 * Static factory method that builds an ElfIndividual
 * from a SnippetFeatureSet found using manual
 * Distillation patterns. Depending on the contents of
 * feature_set, may produce any of the ElfIndividual
 * subclasses.
 *
 * @param doc_theory The DocTheory containing the matched
 * SnipppetFeatureSet, used for determining offsets.
 * @param feature_set The SnippetFeatureSet that contains
 * a SnippetFeature that we can convert to an ElfIndividual.
 *
 * @author nward@bbn.com
 * @date 2010.06.23
 **/
Static factory method that builds an ElfIndividual
from a SnippetFeatureSet found using manual
Distillation patterns. Depending on the contents of
feature_set, may produce any of the ElfIndividual
subclasses.

@param doc_theory The DocTheory containing the matched
SnipppetFeatureSet, used for determining offsets.
@param feature_set The SnippetFeatureSet that contains
a SnippetFeature that we can convert to an ElfIndividual.


Static factory method that builds an ElfIndividual from a SnippetFeatureSet found using manual Distillation patterns . Depending on the contents of feature_set may produce any of the ElfIndividual subclasses . @param doc_theory The DocTheory containing the matched SnipppetFeatureSet used for determining offsets . @param feature_set The SnippetFeatureSet that contains a SnippetFeature that we can convert to an ElfIndividual .
ElfIndividual_ptr ElfIndividualFactory::from_feature_set(const DocTheory* doc_theory, const PatternFeatureSet_ptr feature_set) {
	if (doc_theory == NULL)
		throw std::runtime_error("ElfIndividualFactory::from_feature_set(DocTheory*, PatternFeatureSet_ptr): Document theory null");
	ElfIndividual_ptr individual;
	bool valid_individual_feature = false;
	for (size_t i = 0; i < feature_set->getNFeatures(); i++) {
		PatternFeature_ptr feature = feature_set->getFeature(i);
		if (ReturnPatternFeature_ptr rpf = dynamic_pointer_cast<ReturnPatternFeature>(feature)) {
			if (valid_individual_feature)
				throw std::runtime_error("ElfIndividualFactory::from_feature_set(DocTheory*, PatternFeatureSet_ptr): "
				"Multiple individuals in PatternFeatureSet");
			if (ValueMentionReturnPFeature_ptr vmf = dynamic_pointer_cast<ValueMentionReturnPFeature>(rpf)) {
				individual = boost::make_shared<ElfIndividual>(doc_theory, rpf->getReturnValue(L"type"), vmf->getValueMention());
			} else {
				individual = boost::make_shared<ElfIndividual>(doc_theory, rpf);
			}
			valid_individual_feature = true;
		}
	}
	if (!valid_individual_feature)
		throw UnexpectedInputException("ElfIndividualFactory::from_feature_set", 
		"Feature set had no individual-generating feature");
	return individual;
}
ElfIndividual_ptr ElfIndividualFactory :: from_feature_set ( const DocTheory * doc_theory , const PatternFeatureSet_ptr feature_set ) { if ( doc_theory == NULL ) throw std :: runtime_error ( " " ) ; ElfIndividual_ptr individual ; bool valid_individual_feature = false ; for ( size_t i = 0 ; i < feature_set -> getNFeatures ( ) ; i ++ ) { PatternFeature_ptr feature = feature_set -> getFeature ( i ) ; if ( ReturnPatternFeature_ptr rpf = dynamic_pointer_cast < ReturnPatternFeature > ( feature ) ) { if ( valid_individual_feature ) throw std :: runtime_error ( " " " " ) ; if ( ValueMentionReturnPFeature_ptr vmf = dynamic_pointer_cast < ValueMentionReturnPFeature > ( rpf ) ) { individual = boost :: make_shared < ElfIndividual > ( doc_theory , rpf -> getReturnValue ( L" " ) , vmf -> getValueMention ( ) ) ; } else { individual = boost :: make_shared < ElfIndividual > ( doc_theory , rpf ) ; } valid_individual_feature = true ; } } if ( ! valid_individual_feature ) throw UnexpectedInputException ( " " , " " ) ; return individual ; }
Static factory method that builds an ElfIndividual
 from a SnippetFeatureSet found using manual
 Distillation patterns.
Static factory method that builds an ElfIndividual from a SnippetFeatureSet found using manual Distillation patterns .
// Check for bad entity
 // The individual we build from the feature set
 // Find matched features relevant to the individual
 // Get this feature from the set
 // Return features determine everything
 // Check if we've already found something for this individual
 // Check the return feature type
 // Construct from the ValueMention
 // Construct this individual generically
 // Passed all constructors without exception, we found something for this individual
 // Make sure we had a valid feature set (only one thing that can be turned into an individual)
 // Done
