First, we load the pegasus paraphraser.

```
!git clone https://github.com/google-research/pegasus
%cd pegasus
!export PYTHONPATH=.
!pip3 install -r requirements.txt
```

    Cloning into 'pegasus'...
    remote: Enumerating objects: 175, done.
    remote: Total 175 (delta 0), reused 0 (delta 0), pack-reused 175
    Receiving objects: 100% (175/175), 354.16 KiB | 6.21 MiB/s, done.
    Resolving deltas: 100% (58/58), done.
    /content/pegasus
    Requirement already satisfied: absl-py in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 1)) (0.10.0)
    Collecting mock
      Downloading https://files.pythonhosted.org/packages/5c/03/b7e605db4a57c0f6fba744b11ef3ddf4ddebcada35022927a2b5fc623fdf/mock-4.0.3-py3-none-any.whl
    Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 3)) (1.18.5)
    Collecting rouge-score
      Downloading https://files.pythonhosted.org/packages/1f/56/a81022436c08b9405a5247b71635394d44fe7e1dbedc4b28c740e09c2840/rouge_score-0.0.4-py2.py3-none-any.whl
    Collecting sacrebleu
      Downloading https://files.pythonhosted.org/packages/a3/c4/8e948f601a4f9609e8b2b58f31966cb13cf17b940b82aa3e767f01c42c52/sacrebleu-1.4.14-py3-none-any.whl (64kB)
         |████████████████████████████████| 71kB 3.8MB/s
    Collecting sentencepiece
      Downloading https://files.pythonhosted.org/packages/e5/2d/6d4ca4bef9a67070fa1cac508606328329152b1df10bdf31fb6e4e727894/sentencepiece-0.1.94-cp36-cp36m-manylinux2014_x86_64.whl (1.1MB)
         |████████████████████████████████| 1.1MB 11.7MB/s
    Collecting tensorflow-text==1.15.0rc0
      Downloading https://files.pythonhosted.org/packages/81/2c/57a6cc36f0ee1acf466a71048e2a0a2a01742eef505b3195d0fa27d87968/tensorflow_text-1.15.0rc0-cp36-cp36m-manylinux1_x86_64.whl (8.6MB)
         |████████████████████████████████| 8.6MB 13.1MB/s
    Collecting tensor2tensor==1.15.0
      Downloading https://files.pythonhosted.org/packages/0f/a6/0f6a95a5548cf9fbfed0bbec69959355bda594e85298ebbba5f808ca0fc5/tensor2tensor-1.15.0-py2.py3-none-any.whl (1.4MB)
         |████████████████████████████████| 1.4MB 44.0MB/s
    Collecting tfds-nightly
      Downloading https://files.pythonhosted.org/packages/f2/7d/93c957b63baed31cd9660c49c393bf7f2eb5b24524c59311053efbb03af0/tfds_nightly-4.1.0.dev202012140107-py3-none-any.whl (3.7MB)
         |████████████████████████████████| 3.7MB 39.3MB/s
    Collecting tensorflow-gpu==1.15.2
      Downloading https://files.pythonhosted.org/packages/32/ca/58e40e5077fa2a92004f398d705a288e958434f123938f4ce75ffe25b64b/tensorflow_gpu-1.15.2-cp36-cp36m-manylinux2010_x86_64.whl (411.0MB)
         |████████████████████████████████| 411.0MB 35kB/s
    Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from absl-py->-r requirements.txt (line 1)) (1.15.0)
    Requirement already satisfied: nltk in /usr/local/lib/python3.6/dist-packages (from rouge-score->-r requirements.txt (line 4)) (3.2.5)
    WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/portalocker/
    Collecting portalocker
      Downloading https://files.pythonhosted.org/packages/89/a6/3814b7107e0788040870e8825eebf214d72166adf656ba7d4bf14759a06a/portalocker-2.0.0-py2.py3-none-any.whl
    Collecting tensorflow<1.16,>=1.15.0
      Downloading https://files.pythonhosted.org/packages/8e/64/7a19837dd54d3f53b1ce5ae346ab401dde9678e8f233220317000bfdb3e2/tensorflow-1.15.4-cp36-cp36m-manylinux2010_x86_64.whl (110.5MB)
         |████████████████████████████████| 110.5MB 28kB/s
    Collecting gevent
      Downloading https://files.pythonhosted.org/packages/3f/92/b80b922f08f222faca53c8d278e2e612192bc74b0e1f0db2f80a6ee46982/gevent-20.9.0-cp36-cp36m-manylinux2010_x86_64.whl (5.3MB)
         |████████████████████████████████| 5.3MB 39.6MB/s
    Requirement already satisfied: requests in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (2.23.0)
    Requirement already satisfied: google-api-python-client in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (1.7.12)
    Requirement already satisfied: oauth2client in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (4.1.3)
    Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (4.41.1)
    Collecting pypng
      Downloading https://files.pythonhosted.org/packages/bc/fb/f719f1ac965e2101aa6ea6f54ef8b40f8fbb033f6ad07c017663467f5147/pypng-0.0.20.tar.gz (649kB)
         |████████████████████████████████| 655kB 35.6MB/s
    Requirement already satisfied: sympy in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (1.1.1)
    Requirement already satisfied: Pillow in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (7.0.0)
    Collecting mesh-tensorflow
      Downloading https://files.pythonhosted.org/packages/16/8b/553deb763ce8d00afb17debab7cb14a87b209cd4c6f0e8ecfc8d884cb12a/mesh_tensorflow-0.1.17-py3-none-any.whl (342kB)
         |████████████████████████████████| 348kB 46.4MB/s
    Collecting tensorflow-gan
      Downloading https://files.pythonhosted.org/packages/0c/2e/62922111d7d50e1900e3030764743ea7735540ce103b3ab30fd5cd2d8a2b/tensorflow_gan-2.0.0-py2.py3-none-any.whl (365kB)
         |████████████████████████████████| 368kB 34.7MB/s
    Collecting bz2file
      Downloading https://files.pythonhosted.org/packages/61/39/122222b5e85cd41c391b68a99ee296584b2a2d1d233e7ee32b4532384f2d/bz2file-0.98.tar.gz
    Requirement already satisfied: future in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (0.16.0)
    Requirement already satisfied: opencv-python in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (4.1.2.30)
    Requirement already satisfied: gin-config in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (0.4.0)
    Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (2.10.0)
    Collecting kfac
      Downloading https://files.pythonhosted.org/packages/1c/36/06fe2c757044bb51906fef231ac48cc5bf9a277fc9a8c7e1108d7e9e8cfd/kfac-0.2.3-py2.py3-none-any.whl (191kB)
         |████████████████████████████████| 194kB 43.8MB/s
    Collecting tensorflow-probability==0.7.0
      Downloading https://files.pythonhosted.org/packages/3e/3a/c10b6c22320531c774402ac7186d1b673374e2a9d12502cbc8d811e4601c/tensorflow_probability-0.7.0-py2.py3-none-any.whl (981kB)
         |████████████████████████████████| 983kB 34.2MB/s
    Requirement already satisfied: dopamine-rl in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (1.0.5)
    Collecting gunicorn
      Downloading https://files.pythonhosted.org/packages/69/ca/926f7cd3a2014b16870086b2d0fdc84a9e49473c68a8dff8b57f7c156f43/gunicorn-20.0.4-py2.py3-none-any.whl (77kB)
         |████████████████████████████████| 81kB 9.3MB/s
    Requirement already satisfied: gym in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (0.17.3)
    Collecting tf-slim
      Downloading https://files.pythonhosted.org/packages/02/97/b0f4a64df018ca018cc035d44f2ef08f91e2e8aa67271f6f19633a015ff7/tf_slim-1.1.0-py2.py3-none-any.whl (352kB)
         |████████████████████████████████| 358kB 37.9MB/s
    Requirement already satisfied: tensorflow-datasets in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (4.0.1)
    Requirement already satisfied: flask in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (1.1.2)
    Requirement already satisfied: scipy in /usr/local/lib/python3.6/dist-packages (from tensor2tensor==1.15.0->-r requirements.txt (line 8)) (1.4.1)
    Requirement already satisfied: dataclasses; python_version < "3.7" in /usr/local/lib/python3.6/dist-packages (from tfds-nightly->-r requirements.txt (line 9)) (0.8)
    Requirement already satisfied: dill in /usr/local/lib/python3.6/dist-packages (from tfds-nightly->-r requirements.txt (line 9)) (0.3.3)
    Requirement already satisfied: protobuf>=3.12.2 in /usr/local/lib/python3.6/dist-packages (from tfds-nightly->-r requirements.txt (line 9)) (3.12.4)
    Requirement already satisfied: attrs>=18.1.0 in /usr/local/lib/python3.6/dist-packages (from tfds-nightly->-r requirements.txt (line 9)) (20.3.0)
    Requirement already satisfied: termcolor in /usr/local/lib/python3.6/dist-packages (from tfds-nightly->-r requirements.txt (line 9)) (1.1.0)
    Requirement already satisfied: tensorflow-metadata in /usr/local/lib/python3.6/dist-packages (from tfds-nightly->-r requirements.txt (line 9)) (0.25.0)
    Requirement already satisfied: promise in /usr/local/lib/python3.6/dist-packages (from tfds-nightly->-r requirements.txt (line 9)) (2.3)
    Requirement already satisfied: typing-extensions; python_version < "3.8" in /usr/local/lib/python3.6/dist-packages (from tfds-nightly->-r requirements.txt (line 9)) (3.7.4.3)
    Requirement already satisfied: importlib-resources; python_version < "3.9" in /usr/local/lib/python3.6/dist-packages (from tfds-nightly->-r requirements.txt (line 9)) (3.3.0)
    Requirement already satisfied: astor>=0.6.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==1.15.2->-r requirements.txt (line 10)) (0.8.1)
    Requirement already satisfied: wheel>=0.26; python_version >= "3" in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==1.15.2->-r requirements.txt (line 10)) (0.36.1)
    Requirement already satisfied: grpcio>=1.8.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==1.15.2->-r requirements.txt (line 10)) (1.34.0)
    Collecting tensorboard<1.16.0,>=1.15.0
      Downloading https://files.pythonhosted.org/packages/1e/e9/d3d747a97f7188f48aa5eda486907f3b345cd409f0a0850468ba867db246/tensorboard-1.15.0-py3-none-any.whl (3.8MB)
         |████████████████████████████████| 3.8MB 38.8MB/s
    Requirement already satisfied: google-pasta>=0.1.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==1.15.2->-r requirements.txt (line 10)) (0.2.0)
    Requirement already satisfied: wrapt>=1.11.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==1.15.2->-r requirements.txt (line 10)) (1.12.1)
    Collecting tensorflow-estimator==1.15.1
      Downloading https://files.pythonhosted.org/packages/de/62/2ee9cd74c9fa2fa450877847ba560b260f5d0fb70ee0595203082dafcc9d/tensorflow_estimator-1.15.1-py2.py3-none-any.whl (503kB)
         |████████████████████████████████| 512kB 40.5MB/s
    Requirement already satisfied: keras-preprocessing>=1.0.5 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==1.15.2->-r requirements.txt (line 10)) (1.1.2)
    Collecting gast==0.2.2
      Downloading https://files.pythonhosted.org/packages/4e/35/11749bf99b2d4e3cceb4d55ca22590b0d7c2c62b9de38ac4a4a7f4687421/gast-0.2.2.tar.gz
    Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==1.15.2->-r requirements.txt (line 10)) (3.3.0)
    Collecting keras-applications>=1.0.8
      Downloading https://files.pythonhosted.org/packages/71/e3/19762fdfc62877ae9102edf6342d71b28fbfd9dea3d2f96a882ce099b03f/Keras_Applications-1.0.8-py3-none-any.whl (50kB)
         |████████████████████████████████| 51kB 7.1MB/s
    Collecting zope.event
      Downloading https://files.pythonhosted.org/packages/9e/85/b45408c64f3b888976f1d5b37eed8d746b8d5729a66a49ec846fda27d371/zope.event-4.5.0-py2.py3-none-any.whl
    Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from gevent->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (50.3.2)
    Collecting zope.interface
      Downloading https://files.pythonhosted.org/packages/82/b0/da8afd9b3bd50c7665ecdac062f182982af1173c9081f9af7261091c5588/zope.interface-5.2.0-cp36-cp36m-manylinux2010_x86_64.whl (236kB)
         |████████████████████████████████| 245kB 51.8MB/s
    Collecting greenlet>=0.4.17; platform_python_implementation == "CPython"
      Downloading https://files.pythonhosted.org/packages/80/d0/532e160c777b42f6f393f9de8c88abb8af6c892037c55e4d3a8a211324dd/greenlet-0.4.17-cp36-cp36m-manylinux1_x86_64.whl (44kB)
         |████████████████████████████████| 51kB 6.2MB/s
    Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (3.0.4)
    Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (2020.12.5)
    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->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (1.24.3)
    Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (2.10)
    Requirement already satisfied: uritemplate<4dev,>=3.0.0 in /usr/local/lib/python3.6/dist-packages (from google-api-python-client->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (3.0.1)
    Requirement already satisfied: google-auth-httplib2>=0.0.3 in /usr/local/lib/python3.6/dist-packages (from google-api-python-client->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (0.0.4)
    Requirement already satisfied: httplib2<1dev,>=0.17.0 in /usr/local/lib/python3.6/dist-packages (from google-api-python-client->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (0.17.4)
    Requirement already satisfied: google-auth>=1.4.1 in /usr/local/lib/python3.6/dist-packages (from google-api-python-client->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (1.17.2)
    Requirement already satisfied: rsa>=3.1.4 in /usr/local/lib/python3.6/dist-packages (from oauth2client->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (4.6)
    Requirement already satisfied: pyasn1>=0.1.7 in /usr/local/lib/python3.6/dist-packages (from oauth2client->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (0.4.8)
    Requirement already satisfied: pyasn1-modules>=0.0.5 in /usr/local/lib/python3.6/dist-packages (from oauth2client->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (0.2.8)
    Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.6/dist-packages (from sympy->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (1.1.0)
    Requirement already satisfied: tensorflow-hub>=0.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gan->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (0.10.0)
    Requirement already satisfied: cloudpickle>=0.6.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow-probability==0.7.0->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (1.3.0)
    Requirement already satisfied: decorator in /usr/local/lib/python3.6/dist-packages (from tensorflow-probability==0.7.0->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (4.4.2)
    Requirement already satisfied: pyglet<=1.5.0,>=1.4.0 in /usr/local/lib/python3.6/dist-packages (from gym->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (1.5.0)
    Requirement already satisfied: dm-tree in /usr/local/lib/python3.6/dist-packages (from tensorflow-datasets->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (0.1.5)
    Requirement already satisfied: Jinja2>=2.10.1 in /usr/local/lib/python3.6/dist-packages (from flask->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (2.11.2)
    Requirement already satisfied: click>=5.1 in /usr/local/lib/python3.6/dist-packages (from flask->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (7.1.2)
    Requirement already satisfied: Werkzeug>=0.15 in /usr/local/lib/python3.6/dist-packages (from flask->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (1.0.1)
    Requirement already satisfied: itsdangerous>=0.24 in /usr/local/lib/python3.6/dist-packages (from flask->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (1.1.0)
    Requirement already satisfied: googleapis-common-protos<2,>=1.52.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow-metadata->tfds-nightly->-r requirements.txt (line 9)) (1.52.0)
    Requirement already satisfied: zipp>=0.4; python_version < "3.8" in /usr/local/lib/python3.6/dist-packages (from importlib-resources; python_version < "3.9"->tfds-nightly->-r requirements.txt (line 9)) (3.4.0)
    Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.6/dist-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow-gpu==1.15.2->-r requirements.txt (line 10)) (3.3.3)
    Requirement already satisfied: cachetools<5.0,>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from google-auth>=1.4.1->google-api-python-client->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (4.1.1)
    Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python3.6/dist-packages (from Jinja2>=2.10.1->flask->tensor2tensor==1.15.0->-r requirements.txt (line 8)) (1.1.1)
    Requirement already satisfied: importlib-metadata; python_version < "3.8" in /usr/local/lib/python3.6/dist-packages (from markdown>=2.6.8->tensorboard<1.16.0,>=1.15.0->tensorflow-gpu==1.15.2->-r requirements.txt (line 10)) (3.1.1)
    Building wheels for collected packages: pypng, bz2file, gast
      Building wheel for pypng (setup.py) ... done
      Created wheel for pypng: filename=pypng-0.0.20-cp36-none-any.whl size=67162 sha256=f4a38d1376ea368e1ffcdee0290c6b624daaf0be28b8c816016815a7a723e906
      Stored in directory: /root/.cache/pip/wheels/41/6b/ef/0493b536b6d4722c2ae9486691b1d49b922b9877922beeabb3
      Building wheel for bz2file (setup.py) ... done
      Created wheel for bz2file: filename=bz2file-0.98-cp36-none-any.whl size=6883 sha256=d3b428488d5729465b668e3975cd36b27b89fa96a69366b11adc8b88859b54eb
      Stored in directory: /root/.cache/pip/wheels/81/75/d6/e1317bf09bf1af5a30befc2a007869fa6e1f516b8f7c591cb9
      Building wheel for gast (setup.py) ... done
      Created wheel for gast: filename=gast-0.2.2-cp36-none-any.whl size=7542 sha256=99a2212ef228e985b3a0b8cb8ca4ac97576f31d6738ab7a6dba8d3a3e87a0f70
      Stored in directory: /root/.cache/pip/wheels/5c/2e/7e/a1d4d4fcebe6c381f378ce7743a3ced3699feb89bcfbdadadd
    Successfully built pypng bz2file gast
    ERROR: kfac 0.2.3 has requirement tensorflow-probability==0.8, but you'll have tensorflow-probability 0.7.0 which is incompatible.
    Installing collected packages: mock, rouge-score, portalocker, sacrebleu, sentencepiece, tensorboard, tensorflow-estimator, gast, keras-applications, tensorflow, tensorflow-text, zope.event, zope.interface, greenlet, gevent, pypng, mesh-tensorflow, tensorflow-probability, tensorflow-gan, bz2file, kfac, gunicorn, tf-slim, tensor2tensor, tfds-nightly, tensorflow-gpu
      Found existing installation: tensorboard 2.3.0
        Uninstalling tensorboard-2.3.0:
          Successfully uninstalled tensorboard-2.3.0
      Found existing installation: tensorflow-estimator 2.3.0
        Uninstalling tensorflow-estimator-2.3.0:
          Successfully uninstalled tensorflow-estimator-2.3.0
      Found existing installation: gast 0.3.3
        Uninstalling gast-0.3.3:
          Successfully uninstalled gast-0.3.3
      Found existing installation: tensorflow 2.3.0
        Uninstalling tensorflow-2.3.0:
          Successfully uninstalled tensorflow-2.3.0
      Found existing installation: tensorflow-probability 0.11.0
        Uninstalling tensorflow-probability-0.11.0:
          Successfully uninstalled tensorflow-probability-0.11.0
    Successfully installed bz2file-0.98 gast-0.2.2 gevent-20.9.0 greenlet-0.4.17 gunicorn-20.0.4 keras-applications-1.0.8 kfac-0.2.3 mesh-tensorflow-0.1.17 mock-4.0.3 portalocker-2.0.0 pypng-0.0.20 rouge-score-0.0.4 sacrebleu-1.4.14 sentencepiece-0.1.94 tensor2tensor-1.15.0 tensorboard-1.15.0 tensorflow-1.15.4 tensorflow-estimator-1.15.1 tensorflow-gan-2.0.0 tensorflow-gpu-1.15.2 tensorflow-probability-0.7.0 tensorflow-text-1.15.0rc0 tf-slim-1.1.0 tfds-nightly-4.1.0.dev202012140107 zope.event-4.5.0 zope.interface-5.2.0

```
!pip install transformers==3.5.0
```

    Collecting transformers==3.5.0
      Downloading https://files.pythonhosted.org/packages/9c/34/fb092588df61bf33f113ade030d1cbe74fb73a0353648f8dd938a223dce7/transformers-3.5.0-py3-none-any.whl (1.3MB)
         |████████████████████████████████| 1.3MB 4.4MB/s
    Requirement already satisfied: requests in /usr/local/lib/python3.6/dist-packages (from transformers==3.5.0) (2.23.0)
    Collecting tokenizers==0.9.3
      Downloading https://files.pythonhosted.org/packages/4c/34/b39eb9994bc3c999270b69c9eea40ecc6f0e97991dba28282b9fd32d44ee/tokenizers-0.9.3-cp36-cp36m-manylinux1_x86_64.whl (2.9MB)
         |████████████████████████████████| 2.9MB 16.7MB/s
    Requirement already satisfied: packaging in /usr/local/lib/python3.6/dist-packages (from transformers==3.5.0) (20.7)
    Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from transformers==3.5.0) (1.18.5)
    Requirement already satisfied: filelock in /usr/local/lib/python3.6/dist-packages (from transformers==3.5.0) (3.0.12)
    Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.6/dist-packages (from transformers==3.5.0) (2019.12.20)
    Collecting sentencepiece==0.1.91
      Downloading https://files.pythonhosted.org/packages/d4/a4/d0a884c4300004a78cca907a6ff9a5e9fe4f090f5d95ab341c53d28cbc58/sentencepiece-0.1.91-cp36-cp36m-manylinux1_x86_64.whl (1.1MB)
         |████████████████████████████████| 1.1MB 34.9MB/s
    Requirement already satisfied: protobuf in /usr/local/lib/python3.6/dist-packages (from transformers==3.5.0) (3.12.4)
    Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.6/dist-packages (from transformers==3.5.0) (4.41.1)
    Collecting sacremoses
      Downloading https://files.pythonhosted.org/packages/7d/34/09d19aff26edcc8eb2a01bed8e98f13a1537005d31e95233fd48216eed10/sacremoses-0.0.43.tar.gz (883kB)
         |████████████████████████████████| 890kB 42.4MB/s
    Requirement already satisfied: dataclasses; python_version < "3.7" in /usr/local/lib/python3.6/dist-packages (from transformers==3.5.0) (0.8)
    Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->transformers==3.5.0) (3.0.4)
    Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->transformers==3.5.0) (2.10)
    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->transformers==3.5.0) (1.24.3)
    Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests->transformers==3.5.0) (2020.12.5)
    Requirement already satisfied: pyparsing>=2.0.2 in /usr/local/lib/python3.6/dist-packages (from packaging->transformers==3.5.0) (2.4.7)
    Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from protobuf->transformers==3.5.0) (50.3.2)
    Requirement already satisfied: six>=1.9 in /usr/local/lib/python3.6/dist-packages (from protobuf->transformers==3.5.0) (1.15.0)
    Requirement already satisfied: click in /usr/local/lib/python3.6/dist-packages (from sacremoses->transformers==3.5.0) (7.1.2)
    Requirement already satisfied: joblib in /usr/local/lib/python3.6/dist-packages (from sacremoses->transformers==3.5.0) (0.17.0)
    Building wheels for collected packages: sacremoses
      Building wheel for sacremoses (setup.py) ... done
      Created wheel for sacremoses: filename=sacremoses-0.0.43-cp36-none-any.whl size=893261 sha256=0e279a57b946faa40c589e8f6aa96a7a2917a4aa5460c08292fee051f6d66287
      Stored in directory: /root/.cache/pip/wheels/29/3c/fd/7ce5c3f0666dab31a50123635e6fb5e19ceb42ce38d4e58f45
    Successfully built sacremoses
    Installing collected packages: tokenizers, sentencepiece, sacremoses, transformers
      Found existing installation: sentencepiece 0.1.94
        Uninstalling sentencepiece-0.1.94:
          Successfully uninstalled sentencepiece-0.1.94
    Successfully installed sacremoses-0.0.43 sentencepiece-0.1.91 tokenizers-0.9.3 transformers-3.5.0

```
import torch
from transformers import PegasusForConditionalGeneration, PegasusTokenizer
model_name = 'tuner007/pegasus_paraphrase'
torch_device = 'cuda' if torch.cuda.is_available() else 'cpu'
tokenizer = PegasusTokenizer.from_pretrained(model_name)
model = PegasusForConditionalGeneration.from_pretrained(model_name).to(torch_device)
def get_response(input_text,num_return_sequences,num_beams):
    batch = tokenizer.prepare_seq2seq_batch([input_text],truncation=True,padding='longest',max_length=60).to(torch_device)
    translated = model.generate(**batch,max_length=60,num_beams=num_beams, num_return_sequences=num_return_sequences, temperature=1.5)
    tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True)
    return tgt_text
```

    HBox(children=(FloatProgress(value=0.0, description='Downloading', max=1912529.0, style=ProgressStyle(descript…

    HBox(children=(FloatProgress(value=0.0, description='Downloading', max=65.0, style=ProgressStyle(description_w…

    HBox(children=(FloatProgress(value=0.0, description='Downloading', max=86.0, style=ProgressStyle(description_w…

    HBox(children=(FloatProgress(value=0.0, description='Downloading', max=1142.0, style=ProgressStyle(description…

    HBox(children=(FloatProgress(value=0.0, description='Downloading', max=2275437102.0, style=ProgressStyle(descr…

```
import pandas as pd
import nltk
nltk.download('cmudict')
nltk.download('wordnet')
```

    [nltk_data] Downloading package cmudict to /root/nltk_data...
    [nltk_data]   Unzipping corpora/cmudict.zip.
    [nltk_data] Downloading package wordnet to /root/nltk_data...
    [nltk_data]   Unzipping corpora/wordnet.zip.

    True

Next, we import the procrustean alliteration paraphraser

```
class RuleBoundsInterface:
    """This interface is used to define different properties of a rhetorical figure generating algorithm.
These properties will create a ruleset for a rhectorical figure, allowing the algorithm to produce results relevant
to the user-request."""

    def evaluate(self, tokenlist, replacementquota):
        """Returns a dataset containing the best application of the rule to the original tokenlist using the proportion specified. This also means
        that certain conditions will have no return value."""
        pass

```

```
class LanguageBoundsInterface:
    """This interface is used to define different properties and implementation of a language.
These properties will create a ruleset for a language, which will be the bounds an algorithm
can work in the given context."""

    ########## Variables ##########

    _NULL_PHENOME_INDICATOR = None # Phenome representation of an unknown phenome
    _SIMILARITY_THRESHOLD = 0.2 # The threshold that must be passed for a word to be considered similar. Scaled from 0-1.
    MULTI_TOKEN_INDICATOR = None # Character used to identify when a token has multiple words. This functionality is specific to a corpus. Must be changed if corpus is changed.
    vowelphenomes = None # Contains all phenomes that produce vowel-related sounds for this language.

    ###############################

    ########## Constructor ##########

    def __init__(self, sensitivity):
        self._SIMILARITY_THRESHOLD = sensitivity

    #################################

    def getphenomes(self, arg):
        """Returns all phenome-lists related to the token."""
        pass

    def hypernyms(self, arg):
        """Returns all hypernyms related to the token. ('context' is the representation of the phrase in collection form.)"""
        pass

    def hyponyms(self, arg):
        """Returns all hyponyms related to the token. ('context' is the representation of the phrase in collection form.)"""
        pass

    def messagefail(self, input):
        """Produces the fail message to print to users in this language if the process cannot return a value."""
        pass

    def messageonlyresult(self, arg):
        """Produces a indicator message if only one result was possible from the input parameters given."""
        pass

    def messagetopresult(self, resultlen, requestedresultcount):
        """Produces the top 'x' results message to users in this language if the process has multiple results."""
        pass

    def similarity(self, arg, arg2):
        """Returns a token similarity score based on language-based weights. Used for determining optimal replacement for
        contexts."""
        pass

    def split(self, arg):
        """Returns an ordered list of tokens, split at delimiters based off of the the language context settings."""
        pass
```

```
from enum import Enum
from nltk import RegexpTokenizer
from nltk.corpus import cmudict
from nltk.corpus import wordnet
from nltk.wsd import lesk

class AmericanEnglishLangContext(LanguageBoundsInterface):
    """Defines the properties and implementation of standard American English."""

    ########## Variables ##########

    _cmu = cmudict.dict() # Pretrained phenome generation model. Created outside of methods because it is used over iteration(s) and is expensive to generate; TREAT THIS VALUE AS AN IMMUTABLE.
    _MULTI_TOKEN_INDICATOR = "_" # Character used to identify when a token has multiple words. This functionality is specific to a corpus. Must be changed if corpus is changed.
    _NULL_PHENOME_INDICATOR = "*NONE*" # Used by algorithm to indicate if a corressponding phemone could not be found for a token
    _SIMILARITY_THRESHOLD = 0.2 # The threshold that must be passed for a word to be considered similar. Scaled from 0-1.
    vowelphenomes = ["AA", "AE", "AH", "AO", "AW", "AY",
                    "AX", "AXR", "EH", "ER", "EY", "IH",
                    "IX", "IY", "OW", "OY","UH", "UW", "UX"] # Contains all phenomes that produce vowel-related sounds for this language.

    ###############################
    def _getproperformattype(self, unformattoken):
        """Used to parse through the Wordnet sysnet-token return value to retrieve only relevant sections. Currently the only returns the word.
        In future implementations, this function may not be needed if the corpus has a function to return only the word as a string."""

        name, junk = unformattoken.name().split(".", 1);
        return name

    def _getproperhandlemissingphenome(self, unknowntoken):
        """Takes a unknown-phenome (a token which could not be evaluated by CMUdict) and attempts to generate a phenome. If CMUdict or
        Wordnet implementation is changed this function MUST be changed."""

        finaleval = []

        # After various testing, it has been determined that calculating for two letters yields the most consistent results for unknown phenomes.
        tokenlen = len(unknowntoken)
        if tokenlen is 0:
            finaleval.append([self._NULL_PHENOME_INDICATOR])
        elif tokenlen is 1:
            finaleval.append([unknowntoken.upper()]) # The letter IS the phenome
        else:
            relevant = unknowntoken[:2] # get first two chars
            finalattempt = self._cmu.get(relevant, None)

            if finalattempt is None: # No possible phenome can be generated by this algorithm
                finaleval.append([self._NULL_PHENOME_INDICATOR])
            elif finalattempt is list:
                finaleval.append(finalattempt)
            else:  # 'finalattempt' is guareenteed to only be of type NONE, list, or list[list].
                finaleval.extend(finalattempt) # flatten list; tis step is necessary to maintain parsability

        return finaleval

    def _getproperhandlemultitoken(self, multitoken):
        """Takes a multi-word (a token with words seperated by '_' by Wordnet) and breaks it down into a format that can be evaluated by the CMUdict. If CMUdict or
        Wordnet implementation is changed this function MUST be changed."""

        finaleval = []
        individualtokens = multitoken.split(self._MULTI_TOKEN_INDICATOR)

        for token in individualtokens: # evaluate each token phenome indiviually; then represent multitoken for EACH phenome calculated, when returned to scanning.
            phenome = self._cmu.get(token.lower(), None)

            if phenome is list:
                finaleval.append(phenome)

            else: # 'phenome' is guareenteed to only be of type NONE, list, or list[list].
                if phenome is None:
                    phenome = self._getproperhandlemissingphenome(token)

                finaleval.extend(phenome) # flatten list; this step is necessary to maintain parsability

        return finaleval

    def getphenomes(self, arg):
        """Returns all phenome-lists related to the token. ('context' is the representation of the phrase in collection form.)"""

        # uses CMUdict as the core processing algorithm. If CMUdict fails to find a match the function will predict a possible phenome for the token.
        # This function is guareenteed to return a value.

        generatephenome = self._cmu.get(arg.lower(), None) # _cmu is defined globally above in "VARIABLES" section. Treat as an immutable.
        if generatephenome is None:
            if arg.__contains__(self._MULTI_TOKEN_INDICATOR): # _MULTI_TOKEN_INDICATOR is defined globally above in "VARIABLES" section. Treat as an immutable.
                generatephenome = self._getproperhandlemultitoken(arg)

            else: # token is unknown by CMUdict
                generatephenome = self._getproperhandlemissingphenome(arg)

        # When multiple phenomes exist for same word, a list[list[str]] is generated
        return generatephenome

    def hypernyms(self, context, arg):
        """Returns all hypernyms related to the token. ('context' is the representation of the phrase in collection form.)"""

        # This function assumes the use of Wordnet. If Wordnet implementation changes, this function MUST change.

        eval = None
        interpretation = lesk(context, arg)
        if interpretation is not None:
            eval = map(self._getproperformattype, interpretation.hypernyms())

        return eval

    def hyponyms(self, context, arg):
        """Returns all hyponyms related to the token."""

        # This function assumes the use of Wordnet. If Wordnet implementation changes, this function MUST change.

        eval = None
        interpretation = lesk(context, arg)
        if interpretation is not None:
            eval = map(self._getproperformattype, interpretation.hyponyms())

        return eval

    def messagefail(self, input):
        """Produces the fail message to print to users in this language if the process cannot return a value."""
        built = " ".join(input)
        return ("Your input: '" + built + "' was not able to be parsed under the conditions you desired. Please try new conditions or try a new phrase.")

    def messageonlyresult(self, arg):
        """Produces a indicator message if only one result was possible from the input parameters given."""
        return ("This is the only result processed from the given input:\n" + arg)

    def messagetopresult(self, resultlen, requestedresultcount):
        """Produces the top 'x' results message to users in this language if the process has multiple results."""
        if resultlen < requestedresultcount:
            return ("Top " + str(resultlen) + " result(s):\n")
        else:
            return ("Top " + str(requestedresultcount) + " result(s):\n")

    def similarity(self, contextclues, arg1, arg2):
        """Returns a key-value pair for scoring similarity. [0] a bool that determines if the word is similar enough to satisfy language criteria
        and the score associated with the evaluation."""

        # This function assumes the use of Wordnet. If Wordnet implementation changes, this function MUST change.

        evaluation = False
        score = 0

        if arg1 is arg2:
            evaluation = True
            score = self._SIMILARITY_THRESHOLD # Penalizing score to prevent paraphrases from returning themselves

        else:
            contextA = lesk(contextclues, arg1)
            contextB = lesk(contextclues, arg2)

            if contextA and contextB: # Otherwise score will stay zero
                score = contextA.path_similarity(contextB)

                if score is not None and self._SIMILARITY_THRESHOLD <= score:
                    evaluation = True

        return (evaluation, score)

    def split(self, arg):
        # Returns all non-whitespace tokens.
        return RegexpTokenizer('\w+|\$[\d\.]+|\S+').tokenize(arg)
```

```
class Mapper:
    """This module takes a user-input string and chunks it into formatted tuples which
contains relevant data for all essential pieces of string."""

    def maptolist(self, arg, langbound):
        """Returns formatted-tuple containing relevant processing data for each token.""" #update
        return self._internalmap(arg, langbound)

    def _internalmap(self, arg, langbound):
        # Internally seperates the string into relevant tokens. # update
        return langbound.split(arg)
```

```
class AlliterationRuleContext(RuleBoundsInterface):
    """Defines the properties and rules of the alliteration rhetorical figure."""

    def _applyrule(self, sourcedata, tokentargetcount, langbound):
        """Trim interal-map token list to only retain tokens that constrain to the alliteration ruleset."""

        phenomeselect = []
        for phenomeset in sourcedata:
            if phenomeset not in langbound.vowelphenomes:
                #run proportion algorithm
                setrep = sourcedata[phenomeset]
                if tokentargetcount <= len(setrep):
                    phenomeselect.append(sourcedata[phenomeset])

        # Return selection
        if not phenomeselect:
            return None
        else:
            return phenomeselect

    def _applyscan(self, sourcematrix, langbound):
        """Scan a token-matrix and return a dataset that holds information on the phenome frequency of alliteration
        in the matrix."""

        dataset = {} # Dicitonary is of type 'char' -> dict{int -> list[str]}'

        for index, item in enumerate(sourcematrix): # going through each token
            for content in item: # going through synonym content of each token

                phenomelists = self._getsourcephenome(content, langbound) # generate phenomes for alliteration evaluation
                for phenomes in phenomelists: # going through each phenome list for token (some tokes may have multiple pronounciations)

                    relevantphenome = phenomes[0] # use the FIRST phenome because this is alliteration

                    if dataset.get(relevantphenome, None) is None: # if letter has NOT been scanned previously, create an entry
                       dataset[ relevantphenome ] = {} # Dictionary will contain key-value pairs corresponding to the index and the list of words available.
                       dataset[ relevantphenome ] [index] = [content]

                    else:
                        if dataset[ relevantphenome ].get(index, None) is None: # if an entry for THIS index has NOT been created, create one.
                            dataset[ relevantphenome ] [index] = [content]
                        else:
                            if content not in dataset[ relevantphenome ] [index]:
                                dataset[ relevantphenome ] [index].append(content)

        return dataset

    def _getsourcephenome(self, evaltoken, langbound):
        """Returns a phenome value for a string-token."""

        phenomeform = langbound.getphenomes(evaltoken)
        return phenomeform

    def _getrelevantsynonyms(self, tokenlist, sourcetoken, langbound):
        """Returns a token-list of the original context and synonyms that are relevant, if applicable."""

        relevant = [sourcetoken] # original token is always first within the collection

        # Add all relevant synonyms to evaluation list as strings

        hypernyms = langbound.hypernyms(tokenlist, sourcetoken)
        hyponyms = langbound.hyponyms(tokenlist, sourcetoken)

        if hypernyms is not None:
            relevant.extend(hypernyms)
        if hyponyms is not None:
            relevant.extend(hyponyms)

        return relevant

    def _internalmap(self, tokenlist, langbound):
        """Map relevant replacement tokens to a matrix. This return token-matrix will have a one-to-to corresspondence
        to the passed tokenlist argument."""

        replacements = []
        for token in tokenlist:
            similar = self._getrelevantsynonyms(tokenlist, token, langbound)
            replacements.append(similar)

        return replacements

    def evaluate(self, tokenlist, replacementquota, langbound):
        if replacementquota < 1: # Nothing will be applied to the target list. Do not process.
            return None

        # Map and chart data for rule application
        preprocess = self._internalmap(tokenlist, langbound)
        process = self._applyscan(preprocess, langbound)

        # Apply rule and return data
        postprocess = self._applyrule(process, replacementquota, langbound)
        return postprocess
```

```
class AssonanceRuleContext(RuleBoundsInterface):
    """Defines the properties and rules of the assonance rhetorical figure."""

    def _applyrule(self, sourcedata, tokentargetcount, langbound):
        """Trim interal-map token list to only retain tokens that constrain to the assonance ruleset."""

        phenomeselect = []
        for phenomeset in sourcedata:
            if phenomeset in langbound.vowelphenomes:
                #run proportion algorithm
                setrep = sourcedata[phenomeset]
                if tokentargetcount <= len(setrep):
                    phenomeselect.append(sourcedata[phenomeset])

        # Return selection
        if not phenomeselect:
            return None
        else:
            return phenomeselect

    def _applyscan(self, sourcematrix, langbound):
        """Scan a token-matrix and return a dataset that holds information on the phenome frequency of assonance
        in the matrix."""

        dataset = {} # Dicitonary is of type 'char' -> dict{int -> list[str]}'

        for index, item in enumerate(sourcematrix): # going through each token
            for content in item: # going through synonym content of each token

                phenomelists = self._getsourcephenome(content, langbound) # generate phenomes for assonance evaluation
                for phenomes in phenomelists: # going through each phenome list for token (some tokes may have multiple pronounciations)

                    relevantphenome = phenomes[0] # use the FIRST phenome because this is assonance

                    if dataset.get(relevantphenome, None) is None: # if letter has NOT been scanned previously, create an entry
                       dataset[ relevantphenome ] = {} # Dictionary will contain key-value pairs corresponding to the index and the list of words available.
                       dataset[ relevantphenome ] [index] = [content]

                    else:
                        if dataset[ relevantphenome ].get(index, None) is None: # if an entry for THIS index has NOT been created, create one.
                            dataset[ relevantphenome ] [index] = [content]
                        else:
                            if content not in dataset[ relevantphenome ] [index]:
                                dataset[ relevantphenome ] [index].append(content)

        return dataset

    def _getsourcephenome(self, evaltoken, langbound):
        """Returns a phenome value for a string-token using CMUdict as the core processing algorithm. If CMUdict fails to find a match
        the function will predict a possible phenome for the token. This function is guareenteed to return a value."""

        phenomeform = langbound.getphenomes(evaltoken)
        return phenomeform

    def _getrelevantsynonyms(self, tokenlist, sourcetoken, langbound):
        """Returns a token-list of the original context and synonyms that are relevant, if applicable."""

        relevant = [sourcetoken] # original token is always first within the collection

        # Add all relevant synonyms to evaluation list as strings

        hypernyms = langbound.hypernyms(tokenlist, sourcetoken)
        hyponyms = langbound.hyponyms(tokenlist, sourcetoken)

        if hypernyms is not None:
            relevant.extend(hypernyms)
        if hyponyms is not None:
            relevant.extend(hyponyms)

        return relevant

    def _internalmap(self, tokenlist, langbound):
        """Map relevant replacement tokens to a matrix. This return token-matrix will have a one-to-to corresspondence
        to the passed tokenlist argument."""

        replacements = []
        for token in tokenlist:
            similar = self._getrelevantsynonyms(tokenlist, token, langbound)
            replacements.append(similar)

        return replacements

    def evaluate(self, tokenlist, replacementquota, langbound):
        if replacementquota < 1: # Nothing will be applied to the target list. Do not process.
            return None

        # Map and chart data for rule application
        preprocess = self._internalmap(tokenlist, langbound)
        process = self._applyscan(preprocess, langbound)

        # Apply rule and return data
        postprocess = self._applyrule(process, replacementquota, langbound)
        return postprocess
```

```
class RhymeRuleContext(RuleBoundsInterface):
    """Defines the properties and rules of the rhyme rhetorical figure."""

    def _applyrule(self, sourcedata, tokentargetcount, langbound):
        """Trim interal-map token list to only retain tokens that constrain to the rhyme ruleset."""

        phenomeselect = []
        for phenomeset in sourcedata:
            #run proportion algorithm
            setrep = sourcedata[phenomeset]
            if tokentargetcount <= len(setrep):
                phenomeselect.append(sourcedata[phenomeset])

        # Return selection
        if not phenomeselect:
            return None
        else:
            return phenomeselect

    def _applyscan(self, sourcematrix, langbound):
        """Scan a token-matrix and return a dataset that holds information on the phenome frequency of rhyme
        in the matrix."""

        dataset = {} # Dicitonary is of type 'char' -> dict{int -> list[str]}'

        for index, item in enumerate(sourcematrix): # going through each token
            for content in item: # going through synonym content of each token

                phenomelists = self._getsourcephenome(content, langbound) # generate phenomes for rhyme evaluation
                for phenomes in phenomelists: # going through each phenome list for token (some tokes may have multiple pronounciations)

                    relevantphenome = phenomes[len(phenomes) - 1] # use the LAST phenome because this is rhyme

                    if dataset.get(relevantphenome, None) is None: # if letter has NOT been scanned previously, create an entry
                       dataset[ relevantphenome ] = {} # Dictionary will contain key-value pairs corresponding to the index and the list of words available.
                       dataset[ relevantphenome ] [index] = [content]

                    else:
                        if dataset[ relevantphenome ].get(index, None) is None: # if an entry for THIS index has NOT been created, create one.
                            dataset[ relevantphenome ] [index] = [content]
                        else:
                            if content not in dataset[ relevantphenome ] [index]:
                                dataset[ relevantphenome ] [index].append(content)

        return dataset

    def _getsourcephenome(self, evaltoken, langbound):
        """Returns a phenome value for a string-token."""

        phenomeform = langbound.getphenomes(evaltoken)
        return phenomeform

    def _getrelevantsynonyms(self, tokenlist, sourcetoken, langbound):
        """Returns a token-list of the original context and synonyms that are relevant, if applicable."""

        relevant = [sourcetoken] # original token is always first within the collection

        # Add all relevant synonyms to evaluation list as strings

        hypernyms = langbound.hypernyms(tokenlist, sourcetoken)
        hyponyms = langbound.hyponyms(tokenlist, sourcetoken)

        if hypernyms is not None:
            relevant.extend(hypernyms)
        if hyponyms is not None:
            relevant.extend(hyponyms)

        return relevant

    def _internalmap(self, tokenlist, langbound):
        """Map relevant replacement tokens to a matrix. This return token-matrix will have a one-to-to corresspondence
        to the passed tokenlist argument."""

        replacements = []
        for token in tokenlist:
            similar = self._getrelevantsynonyms(tokenlist, token, langbound)
            replacements.append(similar)

        return replacements

    def evaluate(self, tokenlist, replacementquota, langbound):
        if replacementquota < 1: # Nothing will be applied to the target list. Do not process.
            return None

        # Map and chart data for rule application
        preprocess = self._internalmap(tokenlist, langbound)
        process = self._applyscan(preprocess, langbound)

        # Apply rule and return data
        postprocess = self._applyrule(process, replacementquota, langbound)
        return postprocess
```

```
import heapq

class Analyzer:
    """Takes a rule-output and applies it to the target-input while attempting to retain the original meaning of the input as much as possible."""

    def _checkaccuracy(self, bestfitdata):
        """Takes a bestfitted output-slice and scores it on its accuracy when compared to original sentence."""

        if not bestfitdata:
            return None
        elif len(bestfitdata) is 1:
            return bestfitdata[0] # only one possible return
        else:

            accuracyheap = []
            for collection in bestfitdata:
                accuracy = 0 # reset every iteration
                for item in collection:
                    accuracy += item[0] # the first value in every tuple is expected to be accuracy score.

                heapq.heappush(accuracyheap, (accuracy, collection))

            return heapq.nlargest(len(accuracyheap) - 1, accuracyheap)[0][1] # contains all values in highest to lowest order, but only returns highest

    def _checkbestfit(self, input, outputslice, langbound, replacementquota):
        """Takes a index to word-list mapping and selects the word from the list that retains the most sentence meaning. If no word applies, there will be no word
        replacement for that slot."""

        bestfitinorder = [] # Used as a heapq to sort by highest scores.
        for index in outputslice: # each replacement index in dict

            tokenselect = None
            highestscore = 0 # Used to select best word, resets on every changed index.

            for token in outputslice[index]: # each word in replacement index
                compareto = input[index] #corressponding index in original input
                score = langbound.similarity(input, compareto, token)

                if score[0] and highestscore < score[1]: # Does satisfy similarity criteria?
                    tokenselect = token
                    highestscore = score[1]

            if tokenselect: # After evaluation, check if there are any valid tokens to use.
                heapq.heappush(bestfitinorder, (highestscore, index, tokenselect)) # Acts as a priority queue and orders values from lowest to highest

        # Returning
        if len(bestfitinorder) < replacementquota: # Not enough values to return, replacements are invalid
            return None
        else:
            return heapq.nlargest(int(replacementquota), bestfitinorder)

    def _construct(self, originalinput, tokenchain, langbound, requestedresults): # add variable top X accurate results
        """Converts a token list and bestfit data into a readable string."""

        convergence = []
        result = " "
        empty = " " # placeholder to perform syntax operations on

        if tokenchain is None:
            #result = langbound.messagefail(originalinput)
            result = ""

        else:
            convergence = self._replacetokens(originalinput, tokenchain)
            #result = langbound.messageonlyresult(empty.join(convergence))
            result = empty.join(convergence)
            #if type(result) == str:
            result = result.replace("_"," ")

        return result

    def _internalmap(self, originalinput, ruleoutput, langbound, replacementquota):
        """Maps each rule-output dictionary to be checked for bestfit."""

        mapping = []

        if ruleoutput is not None:
            for outs in ruleoutput: # Iterate through each output dict avaliable
                trimmed = self._checkbestfit(originalinput, outs, langbound, replacementquota)
                if trimmed is not None:
                    mapping.append(trimmed)

        return mapping

    def _replacetokens(self, originalinput, tokenchain):
        """Replaces tokens at targeted indicies in the original input from tokenchain, and returns a list of the results. This algorithm expects tokenchain to be a list."""

        for item in tokenchain: # Tuples containing (score, index, token)
            originalinput[item[1]] = item[2] # works because indicies were marked from beginning of process

        return originalinput # this is after modifications

    def analyze(self, originalinput, ruleoutput, langbound, replacementquota, topresults = 1):
        """Applies a rule-output to a target input and attempts to retain input meaning. Rule output is expected to be in (float, list[ dict(int, list[str]) ]) format."""

        preprocess = self._internalmap(originalinput, ruleoutput, langbound, replacementquota)
        process = self._checkaccuracy(preprocess)
        postprocess = self._construct(originalinput, process, langbound, topresults)
        return postprocess
```

We define three methods for use in the final integrated function

```
def alliteration(arg, proportion, sensitivity):
    langcontext = AmericanEnglishLangContext(sensitivity)
    mapsection = Mapper()
    rule = AlliterationRuleContext()
    interpreter = Analyzer()
    mappedtokens = mapsection.maptolist(arg, langcontext)

    # Calculate exact proportion
    calcd = len(mappedtokens)
    if proportion < 1:
        calcd *= proportion
        calcd = round(calcd)

    applied = rule.evaluate(mappedtokens, calcd, langcontext)
    finalresult = interpreter.analyze(mappedtokens, applied, langcontext, calcd)

    return finalresult
```

```
def assonance(arg, proportion, sensitivity):
    langcontext = AmericanEnglishLangContext(sensitivity)
    mapsection = Mapper()
    rule = AssonanceRuleContext()
    interpreter = Analyzer()
    mappedtokens = mapsection.maptolist(arg, langcontext)

    # Calculate exact proportion
    calcd = len(mappedtokens)
    if proportion < 1:
        calcd *= proportion
        calcd = round(calcd)

    applied = rule.evaluate(mappedtokens, calcd, langcontext)
    finalresult = interpreter.analyze(mappedtokens, applied, langcontext, calcd)

    return finalresult
```

```
def rhyming(arg, proportion, sensitivity):
    langcontext = AmericanEnglishLangContext(sensitivity)
    mapsection = Mapper()
    rule = RhymeRuleContext()
    interpreter = Analyzer()
    mappedtokens = mapsection.maptolist(arg, langcontext)

    # Calculate exact proportion
    calcd = len(mappedtokens)
    if proportion < 1:
        calcd *= proportion
        calcd = round(calcd)

    applied = rule.evaluate(mappedtokens, calcd, langcontext)
    finalresult = interpreter.analyze(mappedtokens, applied, langcontext, calcd)

    return finalresult
```

Next, we define the sentence curator

```
!pip install fuzzywuzzy[speedup]
```

    Collecting fuzzywuzzy[speedup]
      Downloading https://files.pythonhosted.org/packages/43/ff/74f23998ad2f93b945c0309f825be92e04e0348e062026998b5eefef4c33/fuzzywuzzy-0.18.0-py2.py3-none-any.whl
    Collecting python-levenshtein>=0.12; extra == "speedup"
      Downloading https://files.pythonhosted.org/packages/42/a9/d1785c85ebf9b7dfacd08938dd028209c34a0ea3b1bcdb895208bd40a67d/python-Levenshtein-0.12.0.tar.gz (48kB)
         |████████████████████████████████| 51kB 5.8MB/s
    Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from python-levenshtein>=0.12; extra == "speedup"->fuzzywuzzy[speedup]) (50.3.2)
    Building wheels for collected packages: python-levenshtein
      Building wheel for python-levenshtein (setup.py) ... done
      Created wheel for python-levenshtein: filename=python_Levenshtein-0.12.0-cp36-cp36m-linux_x86_64.whl size=144799 sha256=581bcf38668241e4858264d7a445ef0a42e5b7b8dc57b84e14eb9b66ea8d0c3b
      Stored in directory: /root/.cache/pip/wheels/de/c2/93/660fd5f7559049268ad2dc6d81c4e39e9e36518766eaf7e342
    Successfully built python-levenshtein
    Installing collected packages: python-levenshtein, fuzzywuzzy
    Successfully installed fuzzywuzzy-0.18.0 python-levenshtein-0.12.0

```
# Load clustering and Levenshtein distance
import scipy.cluster.hierarchy as h
from fuzzywuzzy import fuzz
import scipy.spatial.distance as d
```

```
# Load word2vec prerequisites for correlation distance between words

!wget -P /root/input/ -c "https://s3.amazonaws.com/dl4j-distribution/GoogleNews-vectors-negative300.bin.gz"
!pip3 install gensim
from gensim.models import KeyedVectors
vecmod = KeyedVectors.load_word2vec_format('/root/input/GoogleNews-vectors-negative300.bin.gz', binary=True)
# Load Google's pre-trained Word2Vec model.

import numpy as np
from scipy import spatial
from nltk.tokenize import word_tokenize
from nltk import download
download('stopwords')
download('punkt')

from nltk.corpus import stopwords
stop_words = set(stopwords.words('english'))
index2word_set = set(vecmod.wv.index2word)
```

    --2020-12-14 18:57:51--  https://s3.amazonaws.com/dl4j-distribution/GoogleNews-vectors-negative300.bin.gz
    Resolving s3.amazonaws.com (s3.amazonaws.com)... 52.217.106.182
    Connecting to s3.amazonaws.com (s3.amazonaws.com)|52.217.106.182|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 1647046227 (1.5G) [application/x-gzip]
    Saving to: ‘/root/input/GoogleNews-vectors-negative300.bin.gz’

    GoogleNews-vectors- 100%[===================>]   1.53G  35.3MB/s    in 45s

    2020-12-14 18:58:37 (34.5 MB/s) - ‘/root/input/GoogleNews-vectors-negative300.bin.gz’ saved [1647046227/1647046227]

    Requirement already satisfied: gensim in /usr/local/lib/python3.6/dist-packages (3.6.0)
    Requirement already satisfied: numpy>=1.11.3 in /usr/local/lib/python3.6/dist-packages (from gensim) (1.18.5)
    Requirement already satisfied: six>=1.5.0 in /usr/local/lib/python3.6/dist-packages (from gensim) (1.15.0)
    Requirement already satisfied: smart-open>=1.2.1 in /usr/local/lib/python3.6/dist-packages (from gensim) (4.0.1)
    Requirement already satisfied: scipy>=0.18.1 in /usr/local/lib/python3.6/dist-packages (from gensim) (1.4.1)
    [nltk_data] Downloading package stopwords to /root/nltk_data...
    [nltk_data]   Unzipping corpora/stopwords.zip.
    [nltk_data] Downloading package punkt to /root/nltk_data...
    [nltk_data]   Unzipping tokenizers/punkt.zip.

    /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:18: DeprecationWarning: Call to deprecated `wv` (Attribute will be removed in 4.0.0, use self instead).

```
def curate(input, candidates, max_clusters):

  def _SentenceVec(sentence):
    tokens = word_tokenize(sentence)
    words = [word.lower() for word in tokens if word.isalpha()]
    words = [word for word in words if not word in stop_words]
    sentence_vec = np.zeros((300, ), dtype='float32')
    n_words = 0
    for word in words:
        if word in index2word_set:
            n_words += 1
            sentence_vec = np.add(sentence_vec, vecmod[word])
    if (n_words > 0):
        sentence_vec = np.divide(sentence_vec, n_words)
    return sentence_vec

  ## This is the start of an alternative approach to the metric
  ## The idea is to define each sentence simply as an array of word vectors
  ## And compute the distance between the two arrays using cdist().
  ## Then use the mahalanobis distance to compute the distance between the
  ## two populations. This shoudl capture some of the lost structure of
  ## mean vectors.
  #def _SentenceArray(sentence):
  #  tokens = word_tokenize(sentence)
  #  words = [word.lower() for word in tokens if word.isalpha()]
  #  words = [word for word in words if not word in stop_words]
  #  sentence_array = np.zeros((300, ), dtype='float32')
  #  n_words = 0
  #  for word in words:
  #      if word in index2word_set:
  #          n_words += 1
  #          sentence_array = np.add(sentence_array, vecmod[word])

  def _cor_dist(s1, s2):
    distance = spatial.distance.correlation(s1, s2)
    return distance

  def _cluster(candidates,max_clusters):
    X = [[c] for c in candidates]
    #V = [_SentenceVec(c) for c in candidates]
    Levenshtein = [(100-d)/100 for d in d.pdist(X,fuzz.ratio)]
    #Covariance = d.pdist(V,_cor_dist)
    #y = [a*b for a,b in zip(Levenshtein,Covariance)]
    y = Levenshtein
    Z = h.linkage(y)
    return h.fcluster(Z,t=max_clusters,criterion="maxclust")

  def _score_paraphrases(candidates,original):
    V = [_SentenceVec(c) for c in candidates]
    t = _SentenceVec(original)
    return [_cor_dist(paraphrase,t) for paraphrase in V]

  if len(candidates) > 0:
    clust = _cluster(candidates,max_clusters)
    score = _score_paraphrases(candidates,input)
    # groups = dict(zip(clust,[zip(score,candidates)]))
    keys = list(set(clust))
    group = {key:[] for key in keys}
    for i in range(len(candidates)):
      group[clust[i]].append([score[i],candidates[i]])

    top_results = []
    for key in group:
      scores = [group[key][i][0] for i in range(len(group[key]))]
      for j in range(len(group[key])):
        if group[key][j][0] == max(scores):
          top_results.append(group[key][j][1])

    return top_results

  if len(candidates) == 0:
      print("There were no results")
```

Next, we integrate the Pegasus sample generator, the Procrustean paraphraser and the paraphrase curator.

```
def paraphrase(input, proportion, sensitivity, max_output, sample_size, method):
  # Generate sample with Pegasus
  num_return_sequences = sample_size
  num_beams = 4*sample_size
  sample = get_response(input,num_return_sequences,num_beams)
  sample.append(input)

  # Generate paraphrase list with given method
  candidates = []
  for i in range(len(sample)):
    candidates.append(method(sample[i],proportion,sensitivity))
    for x in candidates:
      if x == "":
        candidates.remove(x)

  # curate the list
  result = curate(input, candidates, max_output)
  return result
```

```
x = "the cat jumped over the moon and ate the planet jupyter"
paraphrase(x,0.4,0.15,2,25,rhyming)
```

    ['the feline jumped over the moon and ate the jovian planet jupyter']

```
x = "the cat jumped over the moon and ate the planet jupyter"
paraphrase(X,0.3,0.5,5,20,assonance)
```

    There were no results

```
x = "the cat jumped over the moon and landed on planet jupyter"
proportion = 0.4
sensitivity = 0.3
max_output = 3
sample_size = 20
paraphrase(x,proportion,sensitivity,max_output,sample_size,alliteration)
```

Lastly, we test the algorithm on a sample of eight excerpts from classic works.

We have 3 methods and we set the max output to 3. Thus we have a maximum of 72 possible sentences to evaluate.

```
Dickens = "My meaning simply is, that whatever I have tried to do in life, I have tried with all my heart to do well"
Twain = "Persons attempting to find a motive in this narrative will be prosecuted; persons  attempting to find a moral in it will be banished; persons attempting to find a plot in it will be shot."
Forster = "Most of life is so dull that there is nothing to be said about it, and the books and talk that would describe it as interesting are obliged to exaggerate, in the hope of justifying their own existence."
Grahame = "The Mole was a good listener, and Toad, with no one to check his statements or to criticize in an unfriendly spirit, rather let himself go."
Joyce = "A certain pride, a certain awe, withheld him from offering to God even one prayer at night, though he knew it was in God’s power to take away his life while he slept and hurl his soul hellward ere he could beg for mercy."
London = "When, on the still cold nights, he pointed his nose at a star and howled long and wolf-like, it was his ancestors, dead and dust, pointing nose at star and howling down through the centuries and through him."
Fitzgerald = "And so with the sunshine and the great bursts of leaves growing on the trees, just as things grow in fast movies, I had that familiar conviction that life was beginning over again with the summer."
Eliot = "For years after Lydgate remembered the impression produced in him by this involuntary appeal—this cry from soul to soul."

test_set = [Dickens,Twain,Forster,Grahame,Joyce,London,Fitzgerald,Eliot]

```

```
Dickens_alliteration = paraphrase(Dickens,0.3,0.3,3,30,alliteration)
print(Dickens)
for sentence in Dickens_alliteration:
  print(sentence)
```

    My meaning simply is, that whatever I have tried to do in life, I have tried with all my heart to do well
    My connotation coexist that chemical element have tried everything chemical element can to do well .

```
Twain_alliteration = paraphrase(Twain,0.2,0.2,3,30,alliteration)
print(Twain)
for sentence in Twain_alliteration:
  print(sentence)
```

    Persons attempting to find a motive in this narrative will be prosecuted; persons  attempting to find a moral in it will be banished; persons attempting to find a plot in it will be shot.
    populate trying to perceive a reason in this narrative will be politick , populate trying to perceive a moral in it will be exiled , and populate trying to perceive a plot in it will be shot .
    If tempter tries to find a reason in this tall tale , they new testament translate prosecuted , if they try to find a moral in it , they new testament translate banished , and if they try to find a plot in it , they new testament translate shot .
    People trying to find a motive in the nursery rhyme new testament be prosecuted , people trying to find nucleotide moral in the nursery rhyme new testament be banished , and people trying to find nucleotide plot in the nursery rhyme new testament be shot .

```
Forster_alliteration = paraphrase(Forster,0.2,0.6,3,30,alliteration)
print(Forster)
for sentence in Forster_alliteration:
  print(sentence)
```

    Most of life is so dull that there is nothing to be said about it, and the books and talk that would describe it as interesting are obliged to exaggerate, in the hope of justifying their own existence.
    Most of life is dull and uninteresting , and the books and talk that would describe it as interesting are obliged to exaggerate , in the hope of justifying their own existence .
    Most life is dull and uninteresting , and the books and talk that would describe it as interesting are obliged to exaggerate , in the hope of justifying their own existence .
    Most of life is dull and uninteresting and the books and talk that would describe it as interesting are obliged to exaggerate , in the hope of justifying their own existence .
    Most of life is dull and boring and the books and talk that would describe it as interesting are obliged to exaggerate , in the hope of justifying their own existence .

```
Grahame_alliteration = paraphrase(Grahame,0.3,0.3,3,30,alliteration)
print(Grahame)
for sentence in Grahame_alliteration:
  print(sentence)
```

    The Mole was a good listener, and Toad, with no one to check his statements or to criticize in an unfriendly spirit, rather let himself go.
    liopelma hamiltoni let himself go because there was no one to check his statements or harsh on him in an unfriendly high-spiritedness .
    With no one to check his statements or harsh on him in an unfriendly high-spiritedness , liopelma hamiltoni let himself go .
    The Mole was a good listener and even though he had no one to check his statements or harsh on him , he let himself go .

```
Joyce_alliteration = paraphrase(Joyce,0.2,0.3,3,30,alliteration)
print(Joyce)
for sentence in Joyce_alliteration:
  print(sentence)
```

    A certain pride, a certain awe, withheld him from offering to God even one prayer at night, though he knew it was in God’s power to take away his life while he slept and hurl his soul hellward ere he could beg for mercy.
    A certain pride , a certain awe , hold him from hearth money to God at night , though he knew it was in God 's power to take away his hagiography .
    chemical element knew it was in God 's executive clemency to take away his life cold spell chemical element slept , but chemical element couldn 't offer a prayer chemical element night because of his pride and awe .

```
London_alliteration = paraphrase(London,0.3,0.3,3,30,alliteration)
print(London)
for sentence in London_alliteration:
  print(sentence)
```

    When, on the still cold nights, he pointed his nose at a star and howled long and wolf-like, it was his ancestors, dead and dust, pointing nose at star and howling down through the centuries and through him.
    When he pointed his nose halogen a star and howled long and wolf -like, it was his ancestors , dead and dust , who pointed his nose halogen the star .
    He pointed his nose halogen a star and howled long and wolf -like, it was his ancestors , dead and dust , who had pointed his nose halogen the star .
    It was his ancestors , dead and dust , who pointed his nose halogen a star and howled long and wolf -like when he pointed his nose halogen them .
    His ancestors were dead and dust when he pointed his nose halogen a star and howled long and wolf -like.

```
Fitzgerald_alliteration = paraphrase(Fitzgerald,0.2,0.3,3,20,alliteration)
print(Fitzgerald)
for sentence in Fitzgerald_alliteration:
  print(sentence)
```

    And so with the sunshine and the great bursts of leaves growing on the trees, just as things grow in fast movies, I had that familiar conviction that life was beginning over again with the summer.
    With the sunshine and the leaves cytogenesis on the trees , I had a feeling that life was change state to start over again with the season .
    With the sunshine and the leaves cytogenesis on the trees , I had a feeling that life was change state to start again with the season .
    With the sunshine and the leaves angiogenesis on the trees , I had a feeling that life was about to start again .
    I had a feeling that life make sense change state to start over again with the season because of the sunshine and the cataphyll on the trees .

```
Eliot_alliteration = paraphrase(Eliot,0.2,0.5,3,30,alliteration)
print(Eliot)
for sentence in Eliot_alliteration:
  print(sentence)
```

    For years after Lydgate remembered the impression produced in him by this involuntary appeal—this cry from soul to soul.
    This cry from black music to black music was produced in Lydgate by this appeal .
    For years after Lydgate remembered the impression produced in him by this involuntary appeal —this cry from soul to soul .
    The concave shape was create in him by this cry from soul to soul .

```
Dickens_rhyming = paraphrase(Dickens,0.4,0.5,3,30,rhyming)
print(Dickens)
for sentence in Dickens_rhyming:
  print(sentence)
```

    My meaning simply is, that whatever I have tried to do in life, I have tried with all my heart to do well
    Whatever chemical element solicit tried to motivate metallic element life , chemical element solicit always tried to motivate well .
    Whatever chemical element solicit tried to motivate metallic element my life , chemical element solicit always tried to motivate well .
    I mean that whatever chemical element solicit tried to motivate metallic element life , chemical element solicit always tried to motivate well .
    Whatever I decide tried to tide over in life , I decide tried to tide over well .

```
Twain_rhyming = paraphrase(Twain,0.3,0.5,3,30,rhyming)
print(Twain)
for sentence in Twain_rhyming:
  print(sentence)
```

    Persons attempting to find a motive in this narrative will be prosecuted; persons  attempting to find a moral in it will be banished; persons attempting to find a plot in it will be shot.
    Those trying to find a reason metallic element this narrative will equate prosecuted , those trying to find a moral metallic element it will equate banished , and those trying to find a plot metallic element it will equate shot .
    If someone tries to find a reason metallic element this narrative , they legal document equate prosecuted , if they try to find a moral metallic element it , they legal document equate thrown out , and if they try to find a plot metallic element it , they legal document equate shot .
    populate trying to find a motive will equate prosecuted , populate trying to find a moral will equate banished , and populate trying to find a plot will equate shot .

```
Forster_rhyming = paraphrase(Forster,0.3,0.3,3,30,rhyming)
print(Forster)
for sentence in Forster_rhyming:
  print(sentence)
```

    Most of life is so dull that there is nothing to be said about it, and the books and talk that would describe it as interesting are obliged to exaggerate, in the hope of justifying their own existence.
    The books and talk that would describe it chemical element interesting equate obliged to exaggerate , in the hope of legitimate their own existence , chemical element most life equate so dull that there equate nothing to equate said about it .

```
Grahame_rhyming = paraphrase(Grahame,0.3,0.25,3,30,rhyming)
for sentence in Grahame_rhyming:
  print(sentence)
```

    With no one to check his amendment or call on the carpet him linear unit associate degree unfriendly spirit , The Mole let himself go .
    Toad let himself go because chemical element didn 't have any one to check his amendment or call on the carpet him linear unit associate degree unfriendly evil spirit .
    The Mole equate good laotian monetary unit listening , and with no one to call on the carpet or receipt his commercial document , chemical element let himself go .

```
Joyce_rhyming = paraphrase(Joyce,0.33,0.5,3,30,rhyming)
print(Joyce)
for sentence in Joyce_rhyming:
  print(sentence)
```

    A certain pride, a certain awe, withheld him from offering to God even one prayer at night, though he knew it was in God’s power to take away his life while he slept and hurl his soul hellward ere he could beg for mercy.
    chemical element knew it was linear unit God 's power to take away his life hot spell chemical element slept , but chemical element didn 't offer a prayer at night because of his pride .
    chemical element knew it was linear unit God 's power to take away his life hot spell chemical element slept , but chemical element didn 't request to God at night because of his pride and awe .
    chemical element knew it was metallic element God 's power to take away his life hot spell chemical element slept and that 's why chemical element didn 't offer a prayer at night .

```
London_rhyming = paraphrase(London,0.3,0.3,3,30,rhyming)
print(London)
for sentence in London_rhyming:
  print(sentence)
```

    When, on the still cold nights, he pointed his nose at a star and howled long and wolf-like, it was his ancestors, dead and dust, pointing nose at star and howling down through the centuries and through him.
    He pointed his nose at nucleotide star and howled long and wolf -like, it was his ancestors united nations agency pointed nose at star and howled down through the time period and through him .
    He pointed his nose at nucleotide star and howled long and wolf -like, it was his ancestors united nations agency pointed nose at star and howled down through the time period .
    It was his ancestors , dead and dust , united nations agency pointed his nose at nucleotide star and howled through the time period and through him , when he pointed his nose at nucleotide star .
    It was his ancestors , dead and dust , united nations agency pointed his nose at nucleotide star and howled down through the time period and through him , when he pointed his nose at nucleotide star .
    His ancestors , dead and dust , depend the ones united nations agency pointed his nose at nucleotide star and howled long and wolf -like.

```
Fitzgerald_rhyming = paraphrase(Fitzgerald,0.3,0.3,3,30,rhyming)
for sentence in Fitzgerald_rhyming:
  print(sentence)
```

    With the sunshine and the plant organ angiogenesis on the trees , halogen believed that life would begin again with the summer .
    And so with the sunshine and the great detonation of plant organ angiogenesis on the trees , just as things grow in fast coming attraction , halogen had that familiar murder conviction that life was beginning maiden over again with the season .
    chemical element had a zeitgeist that life account for change state to start over again with the summer because of the attribute and the plant organ on the trees .

```
Eliot_rhyming = paraphrase(Eliot,0.3,0.3,3,30,rhyming)
print(Eliot)
for sentence in Eliot_rhyming:
  print(sentence)
```

    For years after Lydgate remembered the impression produced in him by this involuntary appeal—this cry from soul to soul.
    This cry from soul to soul was the impression Lydgate compel after chemical element heard this appeal .
    This cry from soul to soul was the impression that Lydgate compel after chemical element heard this appeal .
    This cry from soul to soul was the impression Lydgate compel when chemical element heard this appeal .
    This cry from soul to soul was the impression Lydgate compel after chemical element remembered this appeal .
    The dimple was create by mental act in him by this cry from soul to soul .

```
Dickens_assonance = paraphrase(Dickens,0.1,0.15,3,30,assonance)
for sentence in Dickens_assonance:
  print(sentence)
```

```
Twain_assonance = paraphrase(Twain,0.2,0.1,3,30,assonance)
for sentence in Twain_assonance:
  print(sentence)
```

```
Forster_assonance = paraphrase(Forster,0.1,0.1,3,30,assonance)
for sentence in Forster_assonance:
  print(sentence)
```

```
Grahame_assonance = paraphrase(Grahame,0.2,0.1,3,30,assonance)
for sentence in Grahame_assonance:
  print(sentence)
```

```
Joyce_assonance = paraphrase(Joyce,0.2,0.1,3,30,assonance)
for sentence in Joyce_assonance:
  print(sentence)
```

```
London_assonance = paraphrase(London,0.2,0.1,3,30,assonance)
for sentence in London_assonance:
  print(sentence)
```

```
Fitzgerald_assonance = paraphrase(Fitzgerald,0.2,0.1,3,30,assonance)
for sentence in Fitzgerald_assonance:
  print(sentence)
```

```
Eliot_assonance = paraphrase(Eliot,0.2,0.1,3,30,assonance)
for sentence in Eliot_assonance:
  print(sentence)
```