Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

suryak-cs

🏠
Working from home
  • San Francisco, CA
View GitHub Profile
View upload.html
<html>
<head><title>Upload Image</title></head>
<body>
<center>
{% if msg %}
<p class = "p3">{{ msg }}</p>
{% endif %}
<h1>Upload new File</h1>
<form method=post enctype=multipart/form-data>
<p><input type=file name=file> <input type=submit value=Upload>
View index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Index</title>
<style type="text/css">
span {font-size: 1.6em;}
</style>
</head>
<body>
<H1 ><center>Welcome to LexNLP Demo</center></span></p>
View app.py
import os
from flask import Flask, render_template, request
from ocr_extraction import ocr_extraction,pdf_extract
from lexnlp_extraction import extract_pii
# define folder to save the uploaded image
UPLOAD_FOLDER = 'static/uploads/'
# Allowed file image file extension type
View lexnlp-extraction.py
import lexnlp.extract.en.pii
def extract_pii(input_string):
return list(lexnlp.extract.en.pii.get_pii(input_string))
View ocr_extraction.py
try:
from PIL import Image
except ImportError:
import Image
import pytesseract
def ocr_extraction(filename):
"""
This function will handle the core OCR processing of images.
"""