import re


def clean(text):
	"""Cleans text by: (1) removing obviously non-Coptic text; (2) turning sequences of >=1 newline into a single
	newline; (3) turning sequences of >=1 space into a single space; (4) spacing out ., ·, and :
	:param text: A string of Coptic text
	:return: Cleaned Coptic text
	"""
	text = text.replace(".", " .").replace("·", " ·").replace(":", " : ")
	uncoptic1 = r'\[F[^]]+\]'   # Square brackets if they start with F
	uncoptic2 = r'\|F[^|]+\|'   # Pipe delimiters if they start with F
	uncoptic3 = r'\([^\)]+\)'   # Anything in round brackets
	uncoptic4 = r'[A-Za-z0-9|]' # Latin or numbers, pipe
	uncoptic = "("+"|".join([uncoptic1, uncoptic2, uncoptic3, uncoptic4])+")"

	text = re.sub(uncoptic, '', text)
	text = re.sub(r"\n+", r"\n", text)
	text = re.sub(r" +", r" ", text)

	return text