nlp-opticalreader 1.1.3
Convert Data of Image to Text data with Natural Language Processing


nlp-opticalreader
-------------

This Deep Learning Library is based on probability and mathematical computation, it predicts the words from an image, extracts them, and validate extracted words using Natural language processing.
This library can be used to extract data from any scanned Document any type of Image, Pdf, or any extension of the file. 
It will return "Data", "Entity", "Part of speech" and "Sentences" extracted from an image.

### Installation
```sh
$ pip3 install nlp-opticalreader
```

### Import 
```sh
from nlp_opticalreader import extract_all_data 
from nlp_opticalreader import extract_all_data_ln

* use 'extract_all_data' to extract data from co-ordinates
* use 'extract_all_data_ln' to extract data line by line

```

### Extract Data 
```sh
extract_all_data(extension, data_extract, filename)
extract_all_data_ln(extension, data_extract, filename)
```

| Inputs | Boolean |
| ------ | ------ |
| filename | "filename.pdf" |
| extension | True for PDF and False for Image |
| data_extract | False for single File and True for multiple |


### Output
```sh
It will return a tuple of data_ and probablity :
data_,prob_=({"Metadata":"","Data":"","Entities":"","Discription":"","Sentence":""},prob)
* in keys of data_
dict_keys(['Metadata', 'Data', 'Entities', 'Discription', 'Sentence'])
* in prob_
 probablity of predict words i.e 94.64
```

### working
```sh
filename="nair_image.pdf"
extension=True
data_extract=False
data_,probability_= extract_all_data(extension, data_extract, filename)
```
### Output ( probability_ )
```sh
94.64
```

### Output ( data_ ) 
```sh

{'Metadata': {'Extension': False, 'Extractor': False},
 'Data': 'kotak\nPVR\nKotak Mahindra Bank\nPVR KOTAK CARD\n4283 0605 4400 0357\nVALID 10/23\nVISA\nTHRU\nASHISH NAIR\nCAN 66776182\nPlatinum\nwww.ELLL\n',
 'Entities': [{'word': 'Kotak Mahindra Bank',
   'label': 'ORG',
   'explain': 'Companies, agencies, institutions, etc.'},
  {'word': 'PVR KOTAK CARD',
   'label': 'EVENT',
   'explain': 'Named hurricanes, battles, wars, sports events, etc.'},
  {'word': '4283 0605',
   'label': 'DATE',
   'explain': 'Absolute or relative dates or periods'},
  {'word': '10/23',
   'label': 'CARDINAL',
   'explain': 'Numerals that do not fall under another type'},
  {'word': 'THRU',
   'label': 'ORG',
   'explain': 'Companies, agencies, institutions, etc.'},
  {'word': '66776182',
   'label': 'DATE',
   'explain': 'Absolute or relative dates or periods'},
  {'word': 'ELLL',
   'label': 'ORG',
   'explain': 'Companies, agencies, institutions, etc.'}],
 'Discription': [{'word': 'kotak',
   'Part-of-speech': 'NOUN',
   'Dependency': 'ROOT',
   'Lemma': 'kotak',
   'Tag': 'NN'},
  {'word': '\n',
   'Part-of-speech': 'SPACE',
   'Dependency': '',
   'Lemma': '\n',
   'Tag': '_SP'},
  {'word': 'PVR',
   'Part-of-speech': 'PROPN',
   'Dependency': 'npadvmod',
   'Lemma': 'PVR',
   'Tag': 'NNP'},
  {'word': '\n',
   'Part-of-speech': 'SPACE',
   'Dependency': '',
   'Lemma': '\n',
   'Tag': '_SP'},
  {'word': 'Kotak',
   'Part-of-speech': 'PROPN',
   'Dependency': 'compound',
   'Lemma': 'Kotak',
   'Tag': 'NNP'},
  {'word': 'Mahindra',
   'Part-of-speech': 'PROPN',
   'Dependency': 'compound',
   'Lemma': 'Mahindra',
   'Tag': 'NNP'},
  {'word': 'Bank',
   'Part-of-speech': 'PROPN',
   'Dependency': 'ROOT',
   'Lemma': 'Bank',
   'Tag': 'NNP'},
  {'word': '\n',
   'Part-of-speech': 'SPACE',
   'Dependency': '',
   'Lemma': '\n',
   'Tag': '_SP'},
  {'word': 'PVR',
   'Part-of-speech': 'PROPN',
   'Dependency': 'compound',
   'Lemma': 'PVR',
   'Tag': 'NNP'},
  {'word': 'KOTAK',
   'Part-of-speech': 'PROPN',
   'Dependency': 'nsubj',
   'Lemma': 'KOTAK',
   'Tag': 'NNP'},
  {'word': 'CARD',
   'Part-of-speech': 'PROPN',
   'Dependency': 'ROOT',
   'Lemma': 'CARD',
   'Tag': 'NNP'},
  {'word': '\n',
   'Part-of-speech': 'SPACE',
   'Dependency': '',
   'Lemma': '\n',
   'Tag': '_SP'},
  {'word': '4283',
   'Part-of-speech': 'NUM',
   'Dependency': 'ROOT',
   'Lemma': '4283',
   'Tag': 'CD'},
  {'word': '0605',
   'Part-of-speech': 'NUM',
   'Dependency': 'npadvmod',
   'Lemma': '0605',
   'Tag': 'CD'},
  {'word': '4400',
   'Part-of-speech': 'NUM',
   'Dependency': 'nummod',
   'Lemma': '4400',
   'Tag': 'CD'},
  {'word': '0357',
   'Part-of-speech': 'NUM',
   'Dependency': 'ROOT',
   'Lemma': '0357',
   'Tag': 'CD'},
  {'word': '\n',
   'Part-of-speech': 'SPACE',
   'Dependency': '',
   'Lemma': '\n',
   'Tag': '_SP'},
  {'word': 'VALID',
   'Part-of-speech': 'NOUN',
   'Dependency': 'compound',
   'Lemma': 'valid',
   'Tag': 'NN'},
  {'word': '10/23',
   'Part-of-speech': 'NUM',
   'Dependency': 'ROOT',
   'Lemma': '10/23',
   'Tag': 'CD'},
  {'word': '\n',
   'Part-of-speech': 'SPACE',
   'Dependency': '',
   'Lemma': '\n',
   'Tag': '_SP'},
  {'word': 'VISA',
   'Part-of-speech': 'PROPN',
   'Dependency': 'ROOT',
   'Lemma': 'VISA',
   'Tag': 'NNP'},
  {'word': '\n',
   'Part-of-speech': 'SPACE',
   'Dependency': '',
   'Lemma': '\n',
   'Tag': '_SP'},
  {'word': 'THRU',
   'Part-of-speech': 'PROPN',
   'Dependency': 'ROOT',
   'Lemma': 'THRU',
   'Tag': 'NNP'},
  {'word': '\n',
   'Part-of-speech': 'SPACE',
   'Dependency': '',
   'Lemma': '\n',
   'Tag': '_SP'},
  {'word': 'ASHISH',
   'Part-of-speech': 'NOUN',
   'Dependency': 'compound',
   'Lemma': 'ASHISH',
   'Tag': 'NNS'},
  {'word': 'NAIR',
   'Part-of-speech': 'NOUN',
   'Dependency': 'ROOT',
   'Lemma': 'nair',
   'Tag': 'NN'},
  {'word': '\n',
   'Part-of-speech': 'SPACE',
   'Dependency': '',
   'Lemma': '\n',
   'Tag': '_SP'},
  {'word': 'CAN',
   'Part-of-speech': 'PROPN',
   'Dependency': 'ROOT',
   'Lemma': 'CAN',
   'Tag': 'NNP'},
  {'word': '66776182',
   'Part-of-speech': 'NUM',
   'Dependency': 'ROOT',
   'Lemma': '66776182',
   'Tag': 'CD'},
  {'word': '\n',
   'Part-of-speech': 'SPACE',
   'Dependency': '',
   'Lemma': '\n',
   'Tag': '_SP'},
  {'word': 'Platinum',
   'Part-of-speech': 'NOUN',
   'Dependency': 'ROOT',
   'Lemma': 'platinum',
   'Tag': 'NN'},
  {'word': '\n',
   'Part-of-speech': 'SPACE',
   'Dependency': '',
   'Lemma': '\n',
   'Tag': '_SP'},
  {'word': 'www',
   'Part-of-speech': 'NOUN',
   'Dependency': 'appos',
   'Lemma': 'www',
   'Tag': 'NN'},
  {'word': '.',
   'Part-of-speech': 'PUNCT',
   'Dependency': 'punct',
   'Lemma': '.',
   'Tag': '.'},
  {'word': 'ELLL',
   'Part-of-speech': 'PROPN',
   'Dependency': 'ROOT',
   'Lemma': 'ELLL',
   'Tag': 'NNP'},
  {'word': '\n',
   'Part-of-speech': 'SPACE',
   'Dependency': '',
   'Lemma': '\n',
   'Tag': '_SP'}],
 'Sentence': [kotak
  PVR,
  Kotak Mahindra Bank,
  PVR KOTAK CARD,
  4283 0605,
  4400 0357,
  VALID 10/23,
  VISA,
  THRU,
  ASHISH NAIR,
  CAN,
  66776182,
  Platinum
  www.,
  ELLL]}

```

###  Getting Data 
```sh

data_.get('Data')

kotak
PVR
Kotak Mahindra Bank
PVR KOTAK CARD
4283 0605 4400 0357
VALID 10/23
VISA
THRU
ASHISH NAIR
CAN 66776182
Platinum
www.ELLL

```


###  Getting Entities
```sh

data_.get('Entities')

[{'word': 'Kotak Mahindra Bank',
  'label': 'ORG',
  'explain': 'Companies, agencies, institutions, etc.'},
 {'word': 'PVR KOTAK CARD',
  'label': 'EVENT',
  'explain': 'Named hurricanes, battles, wars, sports events, etc.'},
 {'word': '4283 0605',
  'label': 'DATE',
  'explain': 'Absolute or relative dates or periods'},
 {'word': '10/23',
  'label': 'CARDINAL',
  'explain': 'Numerals that do not fall under another type'},
 {'word': 'THRU',
  'label': 'ORG',
  'explain': 'Companies, agencies, institutions, etc.'},
 {'word': '66776182',
  'label': 'DATE',
  'explain': 'Absolute or relative dates or periods'},
 {'word': 'ELLL',
  'label': 'ORG',
  'explain': 'Companies, agencies, institutions, etc.'}]

```


### Getting Sentence
```sh

data_.get('Sentence')

[kotak
PVR
, Kotak Mahindra Bank
, PVR KOTAK CARD
, 4283 0605, 4400 0357
, VALID 10/23
, VISA
, THRU
, ASHISH NAIR
, CAN, 66776182
, Platinum
www., ELLL
]

```


### Getting Discription
```sh

data_.get('Discription')

[{'word': 'kotak',
  'Part-of-speech': 'NOUN',
  'Dependency': 'ROOT',
  'Lemma': 'kotak',
  'Tag': 'NN'},
 {'word': '\n',
  'Part-of-speech': 'SPACE',
  'Dependency': '',
  'Lemma': '\n',
  'Tag': '_SP'},
 {'word': 'PVR',
  'Part-of-speech': 'PROPN',
  'Dependency': 'npadvmod',
  'Lemma': 'PVR',
  'Tag': 'NNP'},
 {'word': '\n',
  'Part-of-speech': 'SPACE',
  'Dependency': '',
  'Lemma': '\n',
  'Tag': '_SP'},
 {'word': 'Kotak',
  'Part-of-speech': 'PROPN',
  'Dependency': 'compound',
  'Lemma': 'Kotak',
  'Tag': 'NNP'},
 {'word': 'Mahindra',
  'Part-of-speech': 'PROPN',
  'Dependency': 'compound',
  'Lemma': 'Mahindra',
  'Tag': 'NNP'},
 {'word': 'Bank',
  'Part-of-speech': 'PROPN',
  'Dependency': 'ROOT',
  'Lemma': 'Bank',
  'Tag': 'NNP'},
 {'word': '\n',
  'Part-of-speech': 'SPACE',
  'Dependency': '',
  'Lemma': '\n',
  'Tag': '_SP'},
 {'word': 'PVR',
  'Part-of-speech': 'PROPN',
  'Dependency': 'compound',
  'Lemma': 'PVR',
  'Tag': 'NNP'},
 {'word': 'KOTAK',
  'Part-of-speech': 'PROPN',
  'Dependency': 'nsubj',
  'Lemma': 'KOTAK',
  'Tag': 'NNP'},
 {'word': 'CARD',
  'Part-of-speech': 'PROPN',
  'Dependency': 'ROOT',
  'Lemma': 'CARD',
  'Tag': 'NNP'},
 {'word': '\n',
  'Part-of-speech': 'SPACE',
  'Dependency': '',
  'Lemma': '\n',
  'Tag': '_SP'},
 {'word': '4283',
  'Part-of-speech': 'NUM',
  'Dependency': 'ROOT',
  'Lemma': '4283',
  'Tag': 'CD'},
 {'word': '0605',
  'Part-of-speech': 'NUM',
  'Dependency': 'npadvmod',
  'Lemma': '0605',
  'Tag': 'CD'},
 {'word': '4400',
  'Part-of-speech': 'NUM',
  'Dependency': 'nummod',
  'Lemma': '4400',
  'Tag': 'CD'},
 {'word': '0357',
  'Part-of-speech': 'NUM',
  'Dependency': 'ROOT',
  'Lemma': '0357',
  'Tag': 'CD'},
 {'word': '\n',
  'Part-of-speech': 'SPACE',
  'Dependency': '',
  'Lemma': '\n',
  'Tag': '_SP'},
 {'word': 'VALID',
  'Part-of-speech': 'NOUN',
  'Dependency': 'compound',
  'Lemma': 'valid',
  'Tag': 'NN'},
 {'word': '10/23',
  'Part-of-speech': 'NUM',
  'Dependency': 'ROOT',
  'Lemma': '10/23',
  'Tag': 'CD'},
 {'word': '\n',
  'Part-of-speech': 'SPACE',
  'Dependency': '',
  'Lemma': '\n',
  'Tag': '_SP'},
 {'word': 'VISA',
  'Part-of-speech': 'PROPN',
  'Dependency': 'ROOT',
  'Lemma': 'VISA',
  'Tag': 'NNP'},
 {'word': '\n',
  'Part-of-speech': 'SPACE',
  'Dependency': '',
  'Lemma': '\n',
  'Tag': '_SP'},
 {'word': 'THRU',
  'Part-of-speech': 'PROPN',
  'Dependency': 'ROOT',
  'Lemma': 'THRU',
  'Tag': 'NNP'},
 {'word': '\n',
  'Part-of-speech': 'SPACE',
  'Dependency': '',
  'Lemma': '\n',
  'Tag': '_SP'},
 {'word': 'ASHISH',
  'Part-of-speech': 'NOUN',
  'Dependency': 'compound',
  'Lemma': 'ASHISH',
  'Tag': 'NNS'},
 {'word': 'NAIR',
  'Part-of-speech': 'NOUN',
  'Dependency': 'ROOT',
  'Lemma': 'nair',
  'Tag': 'NN'},
 {'word': '\n',
  'Part-of-speech': 'SPACE',
  'Dependency': '',
  'Lemma': '\n',
  'Tag': '_SP'},
 {'word': 'CAN',
  'Part-of-speech': 'PROPN',
  'Dependency': 'ROOT',
  'Lemma': 'CAN',
  'Tag': 'NNP'},
 {'word': '66776182',
  'Part-of-speech': 'NUM',
  'Dependency': 'ROOT',
  'Lemma': '66776182',
  'Tag': 'CD'},
 {'word': '\n',
  'Part-of-speech': 'SPACE',
  'Dependency': '',
  'Lemma': '\n',
  'Tag': '_SP'},
 {'word': 'Platinum',
  'Part-of-speech': 'NOUN',
  'Dependency': 'ROOT',
  'Lemma': 'platinum',
  'Tag': 'NN'},
 {'word': '\n',
  'Part-of-speech': 'SPACE',
  'Dependency': '',
  'Lemma': '\n',
  'Tag': '_SP'},
 {'word': 'www',
  'Part-of-speech': 'NOUN',
  'Dependency': 'appos',
  'Lemma': 'www',
  'Tag': 'NN'},
 {'word': '.',
  'Part-of-speech': 'PUNCT',
  'Dependency': 'punct',
  'Lemma': '.',
  'Tag': '.'},
 {'word': 'ELLL',
  'Part-of-speech': 'PROPN',
  'Dependency': 'ROOT',
  'Lemma': 'ELLL',
  'Tag': 'NNP'},
 {'word': '\n',
  'Part-of-speech': 'SPACE',
  'Dependency': '',
  'Lemma': '\n',
  'Tag': '_SP'}]

```