pyabsa.tasks.TextClassification.prediction.text_classifier
Module Contents
Classes
- class pyabsa.tasks.TextClassification.prediction.text_classifier.TextClassifier(checkpoint=None, cal_perplexity=False, **kwargs)[source]
Bases:
pyabsa.framework.prediction_class.predictor_template.InferenceModel
- batch_infer(target_file=None, print_result=True, save_result=False, ignore_error=True, defense: str = None, **kwargs)[source]
Batch predicts the sentiment of a target file using the model. :param target_file: The path to the target file. :param print_result: Whether to print the result. :param save_result: Whether to save the result. :param ignore_error: Whether to ignore errors and continue. :param defense: The adversarial defense to apply to the input text. :param **kwargs: Additional keyword arguments. :return: The predicted sentiment labels.
- infer(text: Union[str, list] = None, print_result=True, ignore_error=True, defense: str = None, **kwargs)[source]
Predicts the sentiment of a text using the model. :param text: The input text. :param print_result: Whether to print the result. :param ignore_error: Whether to ignore errors and continue. :param defense: The adversarial defense to apply to the input text. :param **kwargs: Additional keyword arguments. :return: The predicted sentiment labels.
- batch_predict(target_file=None, print_result=True, save_result=False, ignore_error=True, **kwargs)[source]
Predict from a file of sentences. param: target_file: the file path of the sentences 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: Union[str, list] = None, print_result=True, ignore_error=True, **kwargs)[source]
Predict from a sentence or a list of sentences. param: text: the sentence or a list of sentence 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.
- class pyabsa.tasks.TextClassification.prediction.text_classifier.Predictor(checkpoint=None, cal_perplexity=False, **kwargs)[source]
Bases:
TextClassifier