pyabsa.tasks.AspectTermExtraction
Subpackages
pyabsa.tasks.AspectTermExtraction.configuration
pyabsa.tasks.AspectTermExtraction.dataset_utils
pyabsa.tasks.AspectTermExtraction.instructor
pyabsa.tasks.AspectTermExtraction.models
pyabsa.tasks.AspectTermExtraction.models.__classic__
pyabsa.tasks.AspectTermExtraction.models.__lcf__
pyabsa.tasks.AspectTermExtraction.models.__lcf__.bert_base_atepc
pyabsa.tasks.AspectTermExtraction.models.__lcf__.fast_lcf_atepc
pyabsa.tasks.AspectTermExtraction.models.__lcf__.fast_lcfs_atepc
pyabsa.tasks.AspectTermExtraction.models.__lcf__.lcf_atepc
pyabsa.tasks.AspectTermExtraction.models.__lcf__.lcf_atepc_large
pyabsa.tasks.AspectTermExtraction.models.__lcf__.lcf_template_atepc
pyabsa.tasks.AspectTermExtraction.models.__lcf__.lcfs_atepc
pyabsa.tasks.AspectTermExtraction.models.__lcf__.lcfs_atepc_large
pyabsa.tasks.AspectTermExtraction.models.__plm__
pyabsa.tasks.AspectTermExtraction.prediction
pyabsa.tasks.AspectTermExtraction.trainer
Package Contents
Classes
Trainer class for training PyABSA models |
|
Simple object for storing attributes. |
|
Built-in mutable sequence. |
|
ATEPCDatasetList is a list of datasets for aspect term extraction and polarity classification task. |
|
- class pyabsa.tasks.AspectTermExtraction.ATEPCTrainer(config: pyabsa.tasks.AspectTermExtraction.configuration.atepc_configuration.ATEPCConfigManager = 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.AspectTermExtraction.ATEPCConfigManager(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.
- class pyabsa.tasks.AspectTermExtraction.ATEPCModelList[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_BASE_ATEPC
- FAST_LCF_ATEPC
- FAST_LCFS_ATEPC
- LCF_ATEPC
- LCF_ATEPC_LARGE
- LCFS_ATEPC
- LCFS_ATEPC_LARGE
- LCF_TEMPLATE_ATEPC
- class pyabsa.tasks.AspectTermExtraction.ATEPCDatasetList[source]
Bases:
list
ATEPCDatasetList is a list of datasets for aspect term extraction and polarity classification task. The datasets are collected from different sources, you can use the id to locate the dataset.
- Laptop14
- Restaurant14
- ARTS_Laptop14
- ARTS_Restaurant14
- Restaurant15
- Restaurant16
- ACL_Twitter
- MAMS
- Television
- TShirt
- Yelp
- Phone
- Car
- Notebook
- Camera
- Shampoo
- MOOC
- MOOC_En
- Kaggle
- FinNews
- Chinese_Zhang
- Chinese
- Binary_Polarity_Chinese
- Triple_Polarity_Chinese
- SemEval2016Task5
- Arabic_SemEval2016Task5
- Dutch_SemEval2016Task5
- Spanish_SemEval2016Task5
- Turkish_SemEval2016Task5
- Russian_SemEval2016Task5
- French_SemEval2016Task5
- English_SemEval2016Task5
- English
- SemEval
- Restaurant
- Multilingual
- class pyabsa.tasks.AspectTermExtraction.AspectExtractor(checkpoint=None, **kwargs)[source]
Bases:
pyabsa.framework.prediction_class.predictor_template.InferenceModel
- task_code
- 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: 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: 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: 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.Predictor(checkpoint=None, **kwargs)[source]
Bases:
AspectExtractor