pyabsa.tasks.AspectTermExtraction.prediction.aspect_extractor
Module Contents
Classes
- class pyabsa.tasks.AspectTermExtraction.prediction.aspect_extractor.AspectExtractor(checkpoint=None, **kwargs)[source]
Bases:
pyabsa.framework.prediction_class.predictor_template.InferenceModel
- merge_result(sentence_res, results)[source]
merge ate sentence result and apc results, and restore to original sentence order :param sentence_res: list of ate sentence results, which has (tokens, iobs) :type sentence_res: [tuple] :param results: list of apc results :type results: [dict]
- Returns:
merged extraction/polarity results for each input example
- Return type:
[dict]
- extract_aspect(inference_source: Union[List[pathlib.Path], list, str], save_result=True, print_result=True, pred_sentiment=True, **kwargs)[source]
Extract aspects and their corresponding polarities from a list of input files.
- Parameters:
self – An instance of the model class.
inference_source – A list of file paths, or a directory containing files to be processed.
save_result (bool) – Whether to save the output to a file. Default is True.
print_result (bool) – Whether to print the output to the console. Default is True.
pred_sentiment (bool) – Whether to predict the sentiment of each aspect. Default is True.
**kwargs – Additional keyword arguments to be passed to the batch_predict method.
- Returns:
The predicted aspects and their corresponding polarities.
- predict(text: Union[str, List[str]], save_result=True, print_result=True, pred_sentiment=True, **kwargs)[source]
- Parameters:
text (str) – input example
save_result (bool) – whether to save the result to file
print_result (bool) – whether to print the result to console
pred_sentiment (bool) – whether to predict sentiment
- batch_predict(target_file: Union[List[pathlib.Path], list, str], save_result=True, print_result=True, pred_sentiment=True, **kwargs)[source]
- Parameters:
target_file (list) – list of input examples or a list of files to be predicted
save_result (bool, optional) – save result to file. Defaults to True.
print_result (bool, optional) – print result to console. Defaults to True.
pred_sentiment (bool, optional) – predict sentiment. Defaults to True.
Returns:
- class pyabsa.tasks.AspectTermExtraction.prediction.aspect_extractor.Predictor(checkpoint=None, **kwargs)[source]
Bases:
AspectExtractor