<commit_before><script language="JavaScript" type="text/javascript">
<!-- Begin

function simplify( name )	{
	name = name.replace(/ \(.*\) /,' ');
	name = name.replace(/( |)(n\. gen\.)( |)/,' ');
	name = name.replace(/( |)(n\. sp\.)( |)/,' ');
	name = name.replace(/^ /,'');
	name = name.replace(/ $/,'');
	return name;
}

function checkForm()	{
// informal formatting
	var frm = document.forms[0];
	var rows = frm.row_token.length;
	var errors = "";
	var lasterrors = "";
	var lastocc = 0;
	var hasreid = new Array();

	// need to know which occurrences are reidentified
	// some strong assumptions: the reid is of the last occurrence
	for ( var i=0; i < rows; i++ )	{
		if ( frm.taxon_name[i].value != "" && frm.reid_no[i].value > 0 && lastocc > 0 && lastocc == frm.occurrence_no[i].value )	{
			hasreid[lastocc] = hasreid[lastocc] + 1;
		} else if ( frm.taxon_name[i].value != "" && frm.reid_no[i].value == 0 )	{
			lastocc = frm.occurrence_no[i].value;
			hasreid[lastocc] = 0;
		}
	}

	// main pass
	for ( var i=0; i < rows; i++ )	{
		if ( frm.taxon_name[i].value != "" )	{
			var taxonName = frm.taxon_name[i].value;

			// replace informals with dummy values for checking
			//  purposes
			taxonName = taxonName.replace(/^<.*> /,'Genus ');
			taxonName = taxonName.replace(/ <.*> /,' (Subgenus) ');
			taxonName = taxonName.replace(/ <.*>$/,' species');

			// checks for duplicates will need to ignore subgenera,
			//  n. gen., and n. sp.
			var simpleName = frm.taxon_name[i].value;
			simpleName = simplify( simpleName );

			// need this workaround because hasreid[0] is undefined
			var has = 0;
			if ( frm.occurrence_no[i].value > 0 )	{
				has = hasreid[frm.occurrence_no[i].value];
			}

			// check for dupes
			// revised 20.2.08 so only current IDs are matched,
			//  as opposed to occurrences since reIDed
			for ( var j=0; j < i; j++ )	{
				var simpleName2 = frm.taxon_name[j].value;
				simpleName2 = simplify( simpleName2 );
				if ( frm.taxon_name[j].value != "" && simpleName == simpleName2 )	{
					var has2 = 0;
					if ( frm.occurrence_no[j].value > 0 )	{
						has2 = hasreid[frm.occurrence_no[j].value];
					}
			// case 1: identical occurrence and its own reID
					if ( frm.occurrence_no[i].value == frm.occurrence_no[j].value && has > 0 )	{
						errors += "* " + simpleName + " and its reID have the same name\n";
					}
			// case 2: identical occurrences with no reIDs
					else if ( has < 1 && has2 < 1 )	{
						errors += "* " + simpleName + " is listed twice\n";
					}
			// case 3: identical reIDs
					if ( frm.reid_no[i].value > 0 && frm.reid_no[j].value > 0 )	{
						errors += "* " + simpleName + " is listed twice\n";
					}
			// case 4: first is a reID and second has no reID
					if ( frm.reid_no[i].value > 0 && has2 < 1 )	{
						errors += "* " + simpleName + " is listed twice\n";
					}
			// case 5: first has no reID and second is a reID
					if ( has < 1 && frm.reid_no[j].value > 0 )	{
						errors += "* " + simpleName + " is listed twice\n";
					}
				}
			}

			lasterrors = errors;
			if ( /^(((\?|aff\.|cf\.|ex gr\.|n\. gen\.|n\. sp\.|sensu lato)( ))|)[A-Z][a-z]+$/.test( taxonName ) )	{
				errors += "* Enter sp. or indet. for indeterminate species or higher taxa";
			} else if ( ! / /.test( taxonName ) )	{
				errors += "* Taxon names must include at least two words";<commit_msg>fixed a bug in check for identical reIDs<commit_after><script language="JavaScript" type="text/javascript">
<!-- Begin

function simplify( name )	{
	name = name.replace(/ \(.*\) /,' ');
	name = name.replace(/( |)(n\. gen\.)( |)/,' ');
	name = name.replace(/( |)(n\. sp\.)( |)/,' ');
	name = name.replace(/^ /,'');
	name = name.replace(/ $/,'');
	return name;
}

function checkForm()	{
// informal formatting
	var frm = document.forms[0];
	var rows = frm.row_token.length;
	var errors = "";
	var lasterrors = "";
	var lastocc = 0;
	var hasreid = new Array();

	// need to know which occurrences are reidentified
	// some strong assumptions: the reid is of the last occurrence
	for ( var i=0; i < rows; i++ )	{
		if ( frm.taxon_name[i].value != "" && frm.reid_no[i].value > 0 && lastocc > 0 && lastocc == frm.occurrence_no[i].value )	{
			hasreid[lastocc] = hasreid[lastocc] + 1;
		} else if ( frm.taxon_name[i].value != "" && frm.reid_no[i].value == 0 )	{
			lastocc = frm.occurrence_no[i].value;
			hasreid[lastocc] = 0;
		}
	}

	// main pass
	for ( var i=0; i < rows; i++ )	{
		if ( frm.taxon_name[i].value != "" )	{
			var taxonName = frm.taxon_name[i].value;

			// replace informals with dummy values for checking
			//  purposes
			taxonName = taxonName.replace(/^<.*> /,'Genus ');
			taxonName = taxonName.replace(/ <.*> /,' (Subgenus) ');
			taxonName = taxonName.replace(/ <.*>$/,' species');

			// checks for duplicates will need to ignore subgenera,
			//  n. gen., and n. sp.
			var simpleName = frm.taxon_name[i].value;
			simpleName = simplify( simpleName );

			// need this workaround because hasreid[0] is undefined
			var has = 0;
			if ( frm.occurrence_no[i].value > 0 )	{
				has = hasreid[frm.occurrence_no[i].value];
			}

			// check for dupes
			// revised 20.2.08 so only current IDs are matched,
			//  as opposed to occurrences since reIDed
			for ( var j=0; j < i; j++ )	{
				var simpleName2 = frm.taxon_name[j].value;
				simpleName2 = simplify( simpleName2 );
				if ( frm.taxon_name[j].value != "" && simpleName == simpleName2 )	{
					var has2 = 0;
					if ( frm.occurrence_no[j].value > 0 )	{
						has2 = hasreid[frm.occurrence_no[j].value];
					}
			// case 1: identical occurrence and its own reID
					if ( frm.occurrence_no[i].value == frm.occurrence_no[j].value && has > 0 )	{
						errors += "* " + simpleName + " and its reID have the same name\n";
					}
			// case 2: identical occurrences with no reIDs
					else if ( has < 1 && has2 < 1 )	{
						errors += "* " + simpleName + " is listed twice\n";
					}
			// case 3: identical reIDs
					if ( frm.reid_no[i].value > 0 && frm.reid_no[j].value > 0 && frm.occurrence_no[i].value == frm.occurrence_no[j].value )	{
						errors += "* " + simpleName + " is listed twice\n";
					}
			// case 4: first is a reID and second has no reID
					if ( frm.reid_no[i].value > 0 && has2 < 1 )	{
						errors += "* " + simpleName + " is listed twice\n";
					}
			// case 5: first has no reID and second is a reID
					if ( has < 1 && frm.reid_no[j].value > 0 )	{
						errors += "* " + simpleName + " is listed twice\n";
					}
				}
			}

			lasterrors = errors;
			if ( /^(((\?|aff\.|cf\.|ex gr\.|n\. gen\.|n\. sp\.|sensu lato)( ))|)[A-Z][a-z]+$/.test( taxonName ) )	{
				errors += "* Enter sp. or indet. for indeterminate species or higher taxa";
			} else if ( ! / /.test( taxonName ) )	{
				errors += "* Taxon names must include at least two words";
{'fraction_non_alphanumeric': 0.1804799057853673, 'fraction_numerical': 0.012365670543206241, 'mean_word_length': 2.587117212249208, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, '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': '1076432', 'n_tokens_mistral': 2997, 'n_tokens_neox': 2508, 'n_words': 652}