Package com.logicaldoc.ai.serializer
Class Serializer
java.lang.Object
com.logicaldoc.ai.serializer.Serializer
- Direct Known Subclasses:
DocumentSerializer
,FileSerializer
Takes care of serializing / deserializing the files required by an
AIModel
- Since:
- 9.2
- Author:
- Marco Meschieri - LogicalDOC
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
exportModel
(AIModel<?, ?> model, File file) Exports into an zip archive this model plus the training filesabstract String
Retrieves a reference (path, id or other) to a file used by the modelimportModel
(String modelName, long tenantId, File file) Imports a model from a provided archive, if present it saves the trained file and the training data but it does not store the model itself in the database.abstract InputStream
loadTrainedModel
(AIModel<?, ?> model) abstract InputStream
loadTrainingData
(AIModel<?, ?> model) abstract void
saveTrainedModel
(AIModel<?, ?> model, InputStream data) Saves the trained model, the input stream gets closedabstract void
saveTrainingData
(AIModel<?, ?> model, InputStream data) Saves the training data set, the input stream gets closed
-
Constructor Details
-
Serializer
public Serializer()
-
-
Method Details
-
loadTrainingData
public abstract InputStream loadTrainingData(AIModel<?, ?> model) throws IOException, com.logicaldoc.core.PersistenceException- Throws:
IOException
com.logicaldoc.core.PersistenceException
-
loadTrainedModel
public abstract InputStream loadTrainedModel(AIModel<?, ?> model) throws IOException, com.logicaldoc.core.PersistenceException- Throws:
IOException
com.logicaldoc.core.PersistenceException
-
saveTrainingData
public abstract void saveTrainingData(AIModel<?, ?> model, InputStream data) throws IOException, com.logicaldoc.core.PersistenceExceptionSaves the training data set, the input stream gets closed- Parameters:
model
- The modeldata
- The data to save- Throws:
IOException
- Error storing the training datacom.logicaldoc.core.PersistenceException
- Error in the data layer
-
saveTrainedModel
public abstract void saveTrainedModel(AIModel<?, ?> model, InputStream data) throws IOException, com.logicaldoc.core.PersistenceExceptionSaves the trained model, the input stream gets closed- Parameters:
model
- The modeldata
- The data to save- Throws:
IOException
- Error storing the modelcom.logicaldoc.core.PersistenceException
- Error in the data layer
-
getFile
public abstract String getFile(AIModel<?, ?> model, String suffix) throws IOException, com.logicaldoc.core.PersistenceExceptionRetrieves a reference (path, id or other) to a file used by the model- Parameters:
model
- The modelsuffix
- The file suffix- Returns:
- the file's reference
- Throws:
IOException
- Error retrieving the filecom.logicaldoc.core.PersistenceException
- Error in the data layer
-
exportModel
public void exportModel(AIModel<?, ?> model, File file) throws IOException, com.logicaldoc.core.PersistenceExceptionExports into an zip archive this model plus the training files- Parameters:
model
- The model to exportfile
- The archive to export to- Throws:
IOException
- I/O errorcom.logicaldoc.core.PersistenceException
- Error in the data layers
-
importModel
public AIModel importModel(String modelName, long tenantId, File file) throws IOException, com.logicaldoc.core.PersistenceException Imports a model from a provided archive, if present it saves the trained file and the training data but it does not store the model itself in the database.- Parameters:
modelName
- Name of the new model to create or an existing one to overridetenantId
- Identifier of the tenantfile
- The archive containing model definition and it's trained data- Returns:
- The model extracted from the archive, not stored in the database
- Throws:
IOException
- Generic IO Errorcom.logicaldoc.core.PersistenceException
- Error in the data layers
-