Skip to content

Instantly share code, notes, and snippets.

@chetanambi
Last active August 9, 2020 18:00
Show Gist options
  • Save chetanambi/aaf20b50b27eae8d1d706c5ccd81c55a to your computer and use it in GitHub Desktop.
Save chetanambi/aaf20b50b27eae8d1d706c5ccd81c55a to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "textattack_example.ipynb",
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "code",
"metadata": {
"id": "mkKgdSYXrMXI",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 185
},
"outputId": "8afe3d6e-aad0-4457-a3d3-373763b08c2d"
},
"source": [
"!pip install pyarrow==0.16.0"
],
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"text": [
"Collecting pyarrow==0.16.0\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/00/d2/695bab1e1e7a4554b6dbd287d55cca096214bd441037058a432afd724bb1/pyarrow-0.16.0-cp36-cp36m-manylinux2014_x86_64.whl (63.1MB)\n",
"\u001b[K |████████████████████████████████| 63.2MB 63kB/s \n",
"\u001b[?25hRequirement already satisfied: six>=1.0.0 in /usr/local/lib/python3.6/dist-packages (from pyarrow==0.16.0) (1.15.0)\n",
"Requirement already satisfied: numpy>=1.14 in /usr/local/lib/python3.6/dist-packages (from pyarrow==0.16.0) (1.18.5)\n",
"Installing collected packages: pyarrow\n",
" Found existing installation: pyarrow 0.14.1\n",
" Uninstalling pyarrow-0.14.1:\n",
" Successfully uninstalled pyarrow-0.14.1\n",
"Successfully installed pyarrow-0.16.0\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "E068fIgQqy6M",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"outputId": "4716f297-1c50-4636-862e-c47cd7057c1b"
},
"source": [
"!pip install textattack"
],
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"text": [
"Collecting textattack\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/df/eb/bb9793f290f0ca40c725f15144171318c1b1e1952ee249cecb66ed5fe841/textattack-0.2.4-py3-none-any.whl (207kB)\n",
"\u001b[K |████████████████████████████████| 215kB 2.7MB/s \n",
"\u001b[?25hCollecting flair>=0.5.1\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/60/8f/51d1f2eb5f9b09beb1e6858b4c174a087bc3b05893438e2cd3ffbf9c6e8b/flair-0.5.1-py3-none-any.whl (201kB)\n",
"\u001b[K |████████████████████████████████| 204kB 8.0MB/s \n",
"\u001b[?25hRequirement already satisfied: scikit-learn in /usr/local/lib/python3.6/dist-packages (from textattack) (0.22.2.post1)\n",
"Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (from textattack) (4.41.1)\n",
"Requirement already satisfied: pandas>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from textattack) (1.0.5)\n",
"Collecting visdom\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/c9/75/e078f5a2e1df7e0d3044749089fc2823e62d029cc027ed8ae5d71fafcbdc/visdom-0.1.8.9.tar.gz (676kB)\n",
"\u001b[K |████████████████████████████████| 686kB 11.4MB/s \n",
"\u001b[?25hCollecting wandb\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/94/19/f8db9eff4b0173adf6dd2e8b0c3d8de0bfe10ec9ed63d247665980d82258/wandb-0.9.4-py2.py3-none-any.whl (1.4MB)\n",
"\u001b[K |████████████████████████████████| 1.4MB 17.9MB/s \n",
"\u001b[?25hCollecting tensorboardX\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/af/0c/4f41bcd45db376e6fe5c619c01100e9b7531c55791b7244815bac6eac32c/tensorboardX-2.1-py2.py3-none-any.whl (308kB)\n",
"\u001b[K |████████████████████████████████| 317kB 22.5MB/s \n",
"\u001b[?25hCollecting lemminflect\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/8d/c5/62e8dd0b6cbfea212cf55a2338838d85a819dbda9462ba53a415dcf19b86/lemminflect-0.2.1-py3-none-any.whl (769kB)\n",
"\u001b[K |████████████████████████████████| 778kB 26.6MB/s \n",
"\u001b[?25hCollecting tokenizers==0.8.1-rc1\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/40/d0/30d5f8d221a0ed981a186c8eb986ce1c94e3a6e87f994eae9f4aa5250217/tokenizers-0.8.1rc1-cp36-cp36m-manylinux1_x86_64.whl (3.0MB)\n",
"\u001b[K |████████████████████████████████| 3.0MB 37.0MB/s \n",
"\u001b[?25hCollecting nlp\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/09/e3/bcdc59f3434b224040c1047769c47b82705feca2b89ebbc28311e3764782/nlp-0.4.0-py3-none-any.whl (1.7MB)\n",
"\u001b[K |████████████████████████████████| 1.7MB 33.8MB/s \n",
"\u001b[?25hRequirement already satisfied: scipy==1.4.1 in /usr/local/lib/python3.6/dist-packages (from textattack) (1.4.1)\n",
"Requirement already satisfied: pyarrow<1.0 in /usr/local/lib/python3.6/dist-packages (from textattack) (0.16.0)\n",
"Requirement already satisfied: tensorflow>=2 in /usr/local/lib/python3.6/dist-packages (from textattack) (2.3.0)\n",
"Collecting terminaltables\n",
" Downloading https://files.pythonhosted.org/packages/9b/c4/4a21174f32f8a7e1104798c445dacdc1d4df86f2f26722767034e4de4bff/terminaltables-3.1.0.tar.gz\n",
"Collecting language-tool-python\n",
" Downloading https://files.pythonhosted.org/packages/d2/4a/95ee8562f40bb8e72f6da43f888e3577711cb49cf62ffedff2b6316d25b5/language_tool_python-2.3.1-py3-none-any.whl\n",
"Requirement already satisfied: editdistance in /usr/local/lib/python3.6/dist-packages (from textattack) (0.5.3)\n",
"Requirement already satisfied: torch in /usr/local/lib/python3.6/dist-packages (from textattack) (1.6.0+cu101)\n",
"Collecting transformers==3.0.2\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/27/3c/91ed8f5c4e7ef3227b4119200fc0ed4b4fd965b1f0172021c25701087825/transformers-3.0.2-py3-none-any.whl (769kB)\n",
"\u001b[K |████████████████████████████████| 778kB 37.4MB/s \n",
"\u001b[?25hRequirement already satisfied: nltk in /usr/local/lib/python3.6/dist-packages (from textattack) (3.2.5)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.6/dist-packages (from textattack) (3.0.12)\n",
"Collecting sentence-transformers>0.2.6\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/ee/71/acfb3f1016f83d90590130dc2ee0d8cd36b005aa7afa45b465837b711070/sentence-transformers-0.3.3.tar.gz (65kB)\n",
"\u001b[K |████████████████████████████████| 71kB 7.9MB/s \n",
"\u001b[?25hCollecting lru-dict\n",
" Downloading https://files.pythonhosted.org/packages/00/a5/32ed6e10246cd341ca8cc205acea5d208e4053f48a4dced2b1b31d45ba3f/lru-dict-1.1.6.tar.gz\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from textattack) (1.18.5)\n",
"Requirement already satisfied: tensorflow-hub in /usr/local/lib/python3.6/dist-packages (from textattack) (0.8.0)\n",
"Collecting bert-score\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/50/8c/70244d0f351176c9984643e2037edc18b9124491b47ad19191039a18d2bd/bert_score-0.3.5-py3-none-any.whl (52kB)\n",
"\u001b[K |████████████████████████████████| 61kB 6.9MB/s \n",
"\u001b[?25hCollecting langdetect\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/56/a3/8407c1e62d5980188b4acc45ef3d94b933d14a2ebc9ef3505f22cf772570/langdetect-1.0.8.tar.gz (981kB)\n",
"\u001b[K |████████████████████████████████| 983kB 43.8MB/s \n",
"\u001b[?25hCollecting pytest>=5.3.2\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/98/db/712bee56f9ab20373508a5a1c662e1db49b407dacf03b5224c6171ed0a3d/pytest-6.0.1-py3-none-any.whl (270kB)\n",
"\u001b[K |████████████████████████████████| 276kB 44.2MB/s \n",
"\u001b[?25hCollecting segtok>=1.5.7\n",
" Downloading https://files.pythonhosted.org/packages/41/08/582dab5f4b1d5ca23bc6927b4bb977c8ff7f3a87a3b98844ef833e2f5623/segtok-1.5.10.tar.gz\n",
"Collecting sqlitedict>=1.6.0\n",
" Downloading https://files.pythonhosted.org/packages/0f/1c/c757b93147a219cf1e25cef7e1ad9b595b7f802159493c45ce116521caff/sqlitedict-1.6.0.tar.gz\n",
"Requirement already satisfied: matplotlib>=2.2.3 in /usr/local/lib/python3.6/dist-packages (from flair>=0.5.1->textattack) (3.2.2)\n",
"Collecting mpld3==0.3\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/91/95/a52d3a83d0a29ba0d6898f6727e9858fe7a43f6c2ce81a5fe7e05f0f4912/mpld3-0.3.tar.gz (788kB)\n",
"\u001b[K |████████████████████████████████| 798kB 40.0MB/s \n",
"\u001b[?25hRequirement already satisfied: python-dateutil>=2.6.1 in /usr/local/lib/python3.6/dist-packages (from flair>=0.5.1->textattack) (2.8.1)\n",
"Requirement already satisfied: gensim>=3.4.0 in /usr/local/lib/python3.6/dist-packages (from flair>=0.5.1->textattack) (3.6.0)\n",
"Collecting deprecated>=1.2.4\n",
" Downloading https://files.pythonhosted.org/packages/76/a1/05d7f62f956d77b23a640efc650f80ce24483aa2f85a09c03fb64f49e879/Deprecated-1.2.10-py2.py3-none-any.whl\n",
"Requirement already satisfied: hyperopt>=0.1.1 in /usr/local/lib/python3.6/dist-packages (from flair>=0.5.1->textattack) (0.1.2)\n",
"Collecting bpemb>=0.2.9\n",
" Downloading https://files.pythonhosted.org/packages/91/77/3f0f53856e86af32b1d3c86652815277f7b5f880002584eb30db115b6df5/bpemb-0.3.2-py3-none-any.whl\n",
"Requirement already satisfied: regex in /usr/local/lib/python3.6/dist-packages (from flair>=0.5.1->textattack) (2019.12.20)\n",
"Collecting sentencepiece!=0.1.92\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/d4/a4/d0a884c4300004a78cca907a6ff9a5e9fe4f090f5d95ab341c53d28cbc58/sentencepiece-0.1.91-cp36-cp36m-manylinux1_x86_64.whl (1.1MB)\n",
"\u001b[K |████████████████████████████████| 1.1MB 30.7MB/s \n",
"\u001b[?25hRequirement already satisfied: tabulate in /usr/local/lib/python3.6/dist-packages (from flair>=0.5.1->textattack) (0.8.7)\n",
"Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.6/dist-packages (from scikit-learn->textattack) (0.16.0)\n",
"Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.6/dist-packages (from pandas>=1.0.1->textattack) (2018.9)\n",
"Requirement already satisfied: requests in /usr/local/lib/python3.6/dist-packages (from visdom->textattack) (2.23.0)\n",
"Requirement already satisfied: tornado in /usr/local/lib/python3.6/dist-packages (from visdom->textattack) (5.1.1)\n",
"Requirement already satisfied: pyzmq in /usr/local/lib/python3.6/dist-packages (from visdom->textattack) (19.0.2)\n",
"Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from visdom->textattack) (1.15.0)\n",
"Collecting jsonpatch\n",
" Downloading https://files.pythonhosted.org/packages/4f/d0/34b0f59ac08de9c1e07876cfecd80aec650600177b4bd445124c755499a7/jsonpatch-1.26-py2.py3-none-any.whl\n",
"Collecting torchfile\n",
" Downloading https://files.pythonhosted.org/packages/91/af/5b305f86f2d218091af657ddb53f984ecbd9518ca9fe8ef4103a007252c9/torchfile-0.1.0.tar.gz\n",
"Collecting websocket-client\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/4c/5f/f61b420143ed1c8dc69f9eaec5ff1ac36109d52c80de49d66e0c36c3dfdf/websocket_client-0.57.0-py2.py3-none-any.whl (200kB)\n",
"\u001b[K |████████████████████████████████| 204kB 38.4MB/s \n",
"\u001b[?25hRequirement already satisfied: pillow in /usr/local/lib/python3.6/dist-packages (from visdom->textattack) (7.0.0)\n",
"Collecting subprocess32>=3.5.3\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/32/c8/564be4d12629b912ea431f1a50eb8b3b9d00f1a0b1ceff17f266be190007/subprocess32-3.5.4.tar.gz (97kB)\n",
"\u001b[K |████████████████████████████████| 102kB 11.4MB/s \n",
"\u001b[?25hCollecting watchdog>=0.8.3\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/0e/06/121302598a4fc01aca942d937f4a2c33430b7181137b35758913a8db10ad/watchdog-0.10.3.tar.gz (94kB)\n",
"\u001b[K |████████████████████████████████| 102kB 10.0MB/s \n",
"\u001b[?25hCollecting docker-pycreds>=0.4.0\n",
" Downloading https://files.pythonhosted.org/packages/f5/e8/f6bd1eee09314e7e6dee49cbe2c5e22314ccdb38db16c9fc72d2fa80d054/docker_pycreds-0.4.0-py2.py3-none-any.whl\n",
"Collecting GitPython>=1.0.0\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/f9/1e/a45320cab182bf1c8656107b3d4c042e659742822fc6bff150d769a984dd/GitPython-3.1.7-py3-none-any.whl (158kB)\n",
"\u001b[K |████████████████████████████████| 163kB 34.9MB/s \n",
"\u001b[?25hRequirement already satisfied: PyYAML>=3.10 in /usr/local/lib/python3.6/dist-packages (from wandb->textattack) (3.13)\n",
"Requirement already satisfied: nvidia-ml-py3>=7.352.0 in /usr/local/lib/python3.6/dist-packages (from wandb->textattack) (7.352.0)\n",
"Collecting shortuuid>=0.5.0\n",
" Downloading https://files.pythonhosted.org/packages/25/a6/2ecc1daa6a304e7f1b216f0896b26156b78e7c38e1211e9b798b4716c53d/shortuuid-1.0.1-py3-none-any.whl\n",
"Collecting configparser>=3.8.1\n",
" Downloading https://files.pythonhosted.org/packages/4b/6b/01baa293090240cf0562cc5eccb69c6f5006282127f2b846fad011305c79/configparser-5.0.0-py3-none-any.whl\n",
"Requirement already satisfied: psutil>=5.0.0 in /usr/local/lib/python3.6/dist-packages (from wandb->textattack) (5.4.8)\n",
"Collecting gql==0.2.0\n",
" Downloading https://files.pythonhosted.org/packages/c4/6f/cf9a3056045518f06184e804bae89390eb706168349daa9dff8ac609962a/gql-0.2.0.tar.gz\n",
"Collecting sentry-sdk>=0.4.0\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/4b/23/811fcdfc9d67fea7e47c91dd553081218d53dda744c28384f4d2f69206c9/sentry_sdk-0.16.3-py2.py3-none-any.whl (110kB)\n",
"\u001b[K |████████████████████████████████| 112kB 40.6MB/s \n",
"\u001b[?25hRequirement already satisfied: Click>=7.0 in /usr/local/lib/python3.6/dist-packages (from wandb->textattack) (7.1.2)\n",
"Requirement already satisfied: protobuf>=3.8.0 in /usr/local/lib/python3.6/dist-packages (from tensorboardX->textattack) (3.12.4)\n",
"Requirement already satisfied: dataclasses; python_version < \"3.7\" in /usr/local/lib/python3.6/dist-packages (from nlp->textattack) (0.7)\n",
"Requirement already satisfied: dill in /usr/local/lib/python3.6/dist-packages (from nlp->textattack) (0.3.2)\n",
"Collecting xxhash\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/f7/73/826b19f3594756cb1c6c23d2fbd8ca6a77a9cd3b650c9dec5acc85004c38/xxhash-2.0.0-cp36-cp36m-manylinux2010_x86_64.whl (242kB)\n",
"\u001b[K |████████████████████████████████| 245kB 41.7MB/s \n",
"\u001b[?25hRequirement already satisfied: astunparse==1.6.3 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2->textattack) (1.6.3)\n",
"Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2->textattack) (3.3.0)\n",
"Requirement already satisfied: tensorboard<3,>=2.3.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2->textattack) (2.3.0)\n",
"Requirement already satisfied: gast==0.3.3 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2->textattack) (0.3.3)\n",
"Requirement already satisfied: absl-py>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2->textattack) (0.9.0)\n",
"Requirement already satisfied: wheel>=0.26 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2->textattack) (0.34.2)\n",
"Requirement already satisfied: h5py<2.11.0,>=2.10.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2->textattack) (2.10.0)\n",
"Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2->textattack) (1.1.0)\n",
"Requirement already satisfied: keras-preprocessing<1.2,>=1.1.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2->textattack) (1.1.2)\n",
"Requirement already satisfied: tensorflow-estimator<2.4.0,>=2.3.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2->textattack) (2.3.0)\n",
"Requirement already satisfied: grpcio>=1.8.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2->textattack) (1.30.0)\n",
"Requirement already satisfied: google-pasta>=0.1.8 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2->textattack) (0.2.0)\n",
"Requirement already satisfied: wrapt>=1.11.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2->textattack) (1.12.1)\n",
"Requirement already satisfied: future in /usr/local/lib/python3.6/dist-packages (from torch->textattack) (0.16.0)\n",
"Requirement already satisfied: packaging in /usr/local/lib/python3.6/dist-packages (from transformers==3.0.2->textattack) (20.4)\n",
"Collecting sacremoses\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/7d/34/09d19aff26edcc8eb2a01bed8e98f13a1537005d31e95233fd48216eed10/sacremoses-0.0.43.tar.gz (883kB)\n",
"\u001b[K |████████████████████████████████| 890kB 36.1MB/s \n",
"\u001b[?25hRequirement already satisfied: more-itertools>=4.0.0 in /usr/local/lib/python3.6/dist-packages (from pytest>=5.3.2->flair>=0.5.1->textattack) (8.4.0)\n",
"Collecting pluggy<1.0,>=0.12\n",
" Downloading https://files.pythonhosted.org/packages/a0/28/85c7aa31b80d150b772fbe4a229487bc6644da9ccb7e427dd8cc60cb8a62/pluggy-0.13.1-py2.py3-none-any.whl\n",
"Requirement already satisfied: toml in /usr/local/lib/python3.6/dist-packages (from pytest>=5.3.2->flair>=0.5.1->textattack) (0.10.1)\n",
"Requirement already satisfied: py>=1.8.2 in /usr/local/lib/python3.6/dist-packages (from pytest>=5.3.2->flair>=0.5.1->textattack) (1.9.0)\n",
"Requirement already satisfied: iniconfig in /usr/local/lib/python3.6/dist-packages (from pytest>=5.3.2->flair>=0.5.1->textattack) (1.0.1)\n",
"Requirement already satisfied: attrs>=17.4.0 in /usr/local/lib/python3.6/dist-packages (from pytest>=5.3.2->flair>=0.5.1->textattack) (19.3.0)\n",
"Requirement already satisfied: importlib-metadata>=0.12; python_version < \"3.8\" in /usr/local/lib/python3.6/dist-packages (from pytest>=5.3.2->flair>=0.5.1->textattack) (1.7.0)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib>=2.2.3->flair>=0.5.1->textattack) (1.2.0)\n",
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib>=2.2.3->flair>=0.5.1->textattack) (2.4.7)\n",
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib>=2.2.3->flair>=0.5.1->textattack) (0.10.0)\n",
"Requirement already satisfied: smart-open>=1.2.1 in /usr/local/lib/python3.6/dist-packages (from gensim>=3.4.0->flair>=0.5.1->textattack) (2.1.0)\n",
"Requirement already satisfied: networkx in /usr/local/lib/python3.6/dist-packages (from hyperopt>=0.1.1->flair>=0.5.1->textattack) (2.4)\n",
"Requirement already satisfied: pymongo in /usr/local/lib/python3.6/dist-packages (from hyperopt>=0.1.1->flair>=0.5.1->textattack) (3.11.0)\n",
"Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->visdom->textattack) (3.0.4)\n",
"Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests->visdom->textattack) (1.24.3)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests->visdom->textattack) (2020.6.20)\n",
"Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->visdom->textattack) (2.10)\n",
"Collecting jsonpointer>=1.9\n",
" Downloading https://files.pythonhosted.org/packages/18/b0/a80d29577c08eea401659254dfaed87f1af45272899e1812d7e01b679bc5/jsonpointer-2.0-py2.py3-none-any.whl\n",
"Collecting pathtools>=0.1.1\n",
" Downloading https://files.pythonhosted.org/packages/e7/7f/470d6fcdf23f9f3518f6b0b76be9df16dcc8630ad409947f8be2eb0ed13a/pathtools-0.1.2.tar.gz\n",
"Collecting gitdb<5,>=4.0.1\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/48/11/d1800bca0a3bae820b84b7d813ad1eff15a48a64caea9c823fc8c1b119e8/gitdb-4.0.5-py3-none-any.whl (63kB)\n",
"\u001b[K |████████████████████████████████| 71kB 7.6MB/s \n",
"\u001b[?25hCollecting graphql-core<2,>=0.5.0\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/b0/89/00ad5e07524d8c523b14d70c685e0299a8b0de6d0727e368c41b89b7ed0b/graphql-core-1.1.tar.gz (70kB)\n",
"\u001b[K |████████████████████████████████| 71kB 6.5MB/s \n",
"\u001b[?25hRequirement already satisfied: promise<3,>=2.0 in /usr/local/lib/python3.6/dist-packages (from gql==0.2.0->wandb->textattack) (2.3)\n",
"Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from protobuf>=3.8.0->tensorboardX->textattack) (49.2.0)\n",
"Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow>=2->textattack) (1.7.0)\n",
"Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow>=2->textattack) (1.0.1)\n",
"Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow>=2->textattack) (3.2.2)\n",
"Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow>=2->textattack) (0.4.1)\n",
"Requirement already satisfied: google-auth<2,>=1.6.3 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow>=2->textattack) (1.17.2)\n",
"Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata>=0.12; python_version < \"3.8\"->pytest>=5.3.2->flair>=0.5.1->textattack) (3.1.0)\n",
"Requirement already satisfied: boto3 in /usr/local/lib/python3.6/dist-packages (from smart-open>=1.2.1->gensim>=3.4.0->flair>=0.5.1->textattack) (1.14.33)\n",
"Requirement already satisfied: boto in /usr/local/lib/python3.6/dist-packages (from smart-open>=1.2.1->gensim>=3.4.0->flair>=0.5.1->textattack) (2.49.0)\n",
"Requirement already satisfied: decorator>=4.3.0 in /usr/local/lib/python3.6/dist-packages (from networkx->hyperopt>=0.1.1->flair>=0.5.1->textattack) (4.4.2)\n",
"Collecting smmap<4,>=3.0.1\n",
" Downloading https://files.pythonhosted.org/packages/b0/9a/4d409a6234eb940e6a78dfdfc66156e7522262f5f2fecca07dc55915952d/smmap-3.0.4-py2.py3-none-any.whl\n",
"Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<3,>=2.3.0->tensorflow>=2->textattack) (1.3.0)\n",
"Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow>=2->textattack) (0.2.8)\n",
"Requirement already satisfied: rsa<5,>=3.1.4; python_version >= \"3\" in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow>=2->textattack) (4.6)\n",
"Requirement already satisfied: cachetools<5.0,>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow>=2->textattack) (4.1.1)\n",
"Requirement already satisfied: botocore<1.18.0,>=1.17.33 in /usr/local/lib/python3.6/dist-packages (from boto3->smart-open>=1.2.1->gensim>=3.4.0->flair>=0.5.1->textattack) (1.17.33)\n",
"Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /usr/local/lib/python3.6/dist-packages (from boto3->smart-open>=1.2.1->gensim>=3.4.0->flair>=0.5.1->textattack) (0.10.0)\n",
"Requirement already satisfied: s3transfer<0.4.0,>=0.3.0 in /usr/local/lib/python3.6/dist-packages (from boto3->smart-open>=1.2.1->gensim>=3.4.0->flair>=0.5.1->textattack) (0.3.3)\n",
"Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.6/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<3,>=2.3.0->tensorflow>=2->textattack) (3.1.0)\n",
"Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /usr/local/lib/python3.6/dist-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow>=2->textattack) (0.4.8)\n",
"Requirement already satisfied: docutils<0.16,>=0.10 in /usr/local/lib/python3.6/dist-packages (from botocore<1.18.0,>=1.17.33->boto3->smart-open>=1.2.1->gensim>=3.4.0->flair>=0.5.1->textattack) (0.15.2)\n",
"Building wheels for collected packages: visdom, terminaltables, sentence-transformers, lru-dict, langdetect, segtok, sqlitedict, mpld3, torchfile, subprocess32, watchdog, gql, sacremoses, pathtools, graphql-core\n",
" Building wheel for visdom (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for visdom: filename=visdom-0.1.8.9-cp36-none-any.whl size=655250 sha256=021ecf255f934787d40fdc3808b5cb6f59e53c7bdd18f1aa58119bb494c8230b\n",
" Stored in directory: /root/.cache/pip/wheels/70/19/a7/6d589ed967f4dfefd33bc166d081257bd4ed0cb618dccfd62a\n",
" Building wheel for terminaltables (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for terminaltables: filename=terminaltables-3.1.0-cp36-none-any.whl size=15356 sha256=11bd424019d47ef03b9b055f4ae0c5de6f5b953e14a30ef54218857a638c2613\n",
" Stored in directory: /root/.cache/pip/wheels/30/6b/50/6c75775b681fb36cdfac7f19799888ef9d8813aff9e379663e\n",
" Building wheel for sentence-transformers (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for sentence-transformers: filename=sentence_transformers-0.3.3-cp36-none-any.whl size=97299 sha256=d1d4f8047c37c1616c94c6f24f0e2ee327c3768200f4f13256bd6d306ccbcddc\n",
" Stored in directory: /root/.cache/pip/wheels/75/d6/0a/cab163b21d0597cc1580bc344487b11ad405e0d1d314725f2b\n",
" Building wheel for lru-dict (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for lru-dict: filename=lru_dict-1.1.6-cp36-cp36m-linux_x86_64.whl size=25864 sha256=9f0c1af722bacbb05e34202cf6d062f406cf508e65b623a56ba51c9a3747462e\n",
" Stored in directory: /root/.cache/pip/wheels/b7/ef/06/fbdd555907a7d438fb33e4c8675f771ff1cf41917284c51ebf\n",
" Building wheel for langdetect (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for langdetect: filename=langdetect-1.0.8-cp36-none-any.whl size=993193 sha256=f6806cc32d2d54c50fd8cd5eb9c4ee3634002c089e479143004248b6213c4324\n",
" Stored in directory: /root/.cache/pip/wheels/8d/b3/aa/6d99de9f3841d7d3d40a60ea06e6d669e8e5012e6c8b947a57\n",
" Building wheel for segtok (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for segtok: filename=segtok-1.5.10-cp36-none-any.whl size=25020 sha256=f3bb5a27e2e5f9411305807610b17562f95896e7cb1de79520e393f17153e09f\n",
" Stored in directory: /root/.cache/pip/wheels/b4/39/f6/9ca1c5cabde964d728023b5751c3a206a5c8cc40252321fb6b\n",
" Building wheel for sqlitedict (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for sqlitedict: filename=sqlitedict-1.6.0-cp36-none-any.whl size=14689 sha256=dadddd2a944c7e9e4b9e25deb4a0661d03f882ed71f84c73c5938900f5a02397\n",
" Stored in directory: /root/.cache/pip/wheels/bd/57/d3/907c3ee02d35e66f674ad0106e61f06eeeb98f6ee66a6cc3fe\n",
" Building wheel for mpld3 (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for mpld3: filename=mpld3-0.3-cp36-none-any.whl size=116679 sha256=083b76dbbce87fafde4618a05fb9f26a3c88856b4e01b9158b82fa0db216ac1d\n",
" Stored in directory: /root/.cache/pip/wheels/c0/47/fb/8a64f89aecfe0059830479308ad42d62e898a3e3cefdf6ba28\n",
" Building wheel for torchfile (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for torchfile: filename=torchfile-0.1.0-cp36-none-any.whl size=5712 sha256=e181fea9479102f59cc0172804beea0549594ba49f2b0e6a2e4d20316e732089\n",
" Stored in directory: /root/.cache/pip/wheels/b1/c3/d6/9a1cc8f3a99a0fc1124cae20153f36af59a6e683daca0a0814\n",
" Building wheel for subprocess32 (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for subprocess32: filename=subprocess32-3.5.4-cp36-none-any.whl size=6489 sha256=cee805c7291b55f24d0b4e4fcfa06915bfbe93e6bf9a4eaa9cab87633fd34ff2\n",
" Stored in directory: /root/.cache/pip/wheels/68/39/1a/5e402bdfdf004af1786c8b853fd92f8c4a04f22aad179654d1\n",
" Building wheel for watchdog (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for watchdog: filename=watchdog-0.10.3-cp36-none-any.whl size=73870 sha256=1a2896b9c4d89700d00421232ec98119340bbbf2bfb98daba4d4c947c5f33624\n",
" Stored in directory: /root/.cache/pip/wheels/a8/1d/38/2c19bb311f67cc7b4d07a2ec5ea36ab1a0a0ea50db994a5bc7\n",
" Building wheel for gql (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for gql: filename=gql-0.2.0-cp36-none-any.whl size=7630 sha256=f90f7f403b9d2af02e220bd61968c7f7d4aeeb52a756f6527e8c751662a4c743\n",
" Stored in directory: /root/.cache/pip/wheels/ce/0e/7b/58a8a5268655b3ad74feef5aa97946f0addafb3cbb6bd2da23\n",
" Building wheel for sacremoses (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for sacremoses: filename=sacremoses-0.0.43-cp36-none-any.whl size=893260 sha256=7a42b3f6968d9cd8a928f232911a1e4c188a1d737be201eb142410cba4c28641\n",
" Stored in directory: /root/.cache/pip/wheels/29/3c/fd/7ce5c3f0666dab31a50123635e6fb5e19ceb42ce38d4e58f45\n",
" Building wheel for pathtools (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for pathtools: filename=pathtools-0.1.2-cp36-none-any.whl size=8784 sha256=40e6d9de6b3e8584a9780536a67a3276ca90f8f63e13faa1e5cadcfaf2f336c5\n",
" Stored in directory: /root/.cache/pip/wheels/0b/04/79/c3b0c3a0266a3cb4376da31e5bfe8bba0c489246968a68e843\n",
" Building wheel for graphql-core (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for graphql-core: filename=graphql_core-1.1-cp36-none-any.whl size=104650 sha256=44a8e1a804ae3d4a17feb1b3ba836f04df2aa7d51acb2fe79ee72e8316ec2496\n",
" Stored in directory: /root/.cache/pip/wheels/45/99/d7/c424029bb0fe910c63b68dbf2aa20d3283d023042521bcd7d5\n",
"Successfully built visdom terminaltables sentence-transformers lru-dict langdetect segtok sqlitedict mpld3 torchfile subprocess32 watchdog gql sacremoses pathtools graphql-core\n",
"\u001b[31mERROR: datascience 0.10.6 has requirement folium==0.2.1, but you'll have folium 0.8.3 which is incompatible.\u001b[0m\n",
"Installing collected packages: langdetect, pluggy, pytest, segtok, sqlitedict, mpld3, deprecated, sentencepiece, bpemb, tokenizers, sacremoses, transformers, flair, jsonpointer, jsonpatch, torchfile, websocket-client, visdom, subprocess32, pathtools, watchdog, docker-pycreds, smmap, gitdb, GitPython, shortuuid, configparser, graphql-core, gql, sentry-sdk, wandb, tensorboardX, lemminflect, xxhash, nlp, terminaltables, language-tool-python, sentence-transformers, lru-dict, bert-score, textattack\n",
" Found existing installation: pluggy 0.7.1\n",
" Uninstalling pluggy-0.7.1:\n",
" Successfully uninstalled pluggy-0.7.1\n",
" Found existing installation: pytest 3.6.4\n",
" Uninstalling pytest-3.6.4:\n",
" Successfully uninstalled pytest-3.6.4\n",
"Successfully installed GitPython-3.1.7 bert-score-0.3.5 bpemb-0.3.2 configparser-5.0.0 deprecated-1.2.10 docker-pycreds-0.4.0 flair-0.5.1 gitdb-4.0.5 gql-0.2.0 graphql-core-1.1 jsonpatch-1.26 jsonpointer-2.0 langdetect-1.0.8 language-tool-python-2.3.1 lemminflect-0.2.1 lru-dict-1.1.6 mpld3-0.3 nlp-0.4.0 pathtools-0.1.2 pluggy-0.13.1 pytest-6.0.1 sacremoses-0.0.43 segtok-1.5.10 sentence-transformers-0.3.3 sentencepiece-0.1.91 sentry-sdk-0.16.3 shortuuid-1.0.1 smmap-3.0.4 sqlitedict-1.6.0 subprocess32-3.5.4 tensorboardX-2.1 terminaltables-3.1.0 textattack-0.2.4 tokenizers-0.8.1rc1 torchfile-0.1.0 transformers-3.0.2 visdom-0.1.8.9 wandb-0.9.4 watchdog-0.10.3 websocket-client-0.57.0 xxhash-2.0.0\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "gM4oUy0ajFrC",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 218
},
"outputId": "0d974a83-c987-40f4-9d7b-57e02956c152"
},
"source": [
"from textattack.augmentation import WordNetAugmenter, EmbeddingAugmenter, EasyDataAugmenter, CharSwapAugmenter"
],
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"text": [
"\u001b[34;1mtextattack\u001b[0m: First time running textattack: downloading remaining required packages.\n",
"\u001b[34;1mtextattack\u001b[0m: Downloading NLTK required packages.\n"
],
"name": "stderr"
},
{
"output_type": "stream",
"text": [
"[nltk_data] Downloading package wordnet to /root/nltk_data...\n",
"[nltk_data] Unzipping corpora/wordnet.zip.\n",
"[nltk_data] Downloading package averaged_perceptron_tagger to\n",
"[nltk_data] /root/nltk_data...\n",
"[nltk_data] Unzipping taggers/averaged_perceptron_tagger.zip.\n",
"[nltk_data] Downloading package universal_tagset to /root/nltk_data...\n",
"[nltk_data] Unzipping taggers/universal_tagset.zip.\n",
"[nltk_data] Downloading package stopwords to /root/nltk_data...\n",
"[nltk_data] Unzipping corpora/stopwords.zip.\n"
],
"name": "stdout"
},
{
"output_type": "stream",
"text": [
"\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m W&B installed but not logged in. Run `wandb login` or set the WANDB_API_KEY env variable.\n"
],
"name": "stderr"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "tv8IprkwWEGg",
"colab_type": "text"
},
"source": [
"Example 1:"
]
},
{
"cell_type": "code",
"metadata": {
"id": "EYBjUPcMjnp5",
"colab_type": "code",
"colab": {}
},
"source": [
"text = \"Leadership requires two things: a vision of the world that does not yet exist and the ability to communicate it.\""
],
"execution_count": 4,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "SP-dHk2VjpAU",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "e07b2d72-a78a-4a49-c8c8-aff74cca3fed"
},
"source": [
"aug = WordNetAugmenter()\n",
"aug.augment(text)"
],
"execution_count": 5,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"['Leadership requires two things: a imaginativeness of the world that does not yet survive and the ability to communicate it.']"
]
},
"metadata": {
"tags": []
},
"execution_count": 5
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Vp1IwMv6jG67",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 101
},
"outputId": "47eef027-5b93-4684-a054-f63b590e192c"
},
"source": [
"aug = EmbeddingAugmenter()\n",
"aug.augment(text)"
],
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"text": [
"\u001b[34;1mtextattack\u001b[0m: Downloading https://textattack.s3.amazonaws.com/word_embeddings/paragramcf.\n",
"100%|██████████| 481M/481M [00:09<00:00, 52.4MB/s]\n",
"\u001b[34;1mtextattack\u001b[0m: Unzipping file /root/.cache/textattack/tmppu06z0jb.zip to /root/.cache/textattack/word_embeddings/paragramcf.\n",
"\u001b[34;1mtextattack\u001b[0m: Successfully saved word_embeddings/paragramcf to cache.\n"
],
"name": "stderr"
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"['Leadership requires deux things: a vision of the world that does not yet exist and the capacities to communicate it.']"
]
},
"metadata": {
"tags": []
},
"execution_count": 6
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "dv_ehYvbjFuQ",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 84
},
"outputId": "1aaef611-4cbe-431e-c2e8-dc8ee875c9b1"
},
"source": [
"aug = EasyDataAugmenter()\n",
"aug.augment(text)"
],
"execution_count": 7,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"['Leadership requires two things: a vision of the world that does not yet be and the power to communicate it.',\n",
" 'Leadership requires two: a of the world that does not yet exist and the ability to communicate it.',\n",
" 'Leadership requires two things: a vision of the world that it communicate yet exist and the ability to not does.',\n",
" 'Leadership requires two live things: a vision of the world that withal does not yet exist and the ability to communicate it.']"
]
},
"metadata": {
"tags": []
},
"execution_count": 7
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "NCTyYWALjsUt",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "fb56547f-dcab-4dcf-c9cc-f2ae2b6a3e6f"
},
"source": [
"aug = CharSwapAugmenter()\n",
"aug.augment(text)"
],
"execution_count": 8,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"['Leadership requires two things: a visoin of the worl that does not yet exist and the ability to communicate it.']"
]
},
"metadata": {
"tags": []
},
"execution_count": 8
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "nDiX5DGaWJQx",
"colab_type": "text"
},
"source": [
"**Example 2:**"
]
},
{
"cell_type": "code",
"metadata": {
"id": "qBvuqyCtWP7b",
"colab_type": "code",
"colab": {}
},
"source": [
"text = \"The role of a leader is not to come up with all the great ideas. The role of a leader is to create an environment in which great ideas can happen.\""
],
"execution_count": 9,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "kAB3XBBvWQAP",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "77967d1c-6ed0-4419-d90b-bfcba62c1994"
},
"source": [
"aug = WordNetAugmenter()\n",
"aug.augment(text)"
],
"execution_count": 10,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"['The persona of a leader is not to come up with all the great theme. The role of a leader is to create an environment in which great ideas can hap.']"
]
},
"metadata": {
"tags": []
},
"execution_count": 10
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "YymkRe8nWQEq",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "46706a51-de20-44bd-b17a-6d6f554a63ac"
},
"source": [
"aug = EmbeddingAugmenter()\n",
"aug.augment(text)"
],
"execution_count": 11,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"['The role of a leader is not to come up with all the great ideas. The role of a leader is to creations an environment in which grand insights can happen.']"
]
},
"metadata": {
"tags": []
},
"execution_count": 11
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Kq5m6SY-WQIO",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 84
},
"outputId": "2c27387e-1065-42bc-9794-ce134a847274"
},
"source": [
"aug = EasyDataAugmenter()\n",
"aug.augment(text)"
],
"execution_count": 12,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"['The role of a leader is not to come up with all the great estimate. The function of a leader is to make an environment in which great ideas can happen.',\n",
" 'The role environment great leader is not to come up with all the a ideas. The role of a leader is to create an of in which great ideas happen can.',\n",
" 'The role of a leader is not to come up with all the great improving ideas. The role of make a leader is to be create an environment in which great ideas can happen.',\n",
" 'role of a leader is not to come up with all the great ideas. The role of a leader is create an environment in which great can happen.']"
]
},
"metadata": {
"tags": []
},
"execution_count": 12
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "r8QycVTPWQC8",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "e2e063a1-5fd9-41a9-f757-6947958e0b39"
},
"source": [
"aug = CharSwapAugmenter()\n",
"aug.augment(text)"
],
"execution_count": 13,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"['The role of a Sleader is not to come up with all the great ideas. The role of a lXader is to create an environment in which great ides can happen.']"
]
},
"metadata": {
"tags": []
},
"execution_count": 13
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment