Source code for pyabsa.framework.flag_class.flag_template

# -*- coding: utf-8 -*-
# file: flag_template.py
# time: 02/11/2022 17:13
# author: YANG, HENG <hy345@exeter.ac.uk> (杨恒)
# github: https://github.com/yangheng95
# GScholar: https://scholar.google.com/citations?user=NPq5a_0AAAAJ&hl=en
# ResearchGate: https://www.researchgate.net/profile/Heng-Yang-17/research
# Copyright (C) 2022. All Rights Reserved.


[docs] class TaskNameOption(dict): """ A dictionary subclass that maps task codes to task names. """
[docs] code2name = { "apc": "Aspect-based Sentiment Classification", "atepc": "Aspect Term Extraction and Polarity Classification", "aste": "Aspect Sentiment Triple Extraction", "tc": "Text Classification", "text_classification": "Text Classification", "tad": "Text Adversarial Defense", "rnac": "RNA Sequence Classification", "rnar": "RNA Sequence Regression", "pr": "Protein Sequence Regression", "cdd": "Code Defect Detection", "acos": "Aspect Category Opinion Sentiment Triplet Extraction", "universal_sentiment_analysis": "Universal Sentiment Analysis", "APC": "Aspect-based Sentiment Classification", "ATEPC": "Aspect Term Extraction and Polarity Classification", "ASTE": "Aspect Sentiment Triple Extraction", "TC": "Text Classification", "TAD": "Text Adversarial Defense", "RNAC": "RNA Sequence Classification", "RNAR": "RNA Sequence Regression", "PR": "Protein Sequence Regression", "CDD": "Code Defect Detection", "ACOS": "Aspect Category Opinion Sentiment Triplet Extraction", "USA": "Universal Sentiment Analysis", }
def __init__(self): super(TaskNameOption, self).__init__(self.code2name)
[docs] def get(self, key): """ Get the task name from the task code. :param key: The task code. :return: The task name. """ return self.code2name.get(key, "Unknown Task")
[docs] class TaskCodeOption: """ A class that defines task codes for various tasks. """
[docs] Aspect_Polarity_Classification = "APC"
[docs] Aspect_Term_Extraction_and_Classification = "ATEPC"
[docs] Aspect_Sentiment_Triplet_Extraction = "ASTE"
[docs] Sentiment_Analysis = "TC"
[docs] Text_Classification = "TC"
[docs] Text_Adversarial_Defense = "TAD"
[docs] RNASequenceClassification = "RNAC"
[docs] RNASequenceRegression = "RNAR"
[docs] ProteinSequenceRegression = "PR"
[docs] CodeDefectDetection = "CDD"
[docs] Aspect_Category_Opinion_Sentiment_Triplet_Extraction = "ACOS"
[docs] Universal_Sentiment_Analysis = "USA"
[docs] class LabelPaddingOption: """ A class that defines label padding options. """
[docs] SENTIMENT_PADDING = -100
[docs] LABEL_PADDING = -100
[docs] class ModelSaveOption: """ A class that defines options for saving models. """
[docs] DO_NOT_SAVE_MODEL = 0
[docs] SAVE_MODEL_STATE_DICT = 1
[docs] SAVE_FULL_MODEL = 2
[docs] SAVE_FINE_TUNED_PLM = 3
[docs] class ProxyAddressOption: """ A class that defines proxy address options. """
[docs] CN_GITHUB_MIRROR = "https://gitee.com/"
[docs] class DeviceTypeOption: """ A class that defines device type options. """
[docs] AUTO = True
[docs] CPU = "cpu"
[docs] CUDA = "cuda"
[docs] ALL_CUDA = "allcuda"
[docs] PyABSAMaterialHostAddress = "https://huggingface.co/spaces/yangheng/PyABSA/"