pyabsa.tasks.CodeDefectDetection

Subpackages

Package Contents

Classes

CDDTrainer

Trainer class for training PyABSA models

CDDConfigManager

Simple object for storing attributes.

BERTCDDModelList

Built-in mutable sequence.

GloVeCDDModelList

Built-in mutable sequence.

CDDDatasetList

Text Classification or Sentiment analysis datasets

CodeDefectDetector

Predictor

class pyabsa.tasks.CodeDefectDetection.CDDTrainer(config: pyabsa.tasks.CodeDefectDetection.configuration.cdd_configuration.CDDConfigManager = None, dataset=None, from_checkpoint: str = None, checkpoint_save_mode: int = ModelSaveOption.SAVE_MODEL_STATE_DICT, auto_device: bool | str = DeviceTypeOption.AUTO, path_to_save=None, load_aug=False)[source]

Bases: pyabsa.framework.trainer_class.trainer_template.Trainer

Trainer class for training PyABSA models

class pyabsa.tasks.CodeDefectDetection.CDDConfigManager(args, **kwargs)[source]

Bases: pyabsa.framework.configuration_class.configuration_template.ConfigManager

Simple object for storing attributes.

Implements equality by attribute names and values, and provides a simple string representation.

static set_cdd_config(configType: str, newitem: dict)[source]
static set_cdd_config_base(newitem)[source]
static get_cdd_config_base()[source]
class pyabsa.tasks.CodeDefectDetection.BERTCDDModelList[source]

Bases: list

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

BERT_MLP
BERT
class pyabsa.tasks.CodeDefectDetection.GloVeCDDModelList[source]

Bases: list

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

LSTM
class pyabsa.tasks.CodeDefectDetection.CDDDatasetList[source]

Bases: list

Text Classification or Sentiment analysis datasets

Promise
GHPR
Devign
class pyabsa.tasks.CodeDefectDetection.CodeDefectDetector(checkpoint=None, cal_perplexity=False, **kwargs)[source]

Bases: pyabsa.framework.prediction_class.predictor_template.InferenceModel

task_code
_log_write_args()[source]
batch_infer(target_file=None, print_result=True, save_result=False, ignore_error=True, **kwargs)[source]

Perform batch inference on a given target file.

Args: - target_file: A file containing text inputs to perform inference on - print_result: Whether to print the result of each prediction - save_result: Whether to save the result of each prediction - ignore_error: Whether to ignore errors encountered during inference - **kwargs: Additional keyword arguments to be passed to batch_predict method

Returns: - A list of prediction results

infer(text: str | list = None, print_result=True, ignore_error=True, **kwargs)[source]

Perform inference on a given text input.

Args: - text: The text inputs to perform inference on - print_result: Whether to print the result of each prediction - ignore_error: Whether to ignore errors encountered during inference - **kwargs: Additional keyword arguments to be passed to predict method

Returns: - A list of prediction results

batch_predict(target_file=None, print_result=True, save_result=False, ignore_error=True, **kwargs)[source]

Predict from a file of labelences. param: target_file: the file path of the labelences to be predicted. param: print_result: whether to print the result. param: save_result: whether to save the result. param: ignore_error: whether to ignore the error when predicting. param: kwargs: other parameters.

predict(text: str | list = None, print_result=True, ignore_error=True, **kwargs)[source]

Predict from a labelence or a list of labelences. param: text: the labelence or a list of labelence to be predicted. param: print_result: whether to print the result. param: ignore_error: whether to ignore the error when predicting. param: kwargs: other parameters.

_run_prediction(save_path=None, print_result=True)[source]

This method should be implemented in the subclass for running predictions using the trained model.

Parameters:

kwargs – additional keyword arguments

Returns:

predicted labels or other prediction outputs

clear_input_samples()[source]
class pyabsa.tasks.CodeDefectDetection.Predictor(checkpoint=None, cal_perplexity=False, **kwargs)[source]

Bases: CodeDefectDetector