{ "postprocess_function": "\ndef post_process(output):\n import torch\n classes = ['ACCOUNTANT', 'ADVOCATE', 'AGRICULTURE', 'APPAREL', 'ARTS', 'AUTOMOBILE', 'AVIATION', 'BANKING', 'BPO', 'BUSINESS-DEVELOPMENT', 'CHEF', 'CONSTRUCTION', 'CONSULTANT', 'DESIGNER', 'DIGITAL-MEDIA', 'ENGINEERING', 'FINANCE', 'FITNESS', 'HEALTHCARE', 'HR', 'INFORMATION-TECHNOLOGY', 'PUBLIC-RELATIONS', 'SALES', 'TEACHER']\n try:\n logits = output.logits\n sigmoid = torch.nn.Sigmoid()\n probs = sigmoid(logits.squeeze().cpu())\n temp = probs.sort()\n return classes[temp[-1][-1].item()]\n except:\n print(\"Some Error occured\")\n", "preprocess_function": "\ndef preprocess(text):\n import re\n import string\n import spacy\n\n try:\n\n # Checking if it the string\n text = str(text)\n\n # remove html\n text = re.sub(r\"<.*?>\",\"\", text)\n \n # Remove URL\n url_pattern = r\"https?://\\S+|www\\.\\S+|\\S+\\.\\S{2,\"\n text = re.sub(url_pattern,\"\", text)\n\n # Remove Punctuation\n translator = str.maketrans(\"\",\"\", string.punctuation)\n text.translate(translator)\n\n # Lower case\n text.lower().strip()\n\n # Remove Unicodes - only applicable for english language. Because other language letters represented as unicodes.\n unicode_pattern = str.maketrans(\"\",\"\",\"\\xa0\")\n text.translate(unicode_pattern)\n\n # Remove Escape sequences (\\n, \\t, \\r)\n text = re.sub(r\"\\[nt\\r]\",\" \",text)\n\n # Remove Stop words using spacy\n\n spacy.prefer_gpu() # using GPU if available. may reduce the run time.\n nlp = spacy.load(\"en_core_web_sm\")\n doc = nlp(text)\n text = \" \".join([token.text for token in doc if not token.is_stop])\n\n # Remove irrelevant white spaces\n text = re.sub(r\"\\s+\",\" \",text)\n except:\n print(f\"error occured\")\n \n return text\n", "transformers_version": "4.47.0" }