Saturday, January 30, 2021

We Need Cost-of-Living-Adjusment Act (2020)


A person earning minimum wages today cannot survive on it year after year.

Following case study done for two years for person in Delhi proves this point:

Item Expense Month
Total 7955 Dec-2016
Total 8221 Jan-2017
Total 9006 Feb-2017
Total 9254 Mar-2017
Total 8284 Apr-2017
Total 8497 May-2017
Total 9912 Jun-2017
Total 9051 Jul-2017
Total 7453 Aug-2017
Total 8541 Sep-2017
Total 9880 Oct-2017
Total 11678 Nov-2017

Average Monthly Expenses (2017): 8978

Item Expense Month
Total 15128 Dec-2017
Total 10794 Jan-2018
Total 10989 Feb-2018
Total 10385 Mar-2018
Total 13462 Apr-2018
Total 10790 May-2018
Total 10525 Jun-2018
Total 10159 Jul-2018
Total 10340 Aug-2018
Total 13508 Sep-2018
Total 11655 Oct-2018
Total 13777 Nov-2018

Average Monthly Expenses (2018): 11793 (Yearly Change: 31%)
Average Monthly Expenses (2019): 15624 (Yearly Change: 33%)

Item Expense Month
Total 16049 Jan-2020
Total 21408 Feb-2020
Total 11997 Mar-2020
Total 11306 Apr-2020
Total 11749 May-2020
Total 11230 Jun-2020
Total 13034 Jul-2020
Total 24481 Aug-2020
Total 24944 Sep-2020
Total 17305 Oct-2020
Total 35500 Nov-2020
Total 25167 Dec-2020

Average Monthly Expenses (2020): 18681 (Yearly Change: 19.6%)
Additional note about year 2020:
- My monthly accomodation rental was about Rs 4000 (for single occupancy).
- In Feb-2020, some expenses involved sister's wedding.
- From Aug 2020 to Dec 2020, there incurred a medical expenses of roughly Rs 8000 per month.
- In Nov 2020, there was an expenditure of about Rs 13000 on a matrimonial site.
- Each year, there is a roughly expenditure of Rs 3000 on phone bill that involves the internet usage.

We see here that:
1. There is an increment of over 31 percent in 2018 in average monthly expenses
2. Average monthly expenses increased by 33 percent in 2019.
3. Average monthly expenses increased by 19.6 percent in 2020.
That is when a person is living hand to mouth and there is no improvement in quality of any aspect of life.
    
We not only need 'Minimum Wages' act but we also need COLA (Cost of Living Adjustment) act as well.

How much increment did you get in your last appraisal? If it is below 10 percent, don't even bother to mention it.

Related articles:
% Are Minimum Wages Sufficent?
% Article showing minimum wages set by Indian government:
% Who benefits from a higher minimum wages?

Friday, January 29, 2021

Installing RASA using YML File in Anaconda



Before starting, a note about creating, activating, deactivating, removing a Conda environment and listing all the installed environments:

(base) CMD>conda create -n my_env_name
(base) CMD>conda activate my_env_name
(my_env_name) CMD>conda deactivate
(base) CMD>conda remove -n my_env_name --all
(base) CMD>conda env list

AFTER INSTALLATION OF "Microsoft Visual C++ 14.0" FROM "Build Tools for Visual Studio" AS WE ARE ON WINDOWS OS:

We run an env.yml file containing following code:

name: my_rasa_env
channels:
- conda-forge
dependencies:
- spacy
- python=3.8
- pip
- pip:
  - rasa-core

-- -- -- -- -- 

(base) C:\Users\ashish\Desktop\code>conda env create -f env.yml

Collecting package metadata (repodata.json): done
Solving environment: done

Downloading and Extracting Packages
urllib3-1.26.3       | 99 KB     | #### | 100%
...
cython-blis-0.7.4    | 5.6 MB    | #### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Installing pip dependencies: | Ran pip subprocess with arguments:
['e:\\Anaconda3\\envs\\my_rasa_env\\python.exe', '-m', 'pip', 'install', '-U', '-r', 'C:\\Users\\ashish\\Desktop\\code\\condaenv.7w4auwk3.requirements.txt']
Pip subprocess output:
Collecting rasa-core
Using cached rasa_core-0.14.5-py3-none-any.whl (212 kB)
Collecting rocketchat-API~=0.6.0
...
Collecting characteristic
Using cached characteristic-14.3.0-py2.py3-none-any.whl (15 kB)
Building wheels for collected packages: Twisted
Building wheel for Twisted (setup.py): started
Building wheel for Twisted (setup.py): still running...
Building wheel for Twisted (setup.py): finished with status 'done'
Created wheel for Twisted: filename=Twisted-20.3.0-cp38-cp38-win_amd64.whl size=3098905 sha256=6eca0e3e573f4230d113548152f64c5aec4d0e7fa2d95b78caeaa5220de02bc9
Stored in directory: c:\users\ashish\appdata\local\pip\cache\wheels\f2\36\1b\99fe6d339e1559e421556c69ad7bc8c869145e86a756c403f4
Successfully built Twisted
Installing collected packages: ipython-genutils, ... rasa-core
Attempting uninstall: chardet
  Found existing installation: chardet 4.0.0
  Uninstalling chardet-4.0.0:
    Successfully uninstalled chardet-4.0.0
Successfully installed Automat-20.2.0 ConfigArgParse-1.2.3 Jinja2-2.11.2 MarkupSafe-1.1.1 PyHamcrest-2.0.2 PyYAML-5.4.1 Tubes-0.2.0 Twisted-20.3.0 Werkzeug-1.0.1 absl-py-0.11.0 aiohttp-3.7.3 alabaster-0.7.12 apscheduler-3.6.3 astunparse-1.6.3 async-generator-1.10 async-timeout-3.0.1 babel-2.9.0 bleach-3.2.3 boto3-1.16.62 botocore-1.19.62 cachetools-4.2.1 characteristic-14.3.0 chardet-3.0.4 click-7.1.2 cloudpickle-1.6.0 colorama-0.4.4 coloredlogs-15.0 constantly-15.1.0 cycler-0.10.0 decorator-4.4.2 defusedxml-0.6.0 docopt-0.6.2 docutils-0.16 entrypoints-0.3 fakeredis-1.4.5 fbmessenger-4.3.1 flask-1.1.2 flatbuffers-1.12 future-0.18.2 gast-0.3.3 gevent-21.1.2 google-auth-1.24.0 google-auth-oauthlib-0.4.2 google-pasta-0.2.0 graphviz-0.16 greenlet-1.0.0 grpcio-1.32.0 h5py-2.10.0 humanfriendly-9.1 hyperlink-21.0.0 imagesize-1.2.0 incremental-17.5.0 ipython-genutils-0.2.0 itsdangerous-1.1.0 jmespath-0.10.0 joblib-1.0.0 jsonpickle-1.5.0 jupyter-client-6.1.11 jupyter-core-4.7.0 jupyterlab-pygments-0.1.2 keras-2.4.3 keras-preprocessing-1.1.2 kiwisolver-1.3.1 klein-20.6.0 markdown-3.3.3 matplotlib-3.3.4 mistune-0.8.4 multidict-5.1.0 nbclient-0.5.1 nbconvert-6.0.7 nbformat-5.1.2 nbsphinx-0.8.1 nest-asyncio-1.5.1 networkx-2.5 oauthlib-3.1.0 opt-einsum-3.3.0 packaging-20.8 pandoc-1.0.2 pandocfilters-1.4.3 pathlib-1.0.1 pillow-8.1.0 ply-3.11 protobuf-3.14.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 pygments-2.7.4 pykwalify-1.6.0 pyparsing-2.4.7 pyreadline-2.1 python-dateutil-2.8.1 python-telegram-bot-13.1 pytz-2020.5 pywin32-300 pyzmq-22.0.1 rasa-core-0.8.6 rasa-nlu-0.11.5 redis-3.5.3 requests-oauthlib-1.3.0 rsa-4.7 ruamel.yaml-0.16.12 ruamel.yaml.clib-0.2.2 s3transfer-0.3.4 scikit-learn-0.24.1 scipy-1.6.0 simplejson-3.17.2 slackclient-2.9.3 snowballstemmer-2.1.0 sortedcontainers-2.3.0 sphinx-3.4.3 sphinxcontrib-applehelp-1.0.2 sphinxcontrib-devhelp-1.0.2 sphinxcontrib-htmlhelp-1.0.3 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.3 sphinxcontrib-serializinghtml-1.1.4 tensorboard-2.4.1 tensorboard-plugin-wit-1.8.0 tensorflow-2.4.1 tensorflow-estimator-2.4.0 termcolor-1.1.0 testpath-0.4.4 threadpoolctl-2.1.0 tornado-6.1 traitlets-5.0.5 typing-3.7.4.3 typing-extensions-3.7.4.3 tzlocal-2.1 webencodings-0.5.1 wrapt-1.12.1 yarl-1.6.3 zope.event-4.5.0 zope.interface-5.2.0

done
#
# To activate this environment, use
#
#     $ conda activate my_rasa_env
#
# To deactivate an active environment, use
#
#     $ conda deactivate 

Testing the installation

(base) C:\Users\ashish>conda activate my_rasa_env

(my_rasa_env) C:\Users\ashish>pip show rasa_core
Name: rasa-core
Version: 0.8.6
Summary: Machine learning based dialogue engine for conversational software.
Home-page: https://rasa.ai
Author: Rasa Technologies GmbH
Author-email: hi@rasa.ai
License: UNKNOWN
Location: e:\anaconda3\envs\my_rasa_env\lib\site-packages
Requires: tqdm, python-telegram-bot, pandoc, tensorflow, redis, Keras, coloredlogs, fbmessenger, pykwalify, scikit-learn, six, numpy, flask, graphviz, slackclient, apscheduler, nbsphinx, fakeredis, future, rasa-nlu, ConfigArgParse, jsonpickle, requests, ruamel.yaml, typing, h5py, networkx
Required-by: 

(my_rasa_env) C:\Users\ashish>pip show rasa_nlu
Name: rasa-nlu
Version: 0.11.5
Summary: Rasa NLU a natural language parser for bots
Home-page: https://rasa.com
Author: Alan Nichol
Author-email: alan@rasa.ai
License: UNKNOWN
Location: e:\anaconda3\envs\my_rasa_env\lib\site-packages
Requires: tqdm, matplotlib, numpy, klein, cloudpickle, boto3, typing, jsonschema, future, gevent, six, simplejson, pathlib, requests
Required-by: rasa-core

(my_rasa_env) C:\Users\ashish>pip show rasa
WARNING: Package(s) not found: rasa

We encountered some errors during our attempts to install RASA, following are the error logs and resolutions.

1: Erroneous code for environment "env.yml" as "rasa" is not available in channel "conda-forge":

name: rasa
channels:
- conda-forge
dependencies:
- pip
- rasa 

ERROR:

(base) C:\Users\ashish\Desktop\code>conda env create -f env.yml
Collecting package metadata (repodata.json): done
Solving environment: failed

ResolvePackageNotFound:
- rasa 

(base) C:\Users\ashish\Desktop\code>conda create -n erasa rasa
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

- rasa

Current channels:

- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

  https://anaconda.org

and use the search bar at the top of the page. 
  
2: Erroneous code for installing "rasa" through "pip":

The RASA documentations says this: You can install RASA using "pip3 install rasa" [ Ref: RASA ] 

ENV.YML:
name: rasa
channels:
- conda-forge
dependencies:
- pip
- pip:
  - rasa

Point to note: It does download "rasa-core" and "rasa-nlu", that too a couple dozen versions.

(base) C:\Users\ashish\Desktop\code>conda env create -f env.yml
Collecting package metadata (repodata.json): done
Solving environment: done

Downloading and Extracting Packages
wheel-0.36.2         | 31 KB     | #### | 100%
wincertstore-0.2     | 15 KB     | #### | 100%
vs2015_runtime-14.28 | 1.4 MB    | #### | 100%
pip-21.0             | 1.1 MB    | #### | 100%
sqlite-3.34.0        | 1.2 MB    | #### | 100%
certifi-2020.12.5    | 144 KB    | #### | 100%
tzdata-2020f         | 121 KB    | #### | 100%
python_abi-3.9       | 4 KB      | #### | 100%
vc-14.2              | 12 KB     | #### | 100%
python-3.9.1         | 19.9 MB   | #### | 100%
setuptools-49.6.0    | 954 KB    | #### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Installing pip dependencies: - Ran pip subprocess with arguments:
['e:\\Anaconda3\\envs\\rasa\\python.exe', '-m', 'pip', 'install', '-U', '-r', 'C:\\Users\\ashish\\Desktop\\code\\condaenv.fjji_o0b.requirements.txt']
Pip subprocess output:
Downloading rasa-1.10.2-py3-none-any.whl (510 kB)
Downloading pykwalify-1.7.0-py2.py3-none-any.whl (40 kB)
Downloading cloudpickle-1.3.0-py2.py3-none-any.whl (26 kB)
Downloading colorclass-2.2.0.tar.gz (17 kB)
Downloading matplotlib-3.2.2-cp39-cp39-win_amd64.whl (8.9 MB)
Downloading pytz-2019.3-py2.py3-none-any.whl (509 kB)
Downloading networkx-2.4-py3-none-any.whl (1.6 MB)
Downloading sanic-19.12.4-py3-none-any.whl (73 kB)
Downloading tensorflow_estimator-2.1.0-py2.py3-none-any.whl (448 kB)
Downloading absl-py-0.9.0.tar.gz (104 kB)
Downloading boto3-1.16.59-py2.py3-none-any.whl (130 kB)
Downloading python_engineio-3.12.1-py2.py3-none-any.whl (49 kB)
Downloading numpy-1.19.5-cp39-cp39-win_amd64.whl (13.3 MB)
Downloading SQLAlchemy-1.3.22-cp39-cp39-win_amd64.whl (1.2 MB)
Downloading fbmessenger-6.0.0-py2.py3-none-any.whl (11 kB)
Downloading kafka_python-1.4.7-py2.py3-none-any.whl (266 kB)
Downloading pydot-1.4.1-py2.py3-none-any.whl (19 kB)
Downloading questionary-1.5.2-py3-none-any.whl (26 kB)
Downloading async_generator-1.10-py3-none-any.whl (18 kB)
Downloading webexteamssdk-1.3.tar.gz (56 kB)
Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Downloading tensorflow_probability-0.9.0-py2.py3-none-any.whl (3.2 MB)
Using cached oauth2client-4.1.3-py2.py3-none-any.whl (98 kB)
Downloading ruamel.yaml-0.16.12-py2.py3-none-any.whl (111 kB)
Downloading PyJWT-1.7.1-py2.py3-none-any.whl (18 kB)
Downloading Sanic_Cors-0.10.0.post3-py2.py3-none-any.whl (17 kB)
Downloading ujson-2.0.3.tar.gz (7.1 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Installing backend dependencies: started
Installing backend dependencies: finished with status 'done'
  Preparing wheel metadata: started
  Preparing wheel metadata: finished with status 'done'

Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
Downloading terminaltables-3.1.0.tar.gz (12 kB)
Downloading tensorflow_hub-0.8.0-py2.py3-none-any.whl (101 kB)
Downloading rasa_sdk-1.10.3-py3-none-any.whl (39 kB)
Downloading coloredlogs-10.0-py2.py3-none-any.whl (47 kB)
Downloading pika-1.1.0-py2.py3-none-any.whl (148 kB)
Downloading rasa-1.10.1-py3-none-any.whl (509 kB)
Downloading rasa-1.10.0-py3-none-any.whl (509 kB)
Downloading rasa-1.9.7-py3-none-any.whl (497 kB)
Downloading tensorflow_hub-0.7.0-py2.py3-none-any.whl (89 kB)
Downloading python_engineio-3.11.2-py2.py3-none-any.whl (49 kB)
Requirement already satisfied: setuptools>=41.0.0 in e:\anaconda3\envs\rasa\lib\site-packages (from rasa->-r C:\Users\ashish\Desktop\code\condaenv.fjji_o0b.requirements.txt (line 1)) (49.6.0.post20210108)
Downloading rocketchat_API-0.6.36-py3-none-any.whl (9.5 kB)
Downloading ruamel.yaml-0.15.100.tar.gz (318 kB)
Downloading matplotlib-3.1.3.tar.gz (40.9 MB)
Downloading webexteamssdk-1.1.1.tar.gz (48 kB)
Downloading rasa-1.9.6-py3-none-any.whl (497 kB)
Downloading rasa-1.9.5-py3-none-any.whl (496 kB)
Downloading rasa-1.9.4-py3-none-any.whl (495 kB)
Downloading rasa-1.9.3-py3-none-any.whl (495 kB)
Downloading rasa-1.9.2-py3-none-any.whl (495 kB)
Downloading rasa-1.9.1-py3-none-any.whl (495 kB)
Downloading rasa-1.9.0-py3-none-any.whl (495 kB)
Downloading rasa-1.8.3-py3-none-any.whl (483 kB)
Downloading rasa-1.8.2-py3-none-any.whl (483 kB)
Downloading rasa-1.8.1-py3-none-any.whl (481 kB)
Downloading rasa-1.8.0-py3-none-any.whl (481 kB)
Downloading rasa-1.7.4-py3-none-any.whl (575 kB)
Using cached jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
Downloading slackclient-1.3.2.tar.gz (16 kB)
Downloading cloudpickle-1.2.2-py2.py3-none-any.whl (25 kB)
Downloading packaging-19.2-py2.py3-none-any.whl (30 kB)
Downloading colorhash-1.0.3-py3-none-any.whl (4.0 kB)
Downloading pika-1.0.1-py2.py3-none-any.whl (148 kB)
Downloading python_socketio-5.0.4-py2.py3-none-any.whl (52 kB)
Downloading sklearn_crfsuite-0.3.6-py2.py3-none-any.whl (12 kB)
Downloading aiohttp-3.7.3-cp39-cp39-win_amd64.whl (633 kB)
Downloading gym-0.15.4.tar.gz (1.6 MB)
Downloading gevent-1.5.0.tar.gz (5.3 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
  Preparing wheel metadata: started
  Preparing wheel metadata: finished with status 'done'
Downloading sanic-jwt-1.6.0.tar.gz (19 kB)
Downloading tensorflow_probability-0.7.0-py2.py3-none-any.whl (981 kB)
Downloading gast-0.2.2.tar.gz (10 kB)
Downloading twilio-6.51.0.tar.gz (457 kB)
Downloading matplotlib-3.3.3-cp39-cp39-win_amd64.whl (8.5 MB)
Downloading scikit-learn-0.20.4.tar.gz (11.7 MB)
Downloading python_engineio-4.0.0-py2.py3-none-any.whl (50 kB)
Downloading redis-3.3.11-py2.py3-none-any.whl (66 kB)
Downloading prompt_toolkit-2.0.10-py3-none-any.whl (340 kB)
Downloading mattermostwrapper-2.2.tar.gz (2.5 kB)
Downloading tqdm-4.56.0-py2.py3-none-any.whl (72 kB)
Downloading webexteamssdk-1.6-py3-none-any.whl (113 kB)
Downloading Sanic_Cors-0.9.9.post1-py2.py3-none-any.whl (16 kB)
Downloading attrs-20.3.0-py2.py3-none-any.whl (49 kB)
Downloading tensor2tensor-1.14.1-py2.py3-none-any.whl (1.6 MB)
Downloading sanic-19.9.0-py3-none-any.whl (73 kB)
Downloading APScheduler-3.7.0-py2.py3-none-any.whl (59 kB)
Downloading jsonpickle-1.5.0-py2.py3-none-any.whl (36 kB)
Downloading scipy-1.6.0-cp39-cp39-win_amd64.whl (32.7 MB)
Downloading python_telegram_bot-11.1.0-py2.py3-none-any.whl (326 kB)

Downloading multidict-4.6.1.tar.gz (115 kB)
Downloading rasa_sdk-1.7.0-py3-none-any.whl (37 kB)
Downloading rasa_sdk-1.6.1-py2.py3-none-any.whl (32 kB)
Downloading rasa_sdk-1.5.2-py2.py3-none-any.whl (32 kB)
Downloading rasa_sdk-1.4.0-py2.py3-none-any.whl (32 kB)
Downloading questionary-1.9.0-py3-none-any.whl (32 kB)
Downloading jsonschema-2.6.0-py2.py3-none-any.whl (39 kB)

Downloading rasa-1.7.3-py3-none-any.whl (575 kB)
Downloading rasa-1.7.2-py3-none-any.whl (575 kB)
Downloading rasa-1.7.1-py3-none-any.whl (574 kB)
Downloading rasa-1.7.0-py3-none-any.whl (573 kB)
Downloading rasa-1.6.2-py3-none-any.whl (559 kB)

Downloading rasa-1.6.1-py3-none-any.whl (559 kB)

Downloading rasa-1.6.0-py3-none-any.whl (558 kB)
Downloading rasa-1.5.3-py3-none-any.whl (530 kB)


Downloading rasa-1.5.2-py3-none-any.whl (529 kB)
Downloading rasa-1.5.1-py3-none-any.whl (529 kB)
Downloading rasa-1.5.0-py3-none-any.whl (527 kB)
Downloading rasa-1.4.6-py3-none-any.whl (518 kB)

Downloading rasa-1.4.5-py3-none-any.whl (517 kB)
Downloading rasa-1.4.4-py3-none-any.whl (517 kB)
Downloading rasa-1.4.3-py3-none-any.whl (518 kB)

Using cached absl_py-0.11.0-py3-none-any.whl (127 kB)
Downloading networkx-2.3.zip (1.7 MB)
Downloading simplejson-3.17.2.tar.gz (83 kB)
Downloading Sanic_Cors-0.9.9.post4-py2.py3-none-any.whl (16 kB)
Downloading pymongo-3.11.2-cp39-cp39-win_amd64.whl (383 kB)
Downloading sanic-19.3.1-py3-none-any.whl (60 kB)
Downloading fakeredis-1.4.5-py3-none-any.whl (35 kB)
Downloading rasa_sdk-1.3.3-py2.py3-none-any.whl (32 kB)
Downloading urllib3-1.24.3-py2.py3-none-any.whl (118 kB)
Downloading rasa_sdk-1.0.0-py2.py3-none-any.whl (22 kB)

Downloading rasa-1.4.2-py3-none-any.whl (516 kB)
Downloading rasa-1.4.1-py3-none-any.whl (516 kB)
Downloading rasa-1.4.0-py3-none-any.whl (515 kB)
Downloading rasa-1.3.10-py3-none-any.whl (507 kB)
Downloading rasa-1.3.9-py3-none-any.whl (506 kB)
Downloading rasa-1.3.8-py3-none-any.whl (505 kB)
Downloading rasa-1.3.7-py3-none-any.whl (505 kB)
Downloading rasa-1.3.6-py3-none-any.whl (505 kB)
Downloading rasa-1.3.4-py3-none-any.whl (504 kB)
Downloading rasa-1.3.3-py3-none-any.whl (503 kB)
Downloading rasa-1.3.2-py3-none-any.whl (502 kB)
Downloading rasa-1.3.1-py3-none-any.whl (502 kB)
Downloading rasa-1.3.0-py3-none-any.whl (502 kB)
Downloading rasa-1.2.12-py3-none-any.whl (471 kB)
Downloading rasa-1.2.11-py3-none-any.whl (471 kB)
Downloading rasa-1.2.10-py3-none-any.whl (471 kB)
Downloading rasa-1.2.9-py3-none-any.whl (471 kB)
Downloading rasa-1.2.8-py3-none-any.whl (471 kB)
Downloading rasa-1.2.7-py3-none-any.whl (471 kB)
Downloading rasa-1.2.6-py3-none-any.whl (470 kB)
Downloading rasa-1.2.5-py3-none-any.whl (470 kB)
Downloading rasa-1.2.4-py3-none-any.whl (469 kB)
Downloading rasa-1.2.3-py3-none-any.whl (469 kB)
Downloading rasa-1.2.2-py3-none-any.whl (468 kB)
Downloading rasa-1.2.1-py3-none-any.whl (468 kB)
Downloading rasa-1.2.0-py3-none-any.whl (468 kB)
Downloading rasa-1.1.8-py3-none-any.whl (464 kB)
Downloading rasa-1.1.7-py3-none-any.whl (455 kB)
Downloading rasa-1.1.6-py3-none-any.whl (453 kB)
Downloading rasa-1.1.5-py3-none-any.whl (452 kB)
Downloading rasa-1.1.4-py3-none-any.whl (447 kB)
Downloading rasa-1.1.3-py3-none-any.whl (446 kB)
Downloading rasa-1.1.2-py3-none-any.whl (444 kB)
Downloading rasa-1.1.1-py3-none-any.whl (444 kB)
Downloading rasa-1.1.0-py3-none-any.whl (444 kB)
Downloading rasa-1.0.9-py3-none-any.whl (440 kB)
Downloading rasa-1.0.8-py3-none-any.whl (440 kB)
Downloading rasa-1.0.7-py3-none-any.whl (439 kB)
Downloading rasa-1.0.6-py3-none-any.whl (438 kB)
Downloading rasa-1.0.5-py3-none-any.whl (438 kB)
Downloading rasa-1.0.4-py3-none-any.whl (438 kB)
Downloading rasa-1.0.3-py3-none-any.whl (438 kB)
Downloading rasa-1.0.2-py3-none-any.whl (438 kB)
Downloading rasa-1.0.1-py3-none-any.whl (436 kB)
Downloading rasa-1.0.0-py3-none-any.whl (436 kB)
Downloading rasa-0.1.1-py3-none-any.whl (6.1 kB)
Downloading rasa_core-0.14.5-py3-none-any.whl (212 kB)
Downloading rasa_nlu-0.15.1-py3-none-any.whl (147 kB)
Downloading networkx-2.5-py3-none-any.whl (1.6 MB)
Downloading redis-2.10.6-py2.py3-none-any.whl (64 kB)
Downloading Flask_Cors-3.0.10-py2.py3-none-any.whl (14 kB)
Downloading fbmessenger-5.6.0-py2.py3-none-any.whl (11 kB)
Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
Downloading Flask-JWT-Simple-0.0.3.tar.gz (6.9 kB)
Downloading pika-0.12.0-py2.py3-none-any.whl (108 kB)
Downloading fakeredis-0.10.3-py2.py3-none-any.whl (27 kB)
Downloading rasa_core_sdk-0.13.1-py2.py3-none-any.whl (20 kB)
Downloading Keras_Applications-1.0.6-py2.py3-none-any.whl (44 kB)
INFO: pip is looking at multiple versions of rasa to determine which version is compatible with other requirements. This could take a while.
Downloading rasa_core-0.14.4-py3-none-any.whl (212 kB)
Downloading rasa_core-0.12.3-py2.py3-none-any.whl (204 kB)
...
Downloading rasa_core-0.8.6-py2.py3-none-any.whl (103 kB)
Downloading rasa_core-0.7.0.tar.gz (60 kB)
Downloading pykwalify-1.6.0-py2.py3-none-any.whl (38 kB)
Downloading ConfigArgParse-0.13.0.tar.gz (31 kB)
Downloading PyYAML-3.13.tar.gz (270 kB)
Downloading scikit-learn-0.19.2.tar.gz (9.7 MB)
Downloading pika-0.11.2-py2.py3-none-any.whl (107 kB)
Downloading python_telegram_bot-10.1.0-py2.py3-none-any.whl (298 kB)
Downloading prompt_toolkit-1.0.14-py3-none-any.whl (248 kB)
Downloading python_engineio-3.14.2-py2.py3-none-any.whl (51 kB)
Downloading future-0.18.2.tar.gz (829 kB)
Downloading jsonpickle-0.9.6.tar.gz (67 kB)
Downloading PyInquirer-1.0.3.tar.gz (27 kB)
Downloading graphviz-0.9-py2.py3-none-any.whl (16 kB)
Downloading graphviz-0.8.4-py2.py3-none-any.whl (16 kB)
Downloading Keras-2.4.3-py2.py3-none-any.whl (36 kB)
Downloading rasa_core_sdk-0.11.5-py2.py3-none-any.whl (14 kB)
Downloading rasa_nlu-0.11.5.tar.gz (55 kB)
Downloading pandoc-1.0.2.tar.gz (488 kB)
Downloading graphviz-0.16-py2.py3-none-any.whl (19 kB)
Downloading python_telegram_bot-13.1-py3-none-any.whl (422 kB)
Downloading slackclient-2.9.3-py2.py3-none-any.whl (96 kB)
Downloading rasa_core-0.8.5.tar.gz (76 kB)
Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Downloading redis-3.5.3-py2.py3-none-any.whl (72 kB)
Downloading nbsphinx-0.8.1-py3-none-any.whl (24 kB)
Downloading typing-3.7.4.3.tar.gz (78 kB)
Downloading rasa-0.1.0-py3-none-any.whl (6.1 kB)
Downloading rasa-0.0.5.tar.gz (5.5 kB)
Downloading rasa-0.0.4.tar.gz (5.0 kB)
Downloading rasa-0.0.3.tar.gz (4.7 kB)
Downloading rasa-0.0.2.tar.gz (3.9 kB)
Downloading rasa-0.0.1.tar.gz (1.6 kB)
Downloading urllib3-1.26.2-py2.py3-none-any.whl (136 kB)
Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
Requirement already satisfied: certifi>=2017.4.17 in e:\anaconda3\envs\rasa\lib\site-packages (from requests < 3.0,>=2.23->rasa->-r C:\Users\ashish\Desktop\code\condaenv.fjji_o0b.requirements.txt (line 1)) (2020.12.5)
Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Building wheels for collected packages: rasa
Building wheel for rasa (setup.py): started
Building wheel for rasa (setup.py): finished with status 'done'
Created wheel for rasa: filename=rasa-0.0.5-py3-none-any.whl size=6115 sha256=21f60ab11f975e9f4855f730b54d316cac6d4864420dd62e945dfc6091330085
Stored in directory: c:\users\ashish\appdata\local\pip\cache\wheels\16\9b\e5\589820b8a86bcf14b1020a72bab300d7f853c133075a6f3d72
Successfully built rasa
Installing collected packages: urllib3, idna, chardet, requests, rasa
Successfully installed chardet-4.0.0 idna-2.10 rasa-0.0.5 requests-2.25.1 urllib3-1.26.2

done
#
# To activate this environment, use
#
#     $ conda activate rasa
#
# To deactivate an active environment, use
#
#     $ conda deactivate 

TESTING:::::

(base) C:\Users\ashish\Desktop\code>conda activate rasa

(rasa) C:\Users\ashish\Desktop\code>pip show rasa-nlu
WARNING: Package(s) not found: rasa-nlu

(rasa) C:\Users\ashish\Desktop\code>pip show rasa_nlu
WARNING: Package(s) not found: rasa_nlu

(rasa) C:\Users\ashish\Desktop\code>pip show rasa-core
WARNING: Package(s) not found: rasa-core

(rasa) C:\Users\ashish\Desktop\code>pip show rasa_core
WARNING: Package(s) not found: rasa_core

(rasa) C:\Users\ashish\Desktop\code>pip show rasa
Name: rasa
Version: 0.0.5
Summary: A wrapper Cisco ASA REST API
Home-page: http://networklore.com/rasa/
Author: Patrick Ogenstad
Author-email: patrick@ogenstad.com
License: Apache
Location: e:\anaconda3\envs\rasa\lib\site-packages
Requires: requests
Required-by:

The Cisco ASA is a security device that combines firewall, antivirus, intrusion prevention, and virtual private network (VPN) capabilities. It provides proactive threat defense that stops attacks before they spread through the network.

This is not what we were looking for. RASA is a chatbot framework.

Another failure while trying out RASA installation using "pip3".
The error we get is: "ModuleNotFoundError: No module named 'pypandoc'"
This error is fixed by using the Python version 3.8 as said in RASA Installation Docs. Our version of Python was 3.9.

(base) C:\Users\ashish>conda create -n myenv python

Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

environment location: e:\Anaconda3\envs\myenv

added / updated specs:
  - python


The following packages will be downloaded:

  package                    |            build
  ---------------------------|-----------------
  ca-certificates-2021.1.19  |       haa95532_0         122 KB
  certifi-2020.12.5          |   py39haa95532_0         141 KB
  openssl-1.1.1i             |       h2bbff1b_0         4.8 MB
  pip-20.3.3                 |   py39haa95532_0         1.8 MB
  python-3.9.1               |       h6244533_2        16.4 MB
  setuptools-52.0.0          |   py39haa95532_0         725 KB
  tzdata-2020f               |       h52ac0ba_0         113 KB
  vc-14.2                    |       h21ff451_1           8 KB
  vs2015_runtime-14.27.29016 |       h5e58377_2        1007 KB
  wheel-0.36.2               |     pyhd3eb1b0_0          33 KB
  wincertstore-0.2           |   py39h2bbff1b_0          15 KB
  ------------------------------------------------------------
                                         Total:        25.1 MB

The following NEW packages will be INSTALLED:

ca-certificates    pkgs/main/win-64::ca-certificates-2021.1.19-haa95532_0
certifi            pkgs/main/win-64::certifi-2020.12.5-py39haa95532_0
openssl            pkgs/main/win-64::openssl-1.1.1i-h2bbff1b_0
pip                pkgs/main/win-64::pip-20.3.3-py39haa95532_0
python             pkgs/main/win-64::python-3.9.1-h6244533_2
setuptools         pkgs/main/win-64::setuptools-52.0.0-py39haa95532_0
sqlite             pkgs/main/win-64::sqlite-3.33.0-h2a8f88b_0
tzdata             pkgs/main/noarch::tzdata-2020f-h52ac0ba_0
vc                 pkgs/main/win-64::vc-14.2-h21ff451_1
vs2015_runtime     pkgs/main/win-64::vs2015_runtime-14.27.29016-h5e58377_2
wheel              pkgs/main/noarch::wheel-0.36.2-pyhd3eb1b0_0
wincertstore       pkgs/main/win-64::wincertstore-0.2-py39h2bbff1b_0
zlib               pkgs/main/win-64::zlib-1.2.11-h62dcd97_4

Proceed ([y]/n)? y 

(base) C:\Users\ashish>conda activate myenv 

(myenv) C:\Users\ashish>pip3 install rasa
Collecting rasa
Using cached rasa-1.10.2-py3-none-any.whl (510 kB)
...
Using cached rasa-1.6.1-py3-none-any.whl (559 kB)
Requirement already satisfied: setuptools>=41.0.0 in e:\anaconda3\envs\myenv\lib\site-packages (from rasa) (52.0.0.post20210125)
Using cached rasa-1.6.0-py3-none-any.whl (558 kB)
...
Using cached rasa-0.1.1-py3-none-any.whl (6.1 kB)
Collecting rasa-core
Using cached rasa_core-0.14.5-py3-none-any.whl (212 kB)
...
Using cached rasa_core-0.7.9.tar.gz (61 kB)
  ERROR: Command errored out with exit status 1:
   command: 'e:\Anaconda3\envs\myenv\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ashish\\AppData\\Local\\Temp\\pip-install-ah9j5xnw\\rasa-core_5c8978c463de41d99df016553e2821a4\\setup.py'"'"'; __file__='"'"'C:\\Users\\ashish\\AppData\\Local\\Temp\\pip-install-ah9j5xnw\\rasa-core_5c8978c463de41d99df016553e2821a4\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\ashish\AppData\Local\Temp\pip-pip-egg-info-98hq0mod'
       cwd: C:\Users\ashish\AppData\Local\Temp\pip-install-ah9j5xnw\rasa-core_5c8978c463de41d99df016553e2821a4\
  Complete output (14 lines):
  Traceback (most recent call last):
    File "C:\Users\ashish\AppData\Local\Temp\pip-install-ah9j5xnw\rasa-core_5c8978c463de41d99df016553e2821a4\setup.py", line 9, in module
      import pypandoc
  ModuleNotFoundError: No module named 'pypandoc'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "string", line 1, in module
    File "C:\Users\ashish\AppData\Local\Temp\pip-install-ah9j5xnw\rasa-core_5c8978c463de41d99df016553e2821a4\setup.py", line 12, in module
      readme = open('README.md').read()
    File "e:\Anaconda3\envs\myenv\lib\encodings\cp1252.py", line 23, in decode
      return codecs.charmap_decode(input,self.errors,decoding_table)[0]
  UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 882: character maps to undefined
  ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

(myenv) C:\Users\ashish> 

Error is due to not using correct version of Python to work with RASA:

(erasa) C:\Users\ashish\Desktop\code>python
Python 3.9.1 (default, Dec 11 2020, 09:29:25) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

WE NEED A LOWER VERSION OF PYTHON:

Dated: 26-Jan-2021
You can install Rasa Open Source using pip (requires Python 3.6, 3.7 or 3.8).

According to this link: RASA Docs  

For Installation of RASA on Windows, you need "Microsoft Visual C++ 14.0 is required. Get it with 'Build Tools for Visual Studio'". 

running build_ext
building 'twisted.test.raiser' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Failed building wheel for Twisted
  ERROR: Command errored out with exit status 1:
  command: 'e:\Anaconda3\envs\erasa3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ashish\\AppData\\Local\\Temp\\pip-install-fpvqt_cw\\twisted_d52b02a3aff44d87b026985a9469039a\\setup.py'"'"'; __file__='"'"'C:\\Users\\ashish\\AppData\\Local\\Temp\\pip-install-fpvqt_cw\\twisted_d52b02a3aff44d87b026985a9469039a\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\ashish\AppData\Local\Temp\pip-record-exf7fho7\install-record.txt' --single-version-externally-managed --compile --install-headers 'e:\Anaconda3\envs\erasa3\Include\Twisted'
      cwd: C:\Users\ashish\AppData\Local\Temp\pip-install-fpvqt_cw\twisted_d52b02a3aff44d87b026985a9469039a\ 
Check the logs for full command output.

failed
CondaEnvException: Pip failed  
Tags: Technology,Natural Language Processing,Anaconda,Machine Learning,Python,

Working with compiled Python code (.pyc file)



How to manually generate a .pyc file from a .py file?

Answer: Use 'compileall' in the terminal. The following command will go recursively into sub directories and make .pyc files for all the python files it finds. The compileall module is part of the python standard library, so you don't need to install anything extra to use it. This works exactly the same way for python2 and python3.

$ python -m compileall .

Or You can compile individual files(s) from the command line with:

$ python -m compileall [file_1].py [file_n].py

-- -- -- -- --

We have a script.py file that looks like this:

print("Hello World!")

In Use

(base) C:\Users\ashish\Desktop\code\1>dir
 Directory of C:\Users\ashish\Desktop\code\1

01/28/2021  11:58 AM    [DIR]          .
01/28/2021  11:58 AM    [DIR]          ..
01/28/2021  11:59 AM                21 script.py
               1 File(s)             21 bytes
               2 Dir(s)  108,239,290,368 bytes free

(base) C:\Users\ashish\Desktop\code\1>python -m compileall .
Listing '.'...
Compiling '.\\script.py'...

(base) C:\Users\ashish\Desktop\code\1>tree /f
Folder PATH listing for volume OSDisk

C:.
│   script.py
│
└───__pycache__
        script.cpython-37.pyc 

(base) C:\Users\ashish\Desktop\code\1>

Execution

(base) C:\Users\ashish\Desktop\code\2>dir
 Directory of C:\Users\ashish\Desktop\code\2

01/28/2021  12:00 PM    [DIR]          .
01/28/2021  12:00 PM    [DIR]          ..
01/28/2021  11:59 AM               124 script.cpython-37.pyc
               1 File(s)            124 bytes
               2 Dir(s)  108,236,578,816 bytes free 

(base) C:\Users\ashish\Desktop\code\2>python script.cpython-37.pyc
Hello World!

(base) C:\Users\ashish\Desktop\code\2>cd ../1

We create a file "script2.py" at path "\code\1":

def myfunc(in_str = "Hello World"):
    print(in_str)

(base) C:\Users\ashish\Desktop\code\1>dir
 Directory of C:\Users\ashish\Desktop\code\1

01/28/2021  01:23 PM    [DIR]          .
01/28/2021  01:23 PM    [DIR]          ..
01/28/2021  11:59 AM                21 script.py
01/28/2021  01:23 PM                56 script2.py
01/28/2021  11:59 AM    [DIR]          __pycache__
               2 File(s)             77 bytes
               3 Dir(s)  107,205,185,536 bytes free 

(base) C:\Users\ashish\Desktop\code\1>python -m compileall script2.py
Compiling 'script2.py'...

(base) C:\Users\ashish\Desktop\code\1>

We have "script3.py" at path "C:\Users\ashish\Desktop\code\1"

from script2 import myfunc

myfunc()

myfunc("From script 3.")

We run it to get.

(base) C:\Users\ashish\Desktop\code\1>python script3.py
Hello World
From script 3.

Next, we try and fail (then later succeed) in using a compiled Python code:

We did these tests after reading from StackOverflow and as a result we generate some error logs:

(base) C:\Users\ashish\Desktop\code\2>python script3.py
Traceback (most recent call last):
  File "script3.py", line 1, in [module]
    from script2 import myfunc
ModuleNotFoundError: No module named 'script2'

(base) C:\Users\ashish\Desktop\code\2>python script2.cpython-37.pyc

(base) C:\Users\ashish\Desktop\code\2>python script3.py
  File "script3.py", line 1
    from  script2.cpython-37 import myfunc
                         ^
SyntaxError: invalid syntax 

Another failed attempt (before success) using "marshal" package:

import marshal
s = open('script2.cpython-37.pyc', 'rb')
s.seek(12)  # Also tried s.seek(8) here. First 4 bytes are for signaling a 'magic number'. Next 4 bytes holding a modification timestamp.

code_obj = marshal.load(s)
exec(code_obj)
myfunc()
myfunc("Testing from script4")

(base) C:\Users\ashish\Desktop\code\2>python script4.py
Traceback (most recent call last):
  File "script4.py", line 5, in [module]
    code_obj = marshal.load(s)
ValueError: bad marshal data (unknown type code) 

Note: Try fixing this code and post answer on StackOverflow [Link].

- - - - - - - - - - - - - - - - - - -

Successful run (1):

We create a script "script5.py" using the "imp" package:
import imp
my_module = imp.load_compiled("script2", "script2.cpython-37.pyc")
my_module.myfunc('Testing script 5.')

Execution:

(base) C:\Users\ashish\Desktop\code\3>python script5.py
script5.py:14: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
Testing script 5.

Successful run (2):

We create a script "script6.py" that uses the "importlib" package: [ Reference ] 

import importlib
import sys

# For illustrative purposes.
#import tokenize
#file_path = tokenize.__file__
#module_name = tokenize.__name__

file_path = "script2.cpython-37.pyc"
module_name = "script2"

spec = importlib.util.spec_from_file_location(module_name, file_path)
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
spec.loader.exec_module(module)

module.myfunc()
module.myfunc("Testing from script 6.") 

(base) C:\Users\ashish\Desktop\code\3>DIR
 Directory of C:\Users\ashish\Desktop\code\3

01/28/2021  02:39 PM    [DIR]          .
01/28/2021  02:39 PM    [DIR]          ..
01/28/2021  02:06 PM               228 script2.cpython-37.pyc
01/28/2021  02:24 PM               418 script5.py
01/28/2021  02:38 PM               462 script6.py
               3 File(s)          1,108 bytes
               2 Dir(s)  106,838,298,624 bytes free

(base) C:\Users\ashish\Desktop\code\3>python script6.py
Hello World
Testing from script 6.

Tuesday, January 26, 2021

Journal (checking emotional temperature in Jan 2021)



My overall emotions and feelings these days are of hatred and disappointment.
I am not very fond of my family. I told my sister (Anu) to not write to me unless she needs anything from me. 
Anu had asked me about marriage and was throwing some ideas but she has been ignorant. I do not know when she last spoke to our mother, Sadhana. Anu's behavior is disgusting. 

When a girls' families talk to me, I at first have to give the explanation about my address and given the present situation that my grandparents have put me in, I don't have an address. My uncle claims the Mayur Vihar house, my buas are not giving a clarity about Tri Nagar's house. Buas (all the three Manju, Kumkum and Rekha) rather tell me that I should buy a house in Chandigarh and move my mom there. On similar lines, my aunt had suggested in last December when I had been in Delhi that I should rent a place and take my mother there. My aunt pretends that Mayur Vihar house belongs to her when on paper it still belongs to my grandpa. I am not really sure what my Grandpa wants. To him, saying pleasing words, nice things and buttering was the way to get through me. I sure owe him something for what I am today but I don’t like to be in debt, I don’t want to be in debt. 

My mother has separate demands like if I buy a house, the house should be near-by a Jain temple and this is not what I want as I am not religious. People buy house which is near-by the facilities such as hospitals or schools or offices or malls, but not a temple, no builder even promotes a property through a temple. What my mom doesn't understand is that Jains are a minority and a rather rigid one with distinguishing eating habits, religious practices and what not.

Also, I told Anu's father-in-law to stop sending me the 'good morning' messages. These were very irritating messages written in Hindi (spoken and written).

I am upset with my grandparents because they have not taken care of me as part of providing me a place to live. The house where my mother stays was in shambles with no roof, and rain falling down directly into her one room before I got it fixed.

When my Manju bua learns of this a few months later as I told her, she asks me if her old law books were there, which I had sold away as wastepaper for recycling. The books had taken the entire room and they were rotting there with termite. My badi bua would be asking about her Godrej almirah that is still there in the room. Kumkum bua and Manju bua call themselves very religious but their affinity towards these objects is rather surprising. She doesn't need the almirah, if she had needed it, she would have taken it away with her by now, but she hasn't.

Date: 26 Jan, 2021

Sunday, January 24, 2021

Please keep your city clean. Images from Vardhaman Park, Tri Nagar, Delhi 110035.


Vardhaman Vatika Entrance (Jan 2021)

Tree leaves piled up from months and nobody comes to pick them up and remove from here.

People should not put their deity's pictures everywhere. They are impinging on the autonomy of the general public with their basic right to a cleaner city.

A good sign: there is a public toilet here in this park but again it is not properly maintained.

Python code to create Annotations required by a custom SpaCy NER



First, we show the version of SpaCy we are using:
(e20200909) CMD>pip show spacy
Name: spacy
Version: 2.3.2
Summary: Industrial-strength Natural Language Processing (NLP) in Python
Home-page: https://spacy.io
Author: Explosion
Author-email: contact@explosion.ai
License: MIT
Location: c:\anaconda3\envs\e20200909\lib\site-packages
Requires: numpy, cymem, preshed, blis, tqdm, catalogue, thinc, wasabi, srsly, setuptools, murmurhash, plac, requests
Required-by: en-core-web-sm, aspect-based-sentiment-analysis 

Before we dive into code, here are few points to note:
1. The execution of code starts from the 'main.py'

2. The first input file is "list_of_entity_names.txt" that has the entities to be detected in the input text. The entities are written all in one line separated by a semi-colon.

3. The second input file is "test_input_strings.txt" that contains the strings we want the entities to be detected in.

Filename: .\main.py 

from get_annotations import getAnnotatedStrings

with open('test_input_strings.txt') as f:
    lines = f.readlines()

#print(lines)

annotations = []
for i in lines:
    annotations.append(getAnnotatedStrings(i))

with open('output.txt', mode="a") as f:
    for i in annotations:
        f.write(str(i) + "\n") 
    
Filename: .\list_of_entity_names.txt 

apple;apple cider vinegar;banana;Apple

Filename: .\get_annotations.py 

import copy

with open('list_of_entity_names.txt') as f:
    entity_names = f.read()
entity_names = list(set(entity_names.split(";")))

#print(entity_names)


def getAnnotatedStrings(textStr, entity_label = 'MY_ENTITY'):
    textStr = textStr.replace("'", "").replace("^ ", "") # Cleaning of text from Wikipedia
    haveMoreEntities = True
    
    entity_position = []
    entity_titles = []
    for entityStr in entity_names:
        start = textStr.find(entityStr)
        end = start + len(entityStr)
        if start != -1 and (not textStr[start - 1].isalnum()):
            # By the condition (not textStr[start - 1].isalnum()) we check that the match found is not in the middle of another word.
            try:
                if (not textStr[end].isalnum()):
                    entity_position += [(start, end, entity_label)]
                    entity_titles += [entityStr]
            except:
                entity_position += [(start, end, entity_label)]
                entity_titles += [entityStr]
    

    print("Initial discovery of entities: ", entity_position)
    print("Initial discovery of entity titles: ", entity_titles)
    print()

    # This "if" block was used for an activity with data related to 'pragramming languages'.
    # entity_titles.index('C') Throws "ValueError: element is not in list"
    if 'C' in entity_titles:
        c_variants = []
        if 'C#' in entity_titles:
            c_variants.append('C#')
        if 'C++' in entity_titles:
            c_variants.append('C++')
        if 'Objective-C' in entity_titles:
            c_variants.append('Objective-C')
        if len(c_variants) > 0:
            for i in c_variants:
                try:
                    c_start = entity_position[entity_titles.index('C')][0]
                except:
                    break
                i_start = entity_position[entity_titles.index(i)][0]
                i_end = entity_position[entity_titles.index(i)][1]
                if c_start >= i_start and c_start <= i_end:
                    del entity_position[entity_titles.index('C')]
                    entity_titles.remove('C') # First 'C' removed.

    overlap_detection_arr = []
    entity_position_out = copy.deepcopy(entity_position)
    
    for i in entity_position:
        temp_arr = []
        for j in entity_position:
            # This "i[1] < j[1] and i[1] > j[0]" is the overlap of kind: 
            # 'ashish', 'ishleen' being picked from a hypothetical word 'ashishleen'.
            if i[1] < j[1] and i[1] > j[0]:
                len1 = i[1] - i[0]
                len2 = j[1] - j[0]
                if len1 > len2:
                    try:
                        entity_position_out.remove(j)
                        del entity_titles[entity_position.index(j)]
                    except:
                        #print("Element not found.")
                        pass
                else:
                    try:
                        entity_position_out.remove(i)
                        del entity_titles[entity_position.index(i)]
                    except:
                        #print("Element not found.")
                        pass
                print("Overlap detected.")  
            else:
                temp_arr.append(False)

            # This "i[0] > j[0] and i[0] < j[1]" is the overlap of kind: jean (denoted by 'i'), greyjean (denoted by 'j')
            if i[0] > j[0] and i[0] < j[1]:
                len1 = i[1] - i[0]
                len2 = j[1] - j[0]
                if len1 > len2:
                    try:
                        entity_position_out.remove(j)
                        del entity_titles[entity_position.index(j)]
                    except:
                        #print("Element not found.")
                        pass
                else:
                    try:
                        entity_position_out.remove(i)
                        del entity_titles[entity_position.index(i)]
                    except:
                        #print("Element not found.")
                        pass
                print("Overlap detected.")  
            else:
                temp_arr.append(False)
        overlap_detection_arr.append(temp_arr)

    if len(entity_titles) > 0:
        rv = (str(textStr), {'entities': entity_position_out})
        print(rv)
        print()
        return rv
		
Filename: .\output.txt 

('An apple a day, keeps the doctor away.\n', {'entities': [(3, 8, 'MY_ENTITY')]})
('Dont add apple cider vinegar to everything.\n', {'entities': [(9, 28, 'MY_ENTITY')]})
('Apple is a fruit and so is banana.', {'entities': [(27, 33, 'MY_ENTITY'), (0, 5, 'MY_ENTITY')]})



Filename: .\test_input_strings.txt  

An apple a day, keeps the doctor away.
Don't add apple cider vinegar to everything.
Apple is a fruit and so is banana.



When we run the code in Command Prompt, it runs like this:

(e20200909) C:\Users\ashish\code>python main.py
Initial discovery of entities:  [(3, 8, 'MY_ENTITY')]
Initial discovery of entity titles:  ['apple']

('An apple a day, keeps the doctor away.\n', {'entities': [(3, 8, 'MY_ENTITY')]})

Initial discovery of entities:  [(9, 14, 'MY_ENTITY'), (9, 28, 'MY_ENTITY')]
Initial discovery of entity titles:  ['apple', 'apple cider vinegar']

Overlap detected.
('Dont add apple cider vinegar to everything.\n', {'entities': [(9, 28, 'MY_ENTITY')]})

Initial discovery of entities:  [(27, 33, 'MY_ENTITY'), (0, 5, 'MY_ENTITY')]
Initial discovery of entity titles:  ['banana', 'Apple']

('Apple is a fruit and so is banana.', {'entities': [(27, 33, 'MY_ENTITY'), (0, 5, 'MY_ENTITY')]})

--- --- --- --- ---

Note How to Remove Unused Imports:

(e20200909) >>>conda install autoflake -c conda-forge

(e20200909) >>>autoflake -i --remove-all-unused-imports main.py

(e20200909) >>>autoflake -i --remove-all-unused-imports get_annotations.py

Here:
-i, --in-place: make changes to files instead of printing diffs

--- --- --- --- ---


Thursday, January 21, 2021

Journal (a difficult tenant named Sanjay in Delhi) - January 22, 2021



February 2020: On a weekday morning, I received a phone call from Tri Nagar that a new prospective tenant would like to take the room on the first floor. This person Sanjay Kumar offered to pay ₹3000 for the bigger room facing the wider 75th street.
This man turned out to be a fraud. 
He said he would pay ₹2500 in the first month and would pay ₹3000 next month onwards. 
It never happened. He had joined in the second week of February. In March, he started delaying the payment and offered that he would get the bathroom door renovated in ₹1500 that I can reimburse from rent. It was the second time he was asking me to trust him for something. The first one was about the rent amount of ₹3000. The March payment didn't happen until 22nd, 23rd when I had to cancel the plan for bathroom door renovation and tell him to pay in full and immediately.
He paid about Rs 1500 and said he’d pay the rest the end of the month and the rest amount will come in a timely manner. This was the third time he was asking me to trust him.
A point to note is that he had also not paid any security, which is a fault on my part.
Following the 23rd, March, the lockdown happened. Sanjay Kumar is a fruit seller. He would have a castor for selling his fruits that he would sell in the market and earn a daily wage. Before this, he had said he was working for a travel agency where the owner died and his son didn’t run the business well and due to personal circumstances, he had to quit. Sanjay was living in our house with his son and wife. His son was in high school (9th or 10th) and his wife was a homemaker. His daughter was not staying here, and she was studying somewhere in a university.
It was a complete mess. In the month of April, there would be regular calls about his payments. It was very frustrating. The amount he was paying was not fixed and was like pennies to mevaried between 50 to 150 Rupees. Mom was not communicating it clearly to me about his total to-date payment and he would often come home late after she had gone to sleep so there would be no communication with me at times. 
I would have to make calls to try and reach him at time continuously for 30-40 minutes. I would have to call home on his wife’s number to know of his whereabouts, or I would have to call mom to help me reach them. His wife would ask me to not call her or ask her anything as she did not have anything to do about the payment and that only Sanjay would have to answer. 
By the end of the month, the situation had badly escalated and my Manju bua was aware about what was happening. Amma was aware. Mom had informed of Sanjay’s behavior to neighbors and mom had started to ponder if she should report about him to the police. My own tenor in Panchkula had become aware of problem at home and I was asked to not raise my voice in my room while being on call from home.
My bua asked me to be assertive but she refused to provide any significant help. She rather seemed distant and disinterested even to the ideas of accepting any money for the help I was asking. I was on my own. I had to hire a lawyer for this problematic tenant.
A thing to note about Sanjay was that he had a clear speech in Hindi, something I have not seen in our tenants so far. 
In May, Sanjay and I had reached a point when he would start using threats such as telling me about his wealthy and powerful relatives. At times, he would go on to insult me. Sanjay had left by the May end. The lockdown had been a factor that he was not able to move out earlier. Sanjay might have done a fraud of roughly 3000 to 4000 Rupees by not paying the rent for last month of May and making part payments for the rest of the previous months.