src/Generic/state/XMLTheoryElement.cpp
/** Option attributes:
  *
  *   - external_original_text: If the document's original text has a
  *     URL, then do not include the contents of the original text in 
  *     the serialized XML file.  The serialized file will only be usable
  *     if the original text can be read from its original location.
  *   - verbose_ids: Each XML identifier generated during serialization 
  *     includes the name of the type of object serialized.
  *   - hierarchical_ids: Each XML identifier generated during serialization
  *     includes its parent object's identifier as a prefix.
  *   - include_mentions_as_comments: Each entity, relation and event generated
  *     during serialization contains comments representing each of its mentions.
  *   - include_spans_as_comments: Each element representing a span of text 
  *     includes a comment containing the actual text string.
  *   - include_spans_as_elements: Each element representing a span of text
  *     includes the actual text string as a child element.
  *   - include_mention_transliterations: Add an attribute containing the
  *     transcribed text of each mention.
  *   - include_name_transliterations: Add an attribute containing the
  *     transcribed text of each name.
  *   - include_canonical_names: Add an attribute containing the canonical
  *     name mention (if one exists) for each entity.
  */
Option attributes.

- external_original_text: If the document's original text has a
URL, then do not include the contents of the original text in
the serialized XML file.  The serialized file will only be usable
if the original text can be read from its original location.
- verbose_ids: Each XML identifier generated during serialization
includes the name of the type of object serialized.
- hierarchical_ids: Each XML identifier generated during serialization
includes its parent object's identifier as a prefix.
- include_mentions_as_comments: Each entity, relation and event generated
during serialization contains comments representing each of its mentions.
- include_spans_as_comments: Each element representing a span of text
includes a comment containing the actual text string.
- include_spans_as_elements: Each element representing a span of text
includes the actual text string as a child element.
- include_mention_transliterations: Add an attribute containing the
transcribed text of each mention.
- include_name_transliterations: Add an attribute containing the
transcribed text of each name.
- include_canonical_names: Add an attribute containing the canonical
name mention (if one exists) for each entity.
Option attributes . - external_original_text : If the document ' s original text has a URL then do not include the contents of the original text in the serialized XML file . The serialized file will only be usable if the original text can be read from its original location . - verbose_ids : Each XML identifier generated during serialization includes the name of the type of object serialized . - hierarchical_ids : Each XML identifier generated during serialization includes its parent object ' s identifier as a prefix . - include_mentions_as_comments : Each entity relation and event generated during serialization contains comments representing each of its mentions . - include_spans_as_comments : Each element representing a span of text includes a comment containing the actual text string . - include_spans_as_elements : Each element representing a span of text includes the actual text string as a child element . - include_mention_transliterations : Add an attribute containing the transcribed text of each mention . - include_name_transliterations : Add an attribute containing the transcribed text of each name . - include_canonical_names : Add an attribute containing the canonical name mention ( if one exists ) for each entity .
XMLTheoryElement::SerializationOptions::SerializationOptions(const XMLTheoryElement::SerializationOptions::OptionMap &optionMap)
{
	using namespace SerifXML;
	setOptionsToDefaultValues();
	setOptionsFromParamReader();
	setBooleanOption(optionMap, external_original_text, X_external_original_text);
	setBooleanOption(optionMap, use_verbose_ids, X_verbose_ids);
	setBooleanOption(optionMap, use_hierarchical_ids, X_hierarchical_ids);
	setBooleanOption(optionMap, use_condensed_offsets, X_condensed_offsets);
	setBooleanOption(optionMap, use_implicit_tokens, X_implicit_tokens);
	setBooleanOption(optionMap, include_mentions_as_comments, X_include_mentions_as_comments);
	setBooleanOption(optionMap, include_spans_as_comments, X_include_spans_as_comments);
	setBooleanOption(optionMap, include_spans_as_elements, X_include_spans_as_elements);
	setBooleanOption(optionMap, include_mention_transliterations, X_include_mention_transliterations);
	setBooleanOption(optionMap, include_mention_confidences, X_include_mention_confidences);
	setBooleanOption(optionMap, include_name_transliterations, X_include_name_transliterations);
	setBooleanOption(optionMap, include_canonical_names, X_include_canonical_names);
    #ifndef MT_DECODER
	if (include_mention_transliterations || include_name_transliterations) {
		throw UnexpectedInputException("XMLTheoryElement::SerializationOptions::SerializationOptions",
									   "include_*_transliterations options not supported: this version of SERIF was not linked with the MTDecoder library.");
	}
    #endif
	if (optionMap.find(X_input_type) != optionMap.end()) {
		std::wstring input_type_str = transcodeToStdWString(optionMap.find(X_input_type)->second.c_str());
		std::transform(input_type_str.begin(), input_type_str.end(), input_type_str.begin(), towlower);
		if (input_type_str == L"auto" || input_type_str == L"dtra" || input_type_str == L"text" || input_type_str == L"sgm")
			input_type = Symbol(input_type_str);
		else
			throw UnexpectedInputException("XMLTheoryElement::SerializationOptions::SerializationOptions",
				"Expected \"input_type\" attribute value to be \"auto\", \"dtra\", \"text\", or \"sgm\".");
	}
	if (optionMap.find(X_parse_encoding) != optionMap.end()) {
		std::wstring parse_encoding = transcodeToStdWString(optionMap.find(X_parse_encoding)->second.c_str());
		std::transform(parse_encoding.begin(), parse_encoding.end(), parse_encoding.begin(), towlower);
		if (parse_encoding == L"treebank")
			use_treebank_tree = true;
		else if (parse_encoding == L"synnode")
			use_treebank_tree = false;
		else
			throw UnexpectedInputException("XMLTheoryElement::SerializationOptions::SerializationOptions",
				"Expected \"parse_encoding\" attribute value to be \"treebank\" or \"SynNode\".");
	}
	if (optionMap.find(X_offset_type) != optionMap.end()) {
		std::wstring offsets = transcodeToStdWString(optionMap.find(X_offset_type)->second.c_str());
		std::transform(offsets.begin(), offsets.end(), offsets.begin(), towlower);
		if (offsets == L"all") {
			include_byte_offsets = true;  include_char_offsets = true;  include_edt_offsets = true;
		} else if (offsets == L"byte") {
			include_byte_offsets = true;  include_char_offsets = false; include_edt_offsets = false;
		} else if (offsets == L"char") {
			include_byte_offsets = false; include_char_offsets = true;  include_edt_offsets = false;
		} else if (offsets == L"edt" || offsets == L"EDT") {
			include_byte_offsets = false; include_char_offsets = false; include_edt_offsets = true;
		} else {
			throw UnexpectedInputException("XMLTheoryElement::SerializationOptions::SerializationOptions",
				"Expected \"offset_type\" attribute value to be \"all\", \"byte\", \"char\", or \"edt\".");
		}
	}
}
XMLTheoryElement :: SerializationOptions :: SerializationOptions ( const XMLTheoryElement :: SerializationOptions :: OptionMap & optionMap ) { using namespace SerifXML ; setOptionsToDefaultValues ( ) ; setOptionsFromParamReader ( ) ; setBooleanOption ( optionMap , external_original_text , X_external_original_text ) ; setBooleanOption ( optionMap , use_verbose_ids , X_verbose_ids ) ; setBooleanOption ( optionMap , use_hierarchical_ids , X_hierarchical_ids ) ; setBooleanOption ( optionMap , use_condensed_offsets , X_condensed_offsets ) ; setBooleanOption ( optionMap , use_implicit_tokens , X_implicit_tokens ) ; setBooleanOption ( optionMap , include_mentions_as_comments , X_include_mentions_as_comments ) ; setBooleanOption ( optionMap , include_spans_as_comments , X_include_spans_as_comments ) ; setBooleanOption ( optionMap , include_spans_as_elements , X_include_spans_as_elements ) ; setBooleanOption ( optionMap , include_mention_transliterations , X_include_mention_transliterations ) ; setBooleanOption ( optionMap , include_mention_confidences , X_include_mention_confidences ) ; setBooleanOption ( optionMap , include_name_transliterations , X_include_name_transliterations ) ; setBooleanOption ( optionMap , include_canonical_names , X_include_canonical_names ) ; #ifndef MT_DECODER if ( include_mention_transliterations || include_name_transliterations ) { throw UnexpectedInputException ( " " , " " ) ; } #endif if ( optionMap . find ( X_input_type ) != optionMap . end ( ) ) { std :: wstring input_type_str = transcodeToStdWString ( optionMap . find ( X_input_type ) -> second . c_str ( ) ) ; std :: transform ( input_type_str . begin ( ) , input_type_str . end ( ) , input_type_str . begin ( ) , towlower ) ; if ( input_type_str == L" " || input_type_str == L" " || input_type_str == L" " || input_type_str == L" " ) input_type = Symbol ( input_type_str ) ; else throw UnexpectedInputException ( " " , " \" \" \" \" \" \" \" \" \" \" " ) ; } if ( optionMap . find ( X_parse_encoding ) != optionMap . end ( ) ) { std :: wstring parse_encoding = transcodeToStdWString ( optionMap . find ( X_parse_encoding ) -> second . c_str ( ) ) ; std :: transform ( parse_encoding . begin ( ) , parse_encoding . end ( ) , parse_encoding . begin ( ) , towlower ) ; if ( parse_encoding == L" " ) use_treebank_tree = true ; else if ( parse_encoding == L" " ) use_treebank_tree = false ; else throw UnexpectedInputException ( " " , " \" \" \" \" \" \" " ) ; } if ( optionMap . find ( X_offset_type ) != optionMap . end ( ) ) { std :: wstring offsets = transcodeToStdWString ( optionMap . find ( X_offset_type ) -> second . c_str ( ) ) ; std :: transform ( offsets . begin ( ) , offsets . end ( ) , offsets . begin ( ) , towlower ) ; if ( offsets == L" " ) { include_byte_offsets = true ; include_char_offsets = true ; include_edt_offsets = true ; } else if ( offsets == L" " ) { include_byte_offsets = true ; include_char_offsets = false ; include_edt_offsets = false ; } else if ( offsets == L" " ) { include_byte_offsets = false ; include_char_offsets = true ; include_edt_offsets = false ; } else if ( offsets == L" " || offsets == L" " ) { include_byte_offsets = false ; include_char_offsets = false ; include_edt_offsets = true ; } else { throw UnexpectedInputException ( " " , " \" \" \" \" \" \" \" \" \" \" " ) ; } } }
Option attributes:
Option attributes :
// Start with the default options
 // Check parameter file values
 // Set boolean options
 // Decide how to encode parse trees.
 // Decide which offset types we should include.
