result_string = "" print("=============================== Filtering data and performing operations ===============================") # Gets the first letter for the first IPC class and adding it to the ipc_sectons set variable ipc_sections = set() for doc in documents: if len(doc['ipc_classes']) > 0: ipc_sections.add(doc['ipc_classes'][0][0]) else: print(doc['filename']) print(ipc_sections) ipc_sections = list(ipc_sections) # Creating a class_map variable, which contains a mapping of the IPC class to a number. The classes are ordered inside # the classMap method. This mapping is important because of keras library particularities. class_map = classMap(ipc_sections) ipc_sections.sort() embedding_generator = MongoDBMetaEmbeddingGenerator(documents, "section", class_map, len(ipc_sections), serve_forever=True) print("=============================== Create training classes ===============================") #Build a factory for a model adapter model_factory = dl.factory.factory.create('MultilayerKerasRecurrentNN', input_shape=(maxWords, embeddingSize), numNeurouns=len(ipc_sections), numOutputNeurons=len(ipc_sections), layers=layers) model = model_factory.create() model = model.load(model_saved_name) # Geting the test documents collection test_documents = mongodb.get_all_meta(testing_documents_collection) test_embedding_generator = MongoDBMetaEmbeddingGenerator(test_documents, "section", class_map, len(ipc_sections))
result_string = "" print( "=============================== Filtering data and performing operations ===============================" ) # Gets the first letter for the first IPC class and adding it to the ipc_sectons set variable ipc_sections = set() for doc in documents: if len(doc['ipc_classes']) > 0: ipc_sections.add(doc['ipc_classes'][0][0]) else: print(doc['filename']) # Creating a class_map variable, which contains a mapping of the IPC class to a number. The classes are ordered inside # the classMap method. This mapping is important because of keras library particularities. class_map = classMap(list(ipc_sections)) # Rebooting mongodb cursor training_documents = mongodb.get_all_meta(training_documents_collection) # The Generator for metadata and word embedding, its a python generator that returns "embeding, ipc_class embedding_generator = MongoDBMetaEmbeddingGenerator(documents, "section", class_map, len(ipc_sections), serve_forever=True, to_categorical=False) print( "=============================== Create training classes ===============================" ) #Build a factory for a model adapter
else: print(doc['filename']) print(ipc_sections) print(ipc_classes) # Creating a class_map variable, which contains a mapping of the IPC class to a number. The classes are ordered inside # the classMap method. This mapping is important because of keras library particularities. for key in ipc_classes.keys(): model_saved_name = "../TrainedLSTM/keras_rnn_mongo_float_" + key + ".model" result_file_name = "../TrainedLSTM/result_rnn_mongo_float_" + key result_string = "" classes = ipc_classes[key] classes.sort() class_map = classMap(classes) documents = mongodb.get_meta_by_section(training_documents_collection, key) # Rebooting mongodb cursor training_documents = mongodb.get_all_meta(training_documents_collection) # The Generator for metadata and word embedding, its a python generator that returns "embeding, ipc_class embedding_generator = MongoDBMetaEmbeddingGenerator(documents, "class", class_map, len(classes), serve_forever=True) print("=============================== Create training classes " + key + " ===============================") #Build a factory for a model adapter model_factory = dl.factory.factory.create('MultilayerKerasRecurrentNN', input_shape=(maxWords, embeddingSize),