<commit_before>(function () {

	var Text, Interpolator, Triple, Section;

	TextFragment = function TextFragment ( options ) {
		initFragment( this, options );
	};

	TextFragment.prototype = {
		createItem: function ( options ) {
			if ( typeof options.descriptor === 'string' ) {
				return new Text( options.descriptor );
			}

			switch ( options.descriptor.t ) {
				case INTERPOLATOR: return new Interpolator( options );
				case TRIPLE: return new Triple( options );
				case SECTION: return new Section( options );

				default: throw 'Something went wrong in a rather interesting way';
			}
		},


		bubble: function () {
			this.owner.bubble();
		},

		teardown: function () {
			var numItems, i;

			numItems = this.items.length;
			for ( i=0; i<numItems; i+=1 ) {
				this.items[i].teardown();
			}
		},

		getValue: function () {
			var value;
			
			// Accommodate boolean attributes
			if ( this.items.length === 1 && this.items[0].type === INTERPOLATOR ) {
				value = this.items[0].value;
				if ( value !== undefined ) {
					return value;
				}
			}
			
			return this.toString();
		},

		toString: function () {
			return this.items.join( '' );
		}
	};

<commit_msg>added toJson method to text fragments<commit_after>(function () {

	var Text, Interpolator, Triple, Section;

	TextFragment = function TextFragment ( options ) {
		initFragment( this, options );
	};

	TextFragment.prototype = {
		createItem: function ( options ) {
			if ( typeof options.descriptor === 'string' ) {
				return new Text( options.descriptor );
			}

			switch ( options.descriptor.t ) {
				case INTERPOLATOR: return new Interpolator( options );
				case TRIPLE: return new Triple( options );
				case SECTION: return new Section( options );

				default: throw 'Something went wrong in a rather interesting way';
			}
		},


		bubble: function () {
			this.owner.bubble();
		},

		teardown: function () {
			var numItems, i;

			numItems = this.items.length;
			for ( i=0; i<numItems; i+=1 ) {
				this.items[i].teardown();
			}
		},

		getValue: function () {
			var value;
			
			// Accommodate boolean attributes
			if ( this.items.length === 1 && this.items[0].type === INTERPOLATOR ) {
				value = this.items[0].value;
				if ( value !== undefined ) {
					return value;
				}
			}
			
			return this.toString();
		},

		toString: function () {
			return this.items.join( '' );
		},

		toJson: function () {
			var str, json;

			str = this.toString();

			try {
				json = JSON.parse( str );
			} catch ( err ) {
				json = str;
			}

			return json;
		}
	};


{'fraction_non_alphanumeric': 0.1391270459859704, 'fraction_numerical': 0.003897116134060795, 'mean_word_length': 2.6988472622478388, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5807159', 'n_tokens_mistral': 1011, 'n_tokens_neox': 799, 'n_words': 212}