def addWordEncounter(self, word): if word not in self.stochasticGrammar.wordData: newWord = Word(word, self.dataGranularity) newWord.initializeValues(self.initialValue) self.stochasticGrammar.wordData[word] = newWord return True return False
def wordTest(inputPath, distributionGranularity, wordGranularity, tempFile): salaryDictionary = SalaryDistribution(inputPath, distributionGranularity) salaryDictionary.parse() test = Word("Potato", wordGranularity) test.initializeValues(salaryDictionary) with open(tempFile, 'w') as dataDump: dataDump.write(test.configure()) with open(tempFile, 'r') as reReading: for line in reReading: try: check=Word.fromFileString(line) print check.configure() check.increment(8200, 3, 0.75) print ("~~~~~~~") print check.configure() except NameError: continue