def readFiles(self, instancesFilename): print('Reading saved files...', instancesFilename, config.questionDictFile(), config.answerDictFile(), config.qaDictFile()) with open(instancesFilename, "r") as inFile: instances = json.load(inFile) with open(config.questionDictFile(), "rb") as inFile: self.questionDict = pickle.load(inFile) with open(config.answerDictFile(), "rb") as inFile: self.answerDict = pickle.load(inFile) with open(config.qaDictFile(), "rb") as inFile: self.qaDict = pickle.load(inFile) return instances
def writeFiles(self, instances, instancesFilename): with open(instancesFilename, "w") as outFile: json.dump(instances, outFile) with open(config.questionDictFile(), "wb") as outFile: pickle.dump(self.questionDict, outFile) with open(config.answerDictFile(), "wb") as outFile: pickle.dump(self.answerDict, outFile) with open(config.qaDictFile(), "wb") as outFile: pickle.dump(self.qaDict, outFile)
def writeVocabs(self): with open(config.questionDictFile(), "wb") as outFile: pickle.dump(self.questionDict, outFile) with open(config.answerDictFile(), "wb") as outFile: pickle.dump(self.answerDict, outFile) with open(config.qaDictFile(), "wb") as outFile: pickle.dump(self.qaDict, outFile) with open(config.sceneDictFile(), "wb") as outFile: pickle.dump(self.sceneDict, outFile)
def readFiles(self, instancesFilename): with open(instancesFilename, "r") as inFile: instances = json.load(inFile) with open(config.questionDictFile(), "rb") as inFile: self.questionDict = pickle.load(inFile) with open(config.answerDictFile(), "rb") as inFile: self.answerDict = pickle.load(inFile) with open(config.qaDictFile(), "rb") as inFile: self.qaDict = pickle.load(inFile) return instances
def loadVocabs(self): if os.path.exists(config.qaDictFile()) and os.path.exists( config.sceneDictFile()): print("load dictionaries") with open(config.questionDictFile(), "rb") as inFile: self.questionDict = pickle.load(inFile) with open(config.answerDictFile(), "rb") as inFile: self.answerDict = pickle.load(inFile) with open(config.qaDictFile(), "rb") as inFile: self.qaDict = pickle.load(inFile) with open(config.sceneDictFile(), "rb") as inFile: self.sceneDict = pickle.load(inFile)