def getID_FromLongestTerm(text, lookupDict):
	"""
	Given a span of text, this method will tokenize and then identify the set of entities that exist in the text. It will prioritise long terms first in order to reduce ambiguity.

	Example: For the text "the cheese pizza is good" and the lookup dict of {("cheese","pizza"):1, ("pizza",):2}, the algorithm will identify "cheese pizza" as an entity with ID 1. Those tokens will then be removed, and so "pizza" will not be identified.

	:param text: The text span to be searched. It will be tokenized using the very naive method of splitting by whitespace.
	:param lookupDict: Dictionary that maps tokenized terms to a particular ID
	:type text: str
	:type lookupDict: dict with tuple keys
	:returns: IDs of all entities identified in text
	:rtype: set
	"""

	terms = set()

	# Lowercase and do very naive tokenization of the text
	np = text.lower().split()

	# The length of each search string will decrease from the full length
	# of the text down to 1
	for l in reversed(range(1, len(np)+1)):
		# We move the search window through the text
		for i in range(len(np)-l+1):
			# Extract that window of text
			s = tuple(np[i:i+l])
			# Search for it in the dictionary
			if s in lookupDict:
				sTxt = " ".join(np[i:i+l])

				for wordlistid,tid in lookupDict[s]:
					#myTxt = "%s\t%s" % (tid,sTxt)
					#terms.add((wordlistid,myTxt))
					terms.add((wordlistid,sTxt))
				# If found, save the ID(s) in the dictionar
				#terms.update(lookupDict[s])
				
				# And blank it out
				np[i:i+l] = [ "" for _ in range(l) ]

	return terms