import sys
from LineMap import LineMap

class Words:
    def __init__(self,f):
	self.file = f
	self.map = LineMap()

    def loop(self):
	input = ""
	while not input == "prettypleaseexit":
	    print "Enter a word to look up in ", self.file, " or 'prettypleaseexit'	to quit"
	    input = sys.stdin.readline().rstrip()
	    if not input == "prettypleaseexit":
		self.loadfile()
		print self.map.lookup(input)
    
    def loadfile(self):
	self.map = LineMap()
	f = open(self.file, 'r')
	lineno = 1
	for line in f:
	    words = line.lower().split()
	    for w in words:
		self.map.add(w,lineno)
	    lineno = lineno + 1
