from model.lstm_model import LSTMModel from model.persistence.model_persistence import ModelEvaluation from utils.nn_utils import NNUtils from utils.config_loader import readConfig def showProgress(currentStep, totalSteps, epoch): perc = (float(currentStep) / float(totalSteps)) * 100.0 temp = perc / 10 sys.stdout.write('\r[{0}] {1}% - {2}/{3} - Epoch {4}'.format( '#' * int(temp), (perc), currentStep, totalSteps, epoch)) sys.stdout.flush() print 'loading configuration' config, modelConfig = readConfig() print 'configuration loaded' print 'loading word embeddings : {} - embedding size : {}'.format( modelConfig.embeddingType, modelConfig.embeddingSize) sentenceLoader, predicateLoader = getEmbeddings() print 'sentenceLoader shape {}'.format(sentenceLoader.weights.shape) nnUtils = NNUtils.Instance() nnUtils.setWordUtils(sentenceLoader.word2idx, sentenceLoader.idx2word) print 'loaded' print 'loading corpus' csvFiles = [ config.convertedCorpusDir + '/propbank_training.csv',
sentences, predicates, aux, roles) # the order is important structure.append((sentences, predicates, aux, roles)) return structure def convertAndSave(self, featureFile): temp = self.convert() self.save(temp, featureFile) if __name__ == '__main__': from embeddings.emb_loader import W2VModel from utils.config_loader import readConfig readConfig() options = { "npzFile": "../../resources/embeddings/wordEmbeddings.npy", "npzModel": "../../resources/embeddings/wordEmbeddings", "vecFile": "../../resources/embeddings/model.vec", "w2idxFile": "../../resources/embeddings/vocabulary.json" } model = W2VModel() model.setResources(options) loader = EmbeddingLoader(model) loader.process() csvFiles = [ '../../resources/corpus/converted/propbank_training.csv', '../../resources/corpus/converted/propbank_test.csv' ]