<commit_before>package ingraph.cypher2relalg.factories

import java.util.HashMap
import org.eclipse.xtend.lib.annotations.Accessors
import relalg.NamedElement
import relalg.RelalgFactory
import relalg.RelalgContainer

abstract class NamedElementFactory<TNamedElement extends NamedElement> {

	protected extension RelalgFactory factory = RelalgFactory.eINSTANCE
	protected final RelalgContainer container

	new(RelalgContainer container) {
		this.container = container
	}

	// ensure that we generate unique names in the compiler
	static var n = 1;
	@Accessors(PUBLIC_GETTER)
	val elements = new HashMap<String, TNamedElement>

	def createElement(String elementName) {
		val variableName = elementName ?: generateName

		if (elements.get(variableName) === null) {
			val variable = createSpecificNamedElement => [
				name = variableName
				it.namedElementContainer = this.container
			]
			elements.put(variableName, variable)
		}

		elements.get(variableName)
	}

	/**
	 * Indicates if this factory is aware of the element by its name,
	 * i.e. the element has ever been created by this factory instance.
	 */
	def hasElement(String elementName) {
		return (elements.get(elementName) !== null)
	}

	/**
	 * Returns the element by name this factory is aware of it,
	 * i.e. the element has ever been created by this factory instance.
	 *
	 * Otherwise returns null.
	 */
	def TNamedElement getElement(String elementName) {
		return elements.get(elementName)
	}

	def generateName() {
		'_e' + n++;
	}

	def TNamedElement createSpecificNamedElement()
}
<commit_msg>cypher2relalg: hide counter for dontCare variable names<commit_after>package ingraph.cypher2relalg.factories

import java.util.HashMap
import org.eclipse.xtend.lib.annotations.Accessors
import relalg.NamedElement
import relalg.RelalgFactory
import relalg.RelalgContainer

abstract class NamedElementFactory<TNamedElement extends NamedElement> {

	protected extension RelalgFactory factory = RelalgFactory.eINSTANCE
	protected final RelalgContainer container

	new(RelalgContainer container) {
		this.container = container
	}

	// ensure that we generate unique names in the compiler
	private static var n = 1;
	@Accessors(PUBLIC_GETTER)
	val elements = new HashMap<String, TNamedElement>

	def createElement(String elementName) {
		val variableName = elementName ?: generateName

		if (elements.get(variableName) === null) {
			val variable = createSpecificNamedElement => [
				name = variableName
				it.namedElementContainer = this.container
			]
			elements.put(variableName, variable)
		}

		elements.get(variableName)
	}

	/**
	 * Indicates if this factory is aware of the element by its name,
	 * i.e. the element has ever been created by this factory instance.
	 */
	def hasElement(String elementName) {
		return (elements.get(elementName) !== null)
	}

	/**
	 * Returns the element by name this factory is aware of it,
	 * i.e. the element has ever been created by this factory instance.
	 *
	 * Otherwise returns null.
	 */
	def TNamedElement getElement(String elementName) {
		return elements.get(elementName)
	}

	def generateName() {
		'_e' + n++;
	}

	def TNamedElement createSpecificNamedElement()
}

{'fraction_non_alphanumeric': 0.08018867924528301, 'fraction_numerical': 0.0015723270440251573, 'mean_word_length': 4.409863945578231, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '4337566', 'n_tokens_mistral': 976, 'n_tokens_neox': 891, 'n_words': 279}