<commit_before>package com.trimc.blogger.commons.type.adapter;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

import com.trimc.blogger.commons.LogManager;
import com.trimc.blogger.commons.exception.AdapterValidationException;
import com.trimc.blogger.commons.type.EngGrammarUpperType;

public final class EngGrammarUpperTypeAdapter {

	public static LogManager logger = new LogManager(EngGrammarUpperTypeAdapter.class);

	public static EngGrammarUpperType findByAbbreviation(String tag) throws AdapterValidationException {
		tag = tag.toLowerCase();

		if ("n".equals(tag)) return EngGrammarUpperType.NOUN;
		if ("n.".equals(tag)) return EngGrammarUpperType.NOUN;
		if ("n.2".equals(tag)) return EngGrammarUpperType.NOUN;
		else if ("v".equals(tag)) return EngGrammarUpperType.VERB;

		throw new AdapterValidationException("Unrecognized Abbreviation (tag = %s)", tag);
	}

	public static String toString(Collection<EngGrammarUpperType> engGrammarUpperTypes) {
		StringBuilder sb = new StringBuilder();

		Iterator<EngGrammarUpperType> iter = engGrammarUpperTypes.iterator();
		while (iter.hasNext()) {
			sb.append(iter.next().toString());
			if (iter.hasNext()) sb.append(", ");
		}

		return sb.toString();
	}

	public static String toString(EngGrammarUpperType... engGrammarUpperTypes) {
		return toString(Arrays.asList(engGrammarUpperTypes));
	}
}<commit_msg>improve adapter method for finding eng grammar upper types<commit_after>package com.trimc.blogger.commons.type.adapter;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

import com.trimc.blogger.commons.LogManager;
import com.trimc.blogger.commons.exception.AdapterValidationException;
import com.trimc.blogger.commons.type.EngGrammarUpperType;

public final class EngGrammarUpperTypeAdapter {

	public static LogManager logger = new LogManager(EngGrammarUpperTypeAdapter.class);

	public static EngGrammarUpperType findByName(String name) {
		for (EngGrammarUpperType value : EngGrammarUpperType.values()) {
			if (value.toString().equalsIgnoreCase(name)) {
				return value;
			}
		}

		return null;
	}

	/**
	 * transforms common abbreviations found in etymological sources 
	 * @param tag
	 * @return {@link EngGrammarUpperType}
	 * @throws AdapterValidationException
	 */
	public static EngGrammarUpperType findByAbbreviation(String tag) throws AdapterValidationException {
		tag = tag.toLowerCase().trim();

		if ("adj.".equals(tag)) return EngGrammarUpperType.ADJECTIVE;
		if ("adj.1".equals(tag)) return EngGrammarUpperType.ADJECTIVE;
		if ("adj.2".equals(tag)) return EngGrammarUpperType.ADJECTIVE;

		else if ("adv".equals(tag)) return EngGrammarUpperType.ADVERB;
		else if ("adv.".equals(tag)) return EngGrammarUpperType.ADVERB;
		else if ("adv.1".equals(tag)) return EngGrammarUpperType.ADVERB;
		else if ("adv.2".equals(tag)) return EngGrammarUpperType.ADVERB;

		else if ("conj".equals(tag)) return EngGrammarUpperType.CONJUNCTION;
		else if ("conj.".equals(tag)) return EngGrammarUpperType.CONJUNCTION;

		else if ("int".equals(tag)) return EngGrammarUpperType.INTERJECTION;
		else if ("int.".equals(tag)) return EngGrammarUpperType.INTERJECTION;
		else if ("int.1".equals(tag)) return EngGrammarUpperType.INTERJECTION;
		else if ("int.2".equals(tag)) return EngGrammarUpperType.INTERJECTION;

		else if ("n".equals(tag)) return EngGrammarUpperType.NOUN;
		else if ("n.".equals(tag)) return EngGrammarUpperType.NOUN;
		else if ("n.1".equals(tag)) return EngGrammarUpperType.NOUN;
		else if ("n.2".equals(tag)) return EngGrammarUpperType.NOUN;
		else if ("n.3".equals(tag)) return EngGrammarUpperType.NOUN;
		else if ("n.4".equals(tag)) return EngGrammarUpperType.NOUN;
		else if ("n.5".equals(tag)) return EngGrammarUpperType.NOUN;

		else if ("prep".equals(tag)) return EngGrammarUpperType.PREPOSITION;
		else if ("prep.".equals(tag)) return EngGrammarUpperType.PREPOSITION;
		else if ("prep.1".equals(tag)) return EngGrammarUpperType.PREPOSITION;
		else if ("prep.2".equals(tag)) return EngGrammarUpperType.PREPOSITION;

		else if ("pron".equals(tag)) return EngGrammarUpperType.PRONOUN;
		else if ("pron.".equals(tag)) return EngGrammarUpperType.PRONOUN;
		else if ("pron.1".equals(tag)) return EngGrammarUpperType.PRONOUN;
		else if ("pron.2".equals(tag)) return EngGrammarUpperType.PRONOUN;
		else if ("pron.3".equals(tag)) return EngGrammarUpperType.PRONOUN;
		else if ("pron.4".equals(tag)) return EngGrammarUpperType.PRONOUN;
		else if ("pron.5".equals(tag)) return EngGrammarUpperType.PRONOUN;

		else if ("prefix".equals(tag)) return EngGrammarUpperType.OTHER;
		else if ("prefix1".equals(tag)) return EngGrammarUpperType.OTHER;
		else if ("suffix".equals(tag)) return EngGrammarUpperType.OTHER;
		else if ("suffix1".equals(tag)) return EngGrammarUpperType.OTHER;

		else if ("v".equals(tag)) return EngGrammarUpperType.VERB;
		else if ("v.".equals(tag)) return EngGrammarUpperType.VERB;
		else if ("v.1".equals(tag)) return EngGrammarUpperType.VERB;
		else if ("v.2".equals(tag)) return EngGrammarUpperType.VERB;
		else if ("v.3".equals(tag)) return EngGrammarUpperType.VERB;
		else if ("v.4".equals(tag)) return EngGrammarUpperType.VERB;
		else if ("v.5".equals(tag)) return EngGrammarUpperType.VERB;

		else if ("comb. form".equals(tag)) return EngGrammarUpperType.OTHER;

		return null;
	}

	public static String toString(Collection<EngGrammarUpperType> engGrammarUpperTypes) {
		StringBuilder sb = new StringBuilder();

		Iterator<EngGrammarUpperType> iter = engGrammarUpperTypes.iterator();
		while (iter.hasNext()) {
			sb.append(iter.next().toString());
			if (iter.hasNext()) sb.append(", ");
		}

		return sb.toString();
	}

	public static String toString(EngGrammarUpperType... engGrammarUpperTypes) {
		return toString(Arrays.asList(engGrammarUpperTypes));
	}
}
{'fraction_non_alphanumeric': 0.12658662092624356, 'fraction_numerical': 0.0044596912521440825, 'mean_word_length': 5.733256351039261, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5741517', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1924, 'n_words': 396}