<commit_before>'use strict';

const markerBegin = '<x:xmpmeta';
const markerEnd = '</x:xmpmeta>';

const bufferLimit = 65536;

const knownTags = [
	'MicrosoftPhoto:LastKeywordXMP',
	'MicrosoftPhoto:LastKeywordIPTC',
	'dc:title',
	'dc:description',
	'xmp:Rating',
	'MicrosoftPhoto:Rating'
];

let fs = require('fs');

let bufferToPromise = (buffer) => new Promise((resolve, reject) => {
	if (!Buffer.isBuffer(buffer)) reject('Not a Buffer');
	else {
		let data = {};
		let offsetBegin = buffer.indexOf(markerBegin);
		if (offsetBegin) {
			let offsetEnd = buffer.indexOf(markerEnd);
			if (offsetEnd) {
				let xmlBuffer = buffer.slice(offsetBegin, offsetEnd + markerEnd.length);
				let parser = require('sax').parser(true);
				let nodeName;

				parser.onerror = (err) => reject(err);
				parser.onend = () => resolve(data);

				parser.onopentag = function (node) {
					if (knownTags.indexOf(node.name) != -1) nodeName = node.name;
				};
<commit_msg>Add envelopeTags to avoid values interference<commit_after>'use strict';

const markerBegin = '<x:xmpmeta';
const markerEnd = '</x:xmpmeta>';

const bufferLimit = 65536;

const knownTags = [
	'MicrosoftPhoto:LastKeywordXMP',
	'MicrosoftPhoto:LastKeywordIPTC',
	'dc:title',
	'dc:description',
	'xmp:Rating',
	'MicrosoftPhoto:Rating'

const envelopeTags = [
	'rdf:Bag',
	'rdf:Alt',
	'rdf:Seq',
	'rdf:li'
];

let fs = require('fs');

let bufferToPromise = (buffer) => new Promise((resolve, reject) => {
	if (!Buffer.isBuffer(buffer)) reject('Not a Buffer');
	else {
		let data = {};
		let offsetBegin = buffer.indexOf(markerBegin);
		if (offsetBegin) {
			let offsetEnd = buffer.indexOf(markerEnd);
			if (offsetEnd) {
				let xmlBuffer = buffer.slice(offsetBegin, offsetEnd + markerEnd.length);
				let parser = require('sax').parser(true);
				let nodeName;

				parser.onerror = (err) => reject(err);
				parser.onend = () => resolve(data);

				parser.onopentag = function (node) {
					if (knownTags.indexOf(node.name) != -1) nodeName = node.name;
					else if (envelopeTags.indexOf(node.name) == -1) nodeName = null;
				};

{'fraction_non_alphanumeric': 0.16138328530259366, 'fraction_numerical': 0.006243996157540826, 'mean_word_length': 4.438642297650131, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1703808', 'n_tokens_mistral': 784, 'n_tokens_neox': 703, 'n_words': 155}