src/MaxEntSimulatedActiveLearning/InstanceSet.cpp
/*
	The first line of each annotation file should contain the number of instances in the file.
	The format for each individual relation instance should be:

	docno
	full sentence text
	EDT start offset of first mention (*)
	EDT end offset of first mention (*)
	start offset of first mention relative to the beginning of the sentence
	length (in chars) of first mention
	mention type of first mention
	EDT start offset of second mention (*)
	EDT end offset of second mention (*)
	start offset of second mention relative to the beginning of the sentence
	length (in chars) of second mention
	mention type of second mention
	relation type (set to "---------" if the type is unknown)
	"reversed" if the relation is reversed, blank otherwise

	(*) these values are not actually used by the HYA tool as far as I can tell.
	*/
The first line of each annotation file should contain the number of instances in the file.
The format for each individual relation instance should be.



(*) these values are not actually used by the HYA tool as far as I can tell.
The first line of each annotation file should contain the number of instances in the file . The format for each individual relation instance should be . ( * ) these values are not actually used by the HYA tool as far as I can tell .
std::wstring InstanceSet::makeHYAString(RelationInstance const * const instance) {
	const TokenSequence* tokens = instance->getSentenceInfo()->tokenSequences[0];
	const SynNode* head1 = PotentialTrainingRelation::getEDTHead(instance->getFirstMention(), 
														  		 instance->getMentionSet());
	const SynNode* head2 = PotentialTrainingRelation::getEDTHead(instance->getSecondMention(), 
														  		 instance->getMentionSet());
	int edt_start1 = tokens->getToken(head1->getStartToken())->getStartOffset();
	int edt_start2 = tokens->getToken(head2->getStartToken())->getStartOffset();
	int edt_end1 = tokens->getToken(head1->getEndToken())->getEndOffset();
	int edt_end2 = tokens->getToken(head2->getEndToken())->getEndOffset();
	int start1, end1, start2, end2;  
	int index = 0;
	for (int t = 0; t < tokens->getNTokens(); t++) {
		const Token* token = tokens->getToken(t);
		const wchar_t* str = token->getSymbol().to_string();
		if (t == head1->getStartToken())
			start1 = index;
		if (t == head1->getEndToken())
			end1 = index + static_cast<int>(wcslen(str));
		if (t == head2->getStartToken())
			start2 = index;
		if (t == head2->getEndToken())
			end2 = index + static_cast<int>(wcslen(str));
		index += static_cast<int>(wcslen(str));
	}
	std::wstring str = L"";
	wchar_t wc[PARAM_LENGTH];
	str += instance->getID().to_string();
	str += L"\n";
	str += tokens->toStringNoSpaces();
	str += L"\n";
	swprintf(wc, L"%d", edt_start1);
	str += wc;
	str += L"\n";
	swprintf(wc, L"%d", edt_end1);
	str += wc;
	str += L"\n";
	swprintf(wc, L"%d", start1);
	str += wc;
	str += L"\n";
	swprintf(wc, L"%d", end1 - start1);
	str += wc;
	str += L"\n";
	str += instance->getFirstMention()->getEntityType().getName().to_string();
	str += L"\n";
	swprintf(wc, L"%d", edt_start2);
	str += wc;
	str += L"\n";
	swprintf(wc, L"%d", edt_end2);
	str += wc;
	str += L"\n";
	swprintf(wc, L"%d", start2);
	str += wc;
	str += L"\n";
	swprintf(wc, L"%d", end2 - start2);
	str += wc;
	str += L"\n";
	str += instance->getSecondMention()->getEntityType().getName().to_string();
	str += L"\n";
	str += instance->getRelationSymbol().to_string();
	str += L"\n";
	if (instance->isReversed()) {
		str += L"reversed\n";
	} else {
		str += L"\n";
	}
	return str;
}
std :: wstring InstanceSet :: makeHYAString ( RelationInstance const * const instance ) { const TokenSequence * tokens = instance -> getSentenceInfo ( ) -> tokenSequences [ 0 ] ; const SynNode * head1 = PotentialTrainingRelation :: getEDTHead ( instance -> getFirstMention ( ) , instance -> getMentionSet ( ) ) ; const SynNode * head2 = PotentialTrainingRelation :: getEDTHead ( instance -> getSecondMention ( ) , instance -> getMentionSet ( ) ) ; int edt_start1 = tokens -> getToken ( head1 -> getStartToken ( ) ) -> getStartOffset ( ) ; int edt_start2 = tokens -> getToken ( head2 -> getStartToken ( ) ) -> getStartOffset ( ) ; int edt_end1 = tokens -> getToken ( head1 -> getEndToken ( ) ) -> getEndOffset ( ) ; int edt_end2 = tokens -> getToken ( head2 -> getEndToken ( ) ) -> getEndOffset ( ) ; int start1 , end1 , start2 , end2 ; int index = 0 ; for ( int t = 0 ; t < tokens -> getNTokens ( ) ; t ++ ) { const Token * token = tokens -> getToken ( t ) ; const wchar_t * str = token -> getSymbol ( ) . to_string ( ) ; if ( t == head1 -> getStartToken ( ) ) start1 = index ; if ( t == head1 -> getEndToken ( ) ) end1 = index + static_cast < int > ( wcslen ( str ) ) ; if ( t == head2 -> getStartToken ( ) ) start2 = index ; if ( t == head2 -> getEndToken ( ) ) end2 = index + static_cast < int > ( wcslen ( str ) ) ; index += static_cast < int > ( wcslen ( str ) ) ; } std :: wstring str = L" " ; wchar_t wc [ PARAM_LENGTH ] ; str += instance -> getID ( ) . to_string ( ) ; str += L" \n " ; str += tokens -> toStringNoSpaces ( ) ; str += L" \n " ; swprintf ( wc , L" " , edt_start1 ) ; str += wc ; str += L" \n " ; swprintf ( wc , L" " , edt_end1 ) ; str += wc ; str += L" \n " ; swprintf ( wc , L" " , start1 ) ; str += wc ; str += L" \n " ; swprintf ( wc , L" " , end1 - start1 ) ; str += wc ; str += L" \n " ; str += instance -> getFirstMention ( ) -> getEntityType ( ) . getName ( ) . to_string ( ) ; str += L" \n " ; swprintf ( wc , L" " , edt_start2 ) ; str += wc ; str += L" \n " ; swprintf ( wc , L" " , edt_end2 ) ; str += wc ; str += L" \n " ; swprintf ( wc , L" " , start2 ) ; str += wc ; str += L" \n " ; swprintf ( wc , L" " , end2 - start2 ) ; str += wc ; str += L" \n " ; str += instance -> getSecondMention ( ) -> getEntityType ( ) . getName ( ) . to_string ( ) ; str += L" \n " ; str += instance -> getRelationSymbol ( ) . to_string ( ) ; str += L" \n " ; if ( instance -> isReversed ( ) ) { str += L" \n " ; } else { str += L" \n " ; } return str ; }
The first line of each annotation file should contain the number of instances in the file.
The first line of each annotation file should contain the number of instances in the file .
/*	const SynNode* firstNode = instance->getFirstMention()->getNode();
	const SynNode* secondNode = instance->getSecondMention()->getNode();

	// these are all inclusive; they should be the same numbers that appear in the CA file
	int edt_start1 = tokens->getToken(firstNode->getStartToken())->getStartOffset();
	int edt_end1 = tokens->getToken(firstNode->getEndToken())->getEndOffset();
	int edt_start2 = tokens->getToken(secondNode->getStartToken())->getStartOffset();
	int edt_end2 = tokens->getToken(secondNode->getEndToken())->getEndOffset();

	// here start and end are NOT inclusive as they will be used only to print out to the HYA format
	int start1 = -1;
	int end1 = -1;
	int start2 = -1;
	int end2 = -1;  

	int index = 0;
	for (int t = 0; t < tokens->getNTokens(); t++) {

		const Token* token = tokens->getToken(t);
		const wchar_t* str = token->getSymbol().to_string();

		if (t == firstNode->getStartToken())
			start1 = index;
		if (t == firstNode->getEndToken())
			end1 = index + static_cast<int>(wcslen(str));
		if (t == secondNode->getStartToken())
			start2 = index;
		if (t == secondNode->getEndToken())
			end2 = index + static_cast<int>(wcslen(str));

		index += static_cast<int>(wcslen(str));
	}
*/ // start and end are inclusive
