# -*- encoding: iso-8859-1 -*-

"""sucht Einträge mit mehr als drei Sonderzeichen.
"""

import re, sys
sys.path.append("../")
import classEntry02


def printTxt(entryList):
	f = open ("../../../res/teilergebnisse/02wl4Sonderz.txt", "a") 
	p = classEntry02.Entry(entryList)
	if re.search("(.*(AE|OE|UE|SS).*){4,}", " ".join(p.getWl1())):
			f.write("WL1: " + " ".join(p.getWl1()) + "\n")
			f.write("WL2: " + " ".join(p.getWl2()) + "\n")
			f.write("\n")	
	if re.search("(.*(AE|OE|UE|SS).*){4,}", " ".join(p.getWl2())):
			f.write("WL1: " + " ".join(p.getWl1()) + "\n")
			f.write("WL2: " + " ".join(p.getWl2()) + "\n")
			f.write("\n")				


if __name__ == "__main__":
	lexicon = open("../../../res/01WAT.txt")
	wholeEntry = []
	countEntry = 0
	line = lexicon.readline()
	while line:
		line = line.strip()
		if re.search("ID:", line):
			if wholeEntry and wholeEntry[0] is not "":
				countEntry += 1
				printTxt(wholeEntry)
			wholeEntry = []
		wholeEntry.append(line)
		line = lexicon.readline()
	printTxt(wholeEntry)
	print "Anzahl der Einträge: ", countEntry
