from oneword import *

def twowordtest(xmldoc):

	situations = xmldoc.getElementsByTagName("situation")
	associations, frameindex = {}, {}
	for sit in situations:
		utterances = parseutterances(sit, associations, method='default')
		#print utterances
		for w in utterances:
			Kreator = minidom.Document()
			meaning = Kreator.createElement("meaning")
			if sit.childNodes[1].nodeName == "frame":
				meaning.appendChild(frames(sit).next().cloneNode(deep=1))
				if not framehash(meaning) in associations[w]:
					associations[w][framehash(meaning)] = 1
				else:
					associations[w][framehash(meaning)] += 1
				frameindex[framehash(meaning)] = meaning
			elif sit.childNodes[1].nodeName == "prop":
				meaning.appendChild(properties(sit).next().cloneNode(deep=1))
				if not framehash(meaning) in associations[w]:
					associations[w][framehash(meaning)] = 1
				else:
					associations[w][framehash(meaning)] += 1
				frameindex[framehash(meaning)] = meaning
			else:
				print "help:"
				print sit.toxml()

	return (associations, frameindex)
	
if __name__ == "__main__":
	xmldoc = minidom.parse("nicecorpus2.xml").documentElement
	twowordtest(xmldoc)
