src/PredFinder/elf/ElfIndividual.cpp
/**
 * Construct an ElfIndividual from two ValueMentions which provide a date range. 
 * Use provided normalization
 *
 * @param doc_theory The DocTheory containing the ValueMention.
 * @param type_string The URI of the ontology type to use for this individual.
 * @param value_mention The value mention we can convert to an ElfIndividual.
 *
 * @author nward@bbn.com
 * @date 2011.05.05
 **/
Construct an ElfIndividual from two ValueMentions which provide a date range.
Use provided normalization




Construct an ElfIndividual from two ValueMentions which provide a date range . Use provided normalization
ElfIndividual::ElfIndividual(const DocTheory* doc_theory, const std::wstring & type_string, const std::wstring & value, const ValueMention* v1, const ValueMention* v2){
	initialize();
	_is_value = true;
	int sent_no = 0;
	if(v1){
		sent_no = v1->getSentenceNumber();
		_date_range.first = v1->getUID().toInt();
	}
	if(v2){
		sent_no = v2->getSentenceNumber();
		_date_range.second = v2->getUID().toInt();
	}
	_value = value;
	_is_value = true;
	_value_mention_id = -1;
	std::wstringstream value_uri;
	value_uri << L"bbn:value-range-"<<_date_range.first <<" "<<_date_range.second;
	_generated_uri = value_uri.str();
	SentenceTheory* sent_theory = doc_theory->getSentenceTheory(sent_no);
	if (sent_theory) {
		TokenSequence* token_sequence = sent_theory->getTokenSequence();
		if (token_sequence){
			EDTOffset start;
			EDTOffset end;
			if(v1 != 0 && v2 != 0){
				start = std::min(token_sequence->getToken(v1->getStartToken())->getStartEDTOffset(), token_sequence->getToken(v2->getStartToken())->getStartEDTOffset());
				end = std::max(token_sequence->getToken(v1->getEndToken())->getEndEDTOffset(), token_sequence->getToken(v2->getEndToken())->getEndEDTOffset());
			}
			else if(v1){
				start = token_sequence->getToken(v1->getStartToken())->getStartEDTOffset();
				end = token_sequence->getToken(v1->getEndToken())->getEndEDTOffset();
			}
			else if(v2){
				start = token_sequence->getToken(v2->getStartToken())->getStartEDTOffset();
				end = token_sequence->getToken(v2->getEndToken())->getEndEDTOffset();
			}
			LocatedString* token_span = MainUtilities::substringFromEdtOffsets(doc_theory->getDocument()->getOriginalText(), start, end);
			std::wstring text = std::wstring(token_span->toString());
			delete token_span;
			_name_or_desc = boost::make_shared<ElfDescriptor>(_value, 1.0, text, start, end);
			_types.insert(boost::make_shared<ElfType>(type_string, text, start, end));
		}
	}
}
ElfIndividual :: ElfIndividual ( const DocTheory * doc_theory , const std :: wstring & type_string , const std :: wstring & value , const ValueMention * v1 , const ValueMention * v2 ) { initialize ( ) ; _is_value = true ; int sent_no = 0 ; if ( v1 ) { sent_no = v1 -> getSentenceNumber ( ) ; _date_range . first = v1 -> getUID ( ) . toInt ( ) ; } if ( v2 ) { sent_no = v2 -> getSentenceNumber ( ) ; _date_range . second = v2 -> getUID ( ) . toInt ( ) ; } _value = value ; _is_value = true ; _value_mention_id = -1 ; std :: wstringstream value_uri ; value_uri << L" " << _date_range . first << " " << _date_range . second ; _generated_uri = value_uri . str ( ) ; SentenceTheory * sent_theory = doc_theory -> getSentenceTheory ( sent_no ) ; if ( sent_theory ) { TokenSequence * token_sequence = sent_theory -> getTokenSequence ( ) ; if ( token_sequence ) { EDTOffset start ; EDTOffset end ; if ( v1 != 0 && v2 != 0 ) { start = std :: min ( token_sequence -> getToken ( v1 -> getStartToken ( ) ) -> getStartEDTOffset ( ) , token_sequence -> getToken ( v2 -> getStartToken ( ) ) -> getStartEDTOffset ( ) ) ; end = std :: max ( token_sequence -> getToken ( v1 -> getEndToken ( ) ) -> getEndEDTOffset ( ) , token_sequence -> getToken ( v2 -> getEndToken ( ) ) -> getEndEDTOffset ( ) ) ; } else if ( v1 ) { start = token_sequence -> getToken ( v1 -> getStartToken ( ) ) -> getStartEDTOffset ( ) ; end = token_sequence -> getToken ( v1 -> getEndToken ( ) ) -> getEndEDTOffset ( ) ; } else if ( v2 ) { start = token_sequence -> getToken ( v2 -> getStartToken ( ) ) -> getStartEDTOffset ( ) ; end = token_sequence -> getToken ( v2 -> getEndToken ( ) ) -> getEndEDTOffset ( ) ; } LocatedString * token_span = MainUtilities :: substringFromEdtOffsets ( doc_theory -> getDocument ( ) -> getOriginalText ( ) , start , end ) ; std :: wstring text = std :: wstring ( token_span -> toString ( ) ) ; delete token_span ; _name_or_desc = boost :: make_shared < ElfDescriptor > ( _value , 1.0 , text , start , end ) ; _types . insert ( boost :: make_shared < ElfType > ( type_string , text , start , end ) ) ; } } }
Construct an ElfIndividual from two ValueMentions which provide a date range.
Construct an ElfIndividual from two ValueMentions which provide a date range .
// Pair of values instead of single value, generate range id that includes both
 // Get the offsets for the return feature
 // Get the text for the token span
 // Add the specified type and desc using the value mention text
