<commit_before>package com.google.code.regexp;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NamedMatcher implements NamedMatchResult {

	private Matcher matcher;
	private NamedPattern parentPattern;

	NamedMatcher() {
	}

	NamedMatcher(NamedPattern parentPattern, MatchResult matcher) {
		this.parentPattern = parentPattern;
		this.matcher = (Matcher) matcher;
	}

	NamedMatcher(NamedPattern parentPattern, CharSequence input) {
		this.parentPattern = parentPattern;
		this.matcher = parentPattern.pattern().matcher(input);
	}

	public Pattern standardPattern() {
		return matcher.pattern();
	}

	public NamedPattern namedPattern() {
		return parentPattern;
	}

	public NamedMatcher usePattern(NamedPattern newPattern) {
		this.parentPattern = newPattern;
		matcher.usePattern(newPattern.pattern());
		return this;
	}

	public NamedMatcher reset() {
		matcher.reset();
		return this;
	}

	public NamedMatcher reset(CharSequence input) {
		matcher.reset(input);
		return this;
	}

	public boolean matches() {
		return matcher.matches();
	}

	public NamedMatchResult toMatchResult() {
		return new NamedMatcher(this.parentPattern, matcher.toMatchResult());
	}

	public boolean find() {
		return matcher.find();
	}

	public boolean find(int start) {
		return matcher.find(start);
	}

	public boolean lookingAt() {
		return matcher.lookingAt();
	}

	public NamedMatcher appendReplacement(StringBuffer sb, String replacement) {
		matcher.appendReplacement(sb, replacement);
		return this;
	}

	public StringBuffer appendTail(StringBuffer sb) {
		return matcher.appendTail(sb);
	}

	public String group() {
		return matcher.group();
	}

	public String group(int group) {
		return matcher.group(group);
	}

	public int groupCount() {
		return matcher.groupCount();
	}

	public List<String> orderedGroups() {
		ArrayList<String> groups = new ArrayList<String>();
		for (int i = 1; i <= groupCount(); i++) {
			groups.add(group(i));
		}
		return groups;
	}

	public String group(String groupName) {
		return group(groupIndex(groupName));
	}

	public Map<String, String> namedGroups() {
		Map<String, String> result = new LinkedHashMap<String, String>();

		for (int i = 1; i <= groupCount(); i++) {
			String groupName = parentPattern.groupNames().get(i-1);
			String groupValue = matcher.group(i);
			result.put(groupName, groupValue);
		}

		return result;
	}<commit_msg>Fix IndexOutOfBoundsException<commit_after>package com.google.code.regexp;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NamedMatcher implements NamedMatchResult {

	private Matcher matcher;
	private NamedPattern parentPattern;

	NamedMatcher() {
	}

	NamedMatcher(NamedPattern parentPattern, MatchResult matcher) {
		this.parentPattern = parentPattern;
		this.matcher = (Matcher) matcher;
	}

	NamedMatcher(NamedPattern parentPattern, CharSequence input) {
		this.parentPattern = parentPattern;
		this.matcher = parentPattern.pattern().matcher(input);
	}

	public Pattern standardPattern() {
		return matcher.pattern();
	}

	public NamedPattern namedPattern() {
		return parentPattern;
	}

	public NamedMatcher usePattern(NamedPattern newPattern) {
		this.parentPattern = newPattern;
		matcher.usePattern(newPattern.pattern());
		return this;
	}

	public NamedMatcher reset() {
		matcher.reset();
		return this;
	}

	public NamedMatcher reset(CharSequence input) {
		matcher.reset(input);
		return this;
	}

	public boolean matches() {
		return matcher.matches();
	}

	public NamedMatchResult toMatchResult() {
		return new NamedMatcher(this.parentPattern, matcher.toMatchResult());
	}

	public boolean find() {
		return matcher.find();
	}

	public boolean find(int start) {
		return matcher.find(start);
	}

	public boolean lookingAt() {
		return matcher.lookingAt();
	}

	public NamedMatcher appendReplacement(StringBuffer sb, String replacement) {
		matcher.appendReplacement(sb, replacement);
		return this;
	}

	public StringBuffer appendTail(StringBuffer sb) {
		return matcher.appendTail(sb);
	}

	public String group() {
		return matcher.group();
	}

	public String group(int group) {
		return matcher.group(group);
	}

	public int groupCount() {
		return matcher.groupCount();
	}

	public List<String> orderedGroups() {
		ArrayList<String> groups = new ArrayList<String>();
		for (int i = 1; i <= groupCount(); i++) {
			groups.add(group(i));
		}
		return groups;
	}

	public String group(String groupName) {
		return group(groupIndex(groupName));
	}

	public Map<String, String> namedGroups() {
		Map<String, String> result = new LinkedHashMap<String, String>();

		int groupCount = Math.min(groupCount(), parentPattern.groupNames().size());
		for (int i = 1; i <= groupCount; i++) {
			String groupName = parentPattern.groupNames().get(i-1);
			String groupValue = matcher.group(i);
			result.put(groupName, groupValue);
		}

		return result;
	}
{'fraction_non_alphanumeric': 0.11605415860735009, 'fraction_numerical': 0.0011605415860735009, 'mean_word_length': 4.758351893095768, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, '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': '4507386', 'n_tokens_mistral': 1720, 'n_tokens_neox': 1587, 'n_words': 379}