src.core.ngram package#

Submodules#

src.core.ngram.ngram module#

class src.core.ngram.ngram.NGRAM(config_dict)[source]#

Bases: BOW

A class to run NGRAM data preprocessing, training and inference

Parameters:

config_dict (dict) – Config Params Dictionary

fit(text_ls=None, y=None)[source]#

Fits NGRAM algo on preprocessed text

Parameters:
  • text_ls (list, optional) – List of preprocessec strings, defaults to None

  • y (list, optional) – Labels, defaults to None

fit_transform(text_ls=None, y=None)[source]#

Fits and Transforms preprocessed text

Parameters:
  • text_ls (list, optional) – List of preprocessec strings, defaults to None

  • y (list, optional) – Labels, defaults to None

Returns:

Word vectors, Labels

Return type:

tuple (numpy.ndarray [num_samples, num_vocab], numpy.ndarray [num_samples, num_vocab])

run()[source]#

Runs NGRAM Fit, Transform and saves output

save_output(X, y)[source]#

Saves Training and Inference results

Parameters:
  • X (numpy.ndarray (num_samples, num_vocab)) – Word vectors

  • y (list, optional) – Labels, defaults to None

transform(text_ls=None, y=None)[source]#

Transforms preprocessed text

Parameters:
  • text_ls (list, optional) – List of preprocessec strings, defaults to None

  • y (list, optional) – Labels, defaults to None

Returns:

Word vectors, Labels

Return type:

tuple (numpy.ndarray [num_samples, num_vocab], numpy.ndarray [num_samples, num_vocab])

Module contents#