<commit_before>
import wikiutils
import logging
from metaprocessor import MetaAdapter, MetaProcessor
from metagrammar import *
from entities import *
import date


class MetaStructure(Entity):
	def __init__(self):
		self.ast = None
		self.adapter = None
		
		self.ges = []
		self.ses = []
		self.apps = []

		self.locations = []
		self.scenarios = []
		
		self.experiments = []
		
		self.releases = []

		self.invalid = []

		self.edges = []
	
	
	def get_ast(self):
		return self.ast

	def get_adapter(self):
		return self.adapter

	def get_descendants(self):
		return self.ges + self.ses + self.apps + self.locations + self.scenarios + self.experiments + self.invalid

	
	
	def find_dependencies(self, entity):
		return [dep[1:3] for dep in self.edges if dep[0] == entity]
	
	def find_edges(self, entity1, entity2):
		return [dep for dep in self.edges if dep[0] == entity1 and dep[1] == entity2]

	def find_relations(self, entity):
		return [dep for dep in self.edges if dep[0] == entity or dep[1] == entity]

	
	def find_enabler(self, id):
		enabler = self.adapter.find(id)
		if enabler in self.ges:
			return enabler
		if enabler in self.ses:
			return enabler
		if isinstance(enabler, InvalidEntity) and enabler.get_keyword() in ['GE', 'SE']:
			return enabler
		return None

	def find_specific_enabler(self, id):
		enabler = self.adapter.find(id)
		return enabler if enabler in self.ses else None

	def find_application(self, id):
		app = self.adapter.find(id)
		if app in self.apps:
			return app
		return None
	
	def find_location(self, id):
		loc = self.adapter.find(id)
		if loc in self.locations:
			return loc
		return None

	def find_scenario(self, id):
		scenario = self.adapter.find(id)
		if scenario in self.scenarios:
			return scenario
		return None
		
	def find_current_release(self):
		rel_dates = [rel.get_date() for rel in self.get_releases()]
		next_upcoming = min([d for d in rel_dates if date.today() < d])
		for rel in self.get_releases():
			if rel.get_date() == next_upcoming:
				return rel
		return None
	
	def get_experiments(self, site = None):
		if site is None:
			return self.experiments
		return [exp for exp in self.experiments if exp.get_site() == site]

	def get_generic_enablers(self):
		return self.ges

	def get_specific_enablers(self):
		return self.ses

	def get_invalid_specific_enablers(self):
		return [e for e in self.invalid if e.get_keyword() == 'SE']

	def get_releases(self):
		return self.releases
		
	def set_ast(self, ast, adapter):
		self.ast = ast
		self.adapter = adapter
		<commit_msg>fix date issue<commit_after>
import wikiutils
import logging
from metaprocessor import MetaAdapter, MetaProcessor
from metagrammar import *
from entities import *
import date


class MetaStructure(Entity):
	def __init__(self):
		self.ast = None
		self.adapter = None
		
		self.ges = []
		self.ses = []
		self.apps = []

		self.locations = []
		self.scenarios = []
		
		self.experiments = []
		
		self.releases = []

		self.invalid = []

		self.edges = []
	
	
	def get_ast(self):
		return self.ast

	def get_adapter(self):
		return self.adapter

	def get_descendants(self):
		return self.ges + self.ses + self.apps + self.locations + self.scenarios + self.experiments + self.invalid

	
	
	def find_dependencies(self, entity):
		return [dep[1:3] for dep in self.edges if dep[0] == entity]
	
	def find_edges(self, entity1, entity2):
		return [dep for dep in self.edges if dep[0] == entity1 and dep[1] == entity2]

	def find_relations(self, entity):
		return [dep for dep in self.edges if dep[0] == entity or dep[1] == entity]

	
	def find_enabler(self, id):
		enabler = self.adapter.find(id)
		if enabler in self.ges:
			return enabler
		if enabler in self.ses:
			return enabler
		if isinstance(enabler, InvalidEntity) and enabler.get_keyword() in ['GE', 'SE']:
			return enabler
		return None

	def find_specific_enabler(self, id):
		enabler = self.adapter.find(id)
		return enabler if enabler in self.ses else None

	def find_application(self, id):
		app = self.adapter.find(id)
		if app in self.apps:
			return app
		return None
	
	def find_location(self, id):
		loc = self.adapter.find(id)
		if loc in self.locations:
			return loc
		return None

	def find_scenario(self, id):
		scenario = self.adapter.find(id)
		if scenario in self.scenarios:
			return scenario
		return None
		
	def find_current_release(self):
		rel_dates = [rel.get_date() for rel in self.get_releases()]
		rel_date_upcoming = [d for d in rel_dates if date.today() <= d]
		if len(rel_date_upcoming) > 0:
			latest = min(rel_date_upcoming)
		else:
			latest = max(rel_dates)
		
		for rel in self.get_releases():
			if rel.get_date() == latest:
				return rel
		return None
	
	def get_experiments(self, site = None):
		if site is None:
			return self.experiments
		return [exp for exp in self.experiments if exp.get_site() == site]

	def get_generic_enablers(self):
		return self.ges

	def get_specific_enablers(self):
		return self.ses

	def get_invalid_specific_enablers(self):
		return [e for e in self.invalid if e.get_keyword() == 'SE']

	def get_releases(self):
		return self.releases
		
	def set_ast(self, ast, adapter):
		self.ast = ast
		self.adapter = adapter
		
{'fraction_non_alphanumeric': 0.10644041650597763, 'fraction_numerical': 0.004435017354415735, 'mean_word_length': 3.652017937219731, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '4354506', 'n_tokens_mistral': 2025, 'n_tokens_neox': 1763, 'n_words': 520}