src/PredFinder/elf/ElfIndividual.cpp
/**
* Copy constructor that also coerces the individual being
* copied into the closest Serif matches(that is, it adds
* any Serif IDs to the copy of the individual where possible).
*
* @param doc_theory The DocTheory containing the relation,
* which will be used to align with Serif mentions.
* @param other ElfRelation to deep copy from.
*
* @author nward@bbn.com
* @date 2011.06.09
 **/
Copy constructor that also coerces the individual being
copied into the closest Serif matches(that is, it adds
any Serif IDs to the copy of the individual where possible).
Copy constructor that also coerces the individual being copied into the closest Serif matches ( that is it adds any Serif IDs to the copy of the individual where possible ) .
ElfIndividual::ElfIndividual(const DocTheory* doc_theory, const ElfIndividual_ptr other) {
	_partner_uri = other->_partner_uri;
	_generated_uri = other->_generated_uri;
	_is_value = other->_is_value;
	_value = other->_value;
	_value_mention_id = other->_value_mention_id;
	_mention_uid = other->_mention_uid;
	_mention_confidence = other->_mention_confidence;
	_entity_id = other->_entity_id;
	_coref_uri = other->_coref_uri;
	_xdoc_cluster_id = other->_xdoc_cluster_id;
	_event_id = other->_event_id;
	_bound_uri = other->_bound_uri;
	_date_range.first = other->_date_range.first;
	_date_range.second = other->_date_range.second;
	_name_or_desc = other->_name_or_desc;
	ElfType_ptr type = other->get_type();
	_types.insert(type);
	if (has_partner_uri()) {
		const Entity* entity = NULL;
		EDTOffset start_offset, end_offset;
		type->get_offsets(start_offset, end_offset);
		int sent_no, start_token, end_token;
		bool token_align = MainUtilities::getSerifStartEndTokenFromCharacterOffsets(doc_theory, start_offset, end_offset, sent_no, start_token, end_token);
		if (token_align) {
			SentenceTheory* sent_theory = doc_theory->getSentenceTheory(sent_no);
			if (sent_theory != NULL) {
				const Mention* mention = MainUtilities::getMentionFromTokenOffsets(sent_theory, start_token, end_token);
				if (mention) {
					_mention_uid = mention->getUID();
					_mention_confidence = MentionConfidence::determineMentionConfidence(doc_theory, sent_theory, mention);
					entity = mention->getEntity(doc_theory);
					if (entity)
						_entity_id = entity->getID();
				} else {
					const ValueMention* value_mention = MainUtilities::getValueMentionFromTokenOffsets(sent_theory, start_token, end_token);
					if (value_mention) {
						_value_mention_id = value_mention->getUID().toInt();
						_is_value = true;
						_value = _name_or_desc->get_value();
						if (value_mention->isTimexValue()) {
							const Value* doc_value = value_mention->getDocValue();
							if (doc_value != NULL) {
								Symbol timex_value = doc_value->getTimexVal();
								if (timex_value != Symbol()) {
									_value = get_text_according_to_type(type->get_value(), timex_value.to_string());
								}
							}
						}
					}
				}
			}
		}
		if (_name_or_desc.get() != NULL && type.get() != NULL) {
			XDocIdType xdoc_id;
			ElfMultiDoc::get_mapped_arg(_name_or_desc->get_value(), type->get_value(), doc_theory, entity, _bound_uri, xdoc_id);
			_xdoc_cluster_id = xdoc_id.as_int();
		}
	}
}
ElfIndividual :: ElfIndividual ( const DocTheory * doc_theory , const ElfIndividual_ptr other ) { _partner_uri = other -> _partner_uri ; _generated_uri = other -> _generated_uri ; _is_value = other -> _is_value ; _value = other -> _value ; _value_mention_id = other -> _value_mention_id ; _mention_uid = other -> _mention_uid ; _mention_confidence = other -> _mention_confidence ; _entity_id = other -> _entity_id ; _coref_uri = other -> _coref_uri ; _xdoc_cluster_id = other -> _xdoc_cluster_id ; _event_id = other -> _event_id ; _bound_uri = other -> _bound_uri ; _date_range . first = other -> _date_range . first ; _date_range . second = other -> _date_range . second ; _name_or_desc = other -> _name_or_desc ; ElfType_ptr type = other -> get_type ( ) ; _types . insert ( type ) ; if ( has_partner_uri ( ) ) { const Entity * entity = NULL ; EDTOffset start_offset , end_offset ; type -> get_offsets ( start_offset , end_offset ) ; int sent_no , start_token , end_token ; bool token_align = MainUtilities :: getSerifStartEndTokenFromCharacterOffsets ( doc_theory , start_offset , end_offset , sent_no , start_token , end_token ) ; if ( token_align ) { SentenceTheory * sent_theory = doc_theory -> getSentenceTheory ( sent_no ) ; if ( sent_theory != NULL ) { const Mention * mention = MainUtilities :: getMentionFromTokenOffsets ( sent_theory , start_token , end_token ) ; if ( mention ) { _mention_uid = mention -> getUID ( ) ; _mention_confidence = MentionConfidence :: determineMentionConfidence ( doc_theory , sent_theory , mention ) ; entity = mention -> getEntity ( doc_theory ) ; if ( entity ) _entity_id = entity -> getID ( ) ; } else { const ValueMention * value_mention = MainUtilities :: getValueMentionFromTokenOffsets ( sent_theory , start_token , end_token ) ; if ( value_mention ) { _value_mention_id = value_mention -> getUID ( ) . toInt ( ) ; _is_value = true ; _value = _name_or_desc -> get_value ( ) ; if ( value_mention -> isTimexValue ( ) ) { const Value * doc_value = value_mention -> getDocValue ( ) ; if ( doc_value != NULL ) { Symbol timex_value = doc_value -> getTimexVal ( ) ; if ( timex_value != Symbol ( ) ) { _value = get_text_according_to_type ( type -> get_value ( ) , timex_value . to_string ( ) ) ; } } } } } } } if ( _name_or_desc . get ( ) != NULL && type . get ( ) != NULL ) { XDocIdType xdoc_id ; ElfMultiDoc :: get_mapped_arg ( _name_or_desc -> get_value ( ) , type -> get_value ( ) , doc_theory , entity , _bound_uri , xdoc_id ) ; _xdoc_cluster_id = xdoc_id . as_int ( ) ; } } }
Copy constructor that also coerces the individual being
copied into the closest Serif matches(that is, it adds
any Serif IDs to the copy of the individual where possible).
Copy constructor that also coerces the individual being copied into the closest Serif matches ( that is it adds any Serif IDs to the copy of the individual where possible ) .
// Copy the various possible IDs for this individual
 // Copy the individual's best name text
 // Copy the type assertion
 // Try to find a token alignment to a mention and entity based on offsets if this came from one of our partners
 // Get the sentence theory containing this string
 //   Give up if for some reason (bad sentence number?) we can't get the sentence theory
 // First, try a mention alignment for this string
 // Store the mention ID (silently overwrites)
 // Get an entity if there is one
 // Try a value mention alignment (probably a date)
 // Store the value mention ID (silently overwrites)
 // If it's a date, try to override with a normalized value
 // Use the specific date value but keep the value text
 // Whether or not we found an entity to use in lookup, try to map this individual
