model module

This module defines the PLASTModel class, which manages the loading and access of various components of a PLAST model, including the Word2Vec model, embeddings, mean embedding, IDF values, and UMAP mapper. Each component is loaded lazily to optimize resource usage.

class plast.model.PLASTModel(config)

Bases: object

Class representing a PLAST model with lazy loading.

Parameters:

config (dict) – Configuration dictionary with file paths for model components.

property model: Word2Vec

Returns the Word2Vec model instance. If the model has not been loaded yet, it loads the model from the path specified in the configuration.

Returns:

Loaded Word2Vec model instance.

Return type:

gensim.models.Word2Vec

property embeddings: Dict[str, Any]

Returns the precomputed embeddings dictionary. If the embeddings have not been loaded yet, it loads them from the path specified in the configuration.

Returns:

Dictionary of embeddings.

Return type:

dict

property mean_embedding: Any

Returns the mean embedding vector. If it has not been loaded yet, it loads it from the path specified in the configuration.

Returns:

Mean embedding vector.

Return type:

Any

property idf: Dict[str, float]

Returns the IDF dictionary. If it has not been loaded yet, it loads it from the path specified in the configuration.

Returns:

Dictionary of IDF values.

Return type:

dict

property umap_mapper: Any

Returns the UMAP mapper instance. If it has not been loaded yet, it loads it from the path specified in the configuration.

Returns:

UMAP mapper object.

Return type:

Any