import re
from ..core.lexeme_parser import LexemeParser

class TextParser:
	@staticmethod
	def sanitizeText(text):
		# remove all non-word symbols from the text
		# allow full Ukrainian alphabet + apostrophe
		# replace other symbols with " " to prevent random words concatenation
		uaSmall = "а-яієїґ"
		uaBig = "А-ЯІЄЇҐ"
		uaApostr = "\'"
		excludePattern = "[^" + uaSmall + uaBig + uaApostr + "]"
		text = re.sub(excludePattern, " ", text)
		return text

	@staticmethod
	def textToWords(text):
		text = TextParser.sanitizeText(text)
		words = text.split()
		return words