# read name meanings, put into class
# Just the classes are in this file, used in NDtest.py

class NameDecoder:

        # object initialization function
        # called as "NameDecoder()"
        def __init__(self):
                self.nameD = {}  # empty dictionary

                f = open("names.csv","rU")
                for line in f:
                        fields = line.split(",") # cut at the commas
                        # fields is now a list of substrings
                        name = fields[0]
                        meaning = fields[1]
                        self.nameD[name] = meaning # store meaning in dictionary

        def define(self, name):
                # always check to see if name is in dictionary
                # before you look it up - otherwise you might
                # get crashes!
                if name in self.nameD:
                        # retrieve definition and return it
                        return self.nameD[name]
                else:
                        return "nothing that I know of"
                        
